All Projects → b4b4r07 → Enhancd

b4b4r07 / Enhancd

🚀 A next-generation cd command with your interactive filter

Programming Languages

shell
77523 projects
awk
318 projects

Projects that are alternatives of or similar to Enhancd

Zoxide
A smarter cd command. Supports all major shells.
Stars: ✭ 4,422 (+115.81%)
Mutual labels:  command-line-tool, fzf, cli, zsh, autojump, fasd, jump, z
Z.lua
⚡ A new cd command that helps you navigate faster by learning your habits.
Stars: ✭ 2,164 (+5.61%)
Mutual labels:  fzf, zsh, cd, autojump, fasd, jump, z
czmod
🚀 Native Module Written in C to Boost z.lua !!
Stars: ✭ 35 (-98.29%)
Mutual labels:  zsh, cd, autojump, fasd, jump, z
smartcd
Expedite your navigation of Linux filesystem.
Stars: ✭ 35 (-98.29%)
Mutual labels:  cd, fzf, fuzzy-search, command-line-tool
Twf
Standalone tree view file explorer, inspired by fzf.
Stars: ✭ 196 (-90.43%)
Mutual labels:  fzf, cli, zsh
goto
Goto - The Good Way to Program
Stars: ✭ 14 (-99.32%)
Mutual labels:  zsh, cd, command-line-tool
Dotbare
Manage dotfiles and any git directories interactively with fzf
Stars: ✭ 327 (-84.04%)
Mutual labels:  command-line-tool, fzf, zsh
Sultan
Sultan: Command and Rule over your Shell
Stars: ✭ 625 (-69.5%)
Mutual labels:  command-line-tool, cli, zsh
Autoenv
Directory-based environments
Stars: ✭ 4,859 (+137.14%)
Mutual labels:  zsh, shell-extension, cd
Fz
Cli shell plugin, the missing fuzzy tab completion feature of z jump around command.
Stars: ✭ 359 (-82.48%)
Mutual labels:  zsh, fuzzy-search, cd
Fzf
🌸 A command-line fuzzy finder
Stars: ✭ 40,965 (+1899.27%)
Mutual labels:  fzf, cli, zsh
Iterfzf
Pythonic interface to fzf, a CLI fuzzy finder
Stars: ✭ 106 (-94.83%)
Mutual labels:  fzf, cli, fuzzy-search
Forgit
💤 A utility tool powered by fzf for using git interactively.
Stars: ✭ 1,823 (-11.03%)
Mutual labels:  fzf, cli, zsh
1pass
A caching wrapper for the 1Passworld CLI
Stars: ✭ 117 (-94.29%)
Mutual labels:  fzf, cli
Python N26
💵 Unofficial Python client for n26 (Number 26) - https://n26.com/
Stars: ✭ 116 (-94.34%)
Mutual labels:  command-line-tool, cli
Elixir cli spinners
Spinnig Animations for Command Line Applications
Stars: ✭ 117 (-94.29%)
Mutual labels:  command-line-tool, cli
Dynein
DynamoDB CLI written in Rust.
Stars: ✭ 126 (-93.85%)
Mutual labels:  command-line-tool, cli
Droid
A command-line tool for checking Android OS version history written by Rust.
Stars: ✭ 115 (-94.39%)
Mutual labels:  command-line-tool, cli
Freenom Dns Updater
A tool to update freenom's dns records
Stars: ✭ 117 (-94.29%)
Mutual labels:  command-line-tool, cli
Typin
Declarative framework for interactive CLI applications
Stars: ✭ 126 (-93.85%)
Mutual labels:  command-line-tool, cli

Description | Features | Known issues | Requirements | Usage
Installation | Configuration | References | License


🚀 enhancd v2 is ...

A next-generation cd command with an interactive filter

Description

cd command is one of the frequently used commands.

Nevertheless, it is not so easy to handle unfortunately. A directory path given as an argument to cd command must be a valid path that exists and is able to resolve. In other words, you cannot pass a partial path such as "dir" (you are in /home/lisa, dir is /home/lisa/work/dir) to cd command.

The new cd command called "enhancd" enhanced the flexibility and usability for a user. enhancd will memorize all directories visited by a user and use it for the pathname resolution. If the log of enhancd have more than one directory path with the same name, enhancd will pass the candidate directories list to the filter within the ENHANCD_FILTER environment variable in order to narrow it down to one directory.

Thanks to this mechanism, the user can intuitively and easily change the directory you want to go.

Features

  • Go to the visited directory in the past
  • Easy to filter, using your favorite filter
  • Work on Bash, Zsh and fish (cross-shell compatibility)
  • Go back to a specific parent directory like zsh-bd
  • Inside a git repo, the first list element is the git root directory
  • Fuzzy search in a similar name directory
  • Support standard input (echo $HOME | cd is acceptable)
  • Custom options (user-defined option is acceptable)

Issues

  • Fish version
    • Because of how fish piping works, it's not possible to pipe to cd like : ls / | cd

Fuzzy search

You can fuzzy-search a directory name you want to run cd. For example, a word "text" is expand to "test" and "txt".

Requirements

  • An interactive filter

    Choose any one from among these.

Usage

Under Zsh or Bourne shells such as sh and bash, you just source init.sh into your shell:

$ source ./init.sh

Because enhancd functions must be executed in the context of the current shell, you should run something like above command.

The basic usage of the cd command that has been implemented by enhancd is the same as the normal builtin cd command.

$ cd [-|..] <directory>

If no arguments are given, enhancd cd command will display a list of the directory you've visited once, encourage you to filter the directory that you want to move.

$ cd
  ...
  /home/lisa/src/github.com/b4b4r07/enhancd/zsh
  /home/lisa/src/github.com/b4b4r07/gotcha
  /home/lisa/src/github.com/b4b4r07/blog/public
  /home/lisa/src/github.com/b4b4r07/blog
  /home/lisa/src/github.com/b4b4r07/link_test
  /home/lisa/src/github.com/b4b4r07
  /home/lisa/Dropbox/etc/dotfiles
  /home/lisa/src/github.com/b4b4r07/enhancd
> /home/lisa
  247/247
> _

The ENHANCD_FILTER variable is specified as a list of one or more visual filter command such as this separated by colon (:) characters.

It is likely the only environment variable you'll need to set when starting enhancd.

$ ENHANCD_FILTER=peco; export ENHANCD_FILTER

Since the $ENHANCD_FILTER variable can be a list, enhancd will use $ENHANCD_FILTER to mean the first element unless otherwise specified.

$ ENHANCD_FILTER=fzy:fzf:peco
$ export ENHANCD_FILTER

Also,

Hyphen (-)

When enhancd takes a hyphen (-) string as an argument, it searchs from the last 10 directory items in the log. With it, you can search easily the directory you used last.

$ cd -
  /home/lisa/Dropbox/etc/dotfiles
  /home/lisa/Dropbox
  /home/lisa/src/github.com
  /home/lisa/src/github.com/b4b4r07/cli
  /home
  /home/lisa/src
  /home/lisa/src/github.com/b4b4r07/enhancd
  /home/lisa/src/github.com/b4b4r07/gotcha
  /home/lisa/src/github.com/b4b4r07
> /home/lisa/src/github.com/b4b4r07/portfolio
  10/10
> _

Then, since the current directory will be delete from the candidate, you just press Enter key to return to the previous directory after type cd - ($PWD is /home/lisa, $OLDPWD is /home/lisa/src/github.com/b4b4r07/portfolio).

Double-dot (..)

From the beginning, .. means the directory's parent directory, that is, the directory that contains it. When enhancd takes a double-dot (..) string as an argument, it behaves like a zsh-bd plugin. In short, you can jump back to a specific directory, without doing cd ../../...

For example, when you are in /home/lisa/src/github.com/b4b4r07/enhancd, type cd .. in your terminal:

$ cd ..
  /
  home
  lisa
  src
  github.com
> b4b4r07
  6/6
> _

When moving to the parent directory, the current directory is removed from the candidate.

Enhancd complete (fish)

On fish shell, you can use alt+f to trigger enhancd when typing a command, the selected item will be appended to the commandline

Options

$ cd --help
usage: cd [OPTIONS] [dir]

OPTIONS:
  -h, --help       Show help message
  -G, --ghq        Filter ghq list

Those options are defined at config.ltsv. As it is written in this json, the user have to make a directory list file or script that generate the list like this script. Of cource, you can disable those options if you do not like it.

Installation

Bash

# add the fzy brew tap to homebrew
$ brew tap jhawthorn/fzy

# install fzy and ccat with homebrew
$ brew install fzy ccat

# alt: brew install fzy ccat percol peco fzf
#  depending on which interactive filter you want to use

# install enhancd into your home directory (or a preferred directory)
$ cd ~
$ git clone https://github.com/b4b4r07/enhancd

# if you want to hide the directory in the finder (gui)
$ chflags hidden enhancd

# add enhancd to your bash profile (or sourced file of choice)
$ echo "source ~/enhancd/init.sh"  >> ~/.bash_profile

# reload your bash profile
$ source ~/.bash_profile

ZSH

Also if you use zsh as your shell, you can install this via zplug which is powerfull plugin mananger for zsh:

zplug "b4b4r07/enhancd", use:init.sh

Fish

System Requirements

Install with Fisher:

fisher install b4b4r07/enhancd

Configurations

ENHANCD_DIR

The ENHANCD_DIR variable is a base directory path. It defaults to ~/.enhancd.

ENHANCD_FILTER
  1. What is ENHANCD_FILTER?

    The ENHANCD_FILTER is an environment variable. It looks exactly like the PATH variable containing with many different filters such as peco concatenated using ':'.

  2. How to set the ENHANCD_FILTER variable?

    Setting the ENHANCD_FILTER variable is exactly like setting the PATH variable. For example:

    $ export ENHANCD_FILTER="/usr/local/bin/peco:fzf:non-existing-filter"

    This above command will hold good till the session is closed. In order to make this change permanent, we need to put this command in the appropriate profile file. The ENHANCD_FILTER command in this example is set with 3 components: /usr/local/bin/peco followed by fzf and the not-existing-filter.

    enhancd narrows the ENHANCD_FILTER variable down to one. However, the command does not exist can not be the candidate.

    Let us try to test this ENHANCD_FILTER variable.

    $ cd

    If cd command does not return error, the settings of ENHANCD_FILTER is success.

  3. How to find the value of the ENHANCD_FILTER variable?

    $ echo $ENHANCD_FILTER
    /usr/local/bin/peco:fzf:non-existing-filter
ENHANCD_COMMAND

The ENHANCD_COMMAND environment variable is to change the command name of enhancd cd. It defaults to cd.

When the command name is changed, you should set new command name to ENHANCD_COMMAND, export it and restart your shell (reload init.sh).

$ echo $ENHANCD_COMMAND
cd
$ export ENHANCD_COMMAND=ecd
$ source /path/to/init.sh

The ENHANCD_COMMAND may only hold one command name. Thus, in the previous example, it is true that enhancd cd command name is ecd, but it is not cd (cd is turned into original builtin cd).

Besides putting a setting such as this one in your ~/.bash_profile or .zshenv would be a good idea:

ENHANCD_COMMAND=ecd; export ENHANCD_COMMAND
ENHANCD_DISABLE_DOT

If you don't want to use the interactive filter, when specifing a double dot (..), you should set not zero value to $ENHANCD_DISABLE_DOT. Defaults to 0.

ENHANCD_DISABLE_HYPHEN

This option is similar to ENHANCD_DISABLE_DOT. Defaults to 0.

ENHANCD_DISABLE_HOME

If you don't want to use the interactive filter when you call cd without an argument, you can set any value but 0 for $ENHANCD_DISABLE_HOME. Defaults to 0.

ENHANCD_DOT_ARG

You can customize the double-dot (..) argument for enhancd by this environment variable. Default is ...

If you set this variable any but .., it gives you the double-dot behavior with that argument; i.e. upward search of directory hierarchy. Then cd .. changes current directory to parent directory without interactive filter.

In other words, you can keep original cd .. behavior by this option.

ENHANCD_HYPHEN_ARG

You can customize the hyphen (-) argument for enhancd by this environment variable. Default is -.

If you set this variable any but -, it gives you the hyphen behavior with that argument; i.e. backward search of directory-change history. Then cd - changes current directory to $OLDPWD without interactive filter.

In other words, you can keep original cd - behavior by this option.

ENHANCD_HYPHEN_NUM

You can customize the number of rows by "cd -" Default is 10.

This is passed to head comand as -n option.

ENHANCD_HOME_ARG

You can customize to trigger the argumentless cd behavior by giving the string specified by this environment variable as an argument. Default is empty string.

If you set this variable any but empty string, it gives you the behavior of cd with no argument; i.e. backward search of the whole directory-change history. Then cd with no argument changes current directory to $HOME without interactive filter.

In other words, you can keep original behavior of cd with no argument by this option.

ENHANCD_HOOK_AFTER_CD

Default is empty. You can run any commands after changing directory with enhancd (e.g. ls: like cd && ls).

ENHANCD_USE_FUZZY_MATCH

Default is 1 (enable). See #33.

ENHANCD_COMPLETION_KEYBIND

Default is Tab (^I). See #90.

ENHANCD_COMPLETION_BEHAVIOR

Default is the word of default (Regular completion). See #90.

It can be taken following words:

  • default
  • list (dir list with $ENHANCD_FILTER)
  • history (dir history list with $ENHANCD_FILTER)

References

The "visual filter" (interactive filter) is what is called "Interactive Grep Tool" according to percol that is a pioneer in interactive selection to the traditional pipe concept on UNIX.

License

MIT ©️ b4b4r07

Stargazers over time

Stargazers over time

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].