Description
|
Features
|
Requirements
|
Usage
Installation
|
Configuration
|
References
|
License
๐ enhancd v2 is ...
A next-generation cd
command with an interactive filter โจ
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 variable in order to narrow it down to one.
Thanks to that mechanism, the user can intuitively and easily change the directory where you want to go to.
cdinterface
is deprecated and was merged into this enhancd.
DEMO:
- Go to the visited directory in the past
- Easy to filter, using your favorite filter
- Work on Bash, Zsh and Fish ๐
- Go back to a specific parent directory like zsh-bd
- Fuzzy search in a similar name directory
You can fuzzy-search a directory name you want to run cd
. For example, a word "text" is expand to "test" and "txt".
Under Zsh or Bourne shells such as sh and bash, you would use enhancd.sh
. Under fish shell, enhancd.fish
.
$ source ./enhancd.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 [-|..] <directroy>
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=fzf:peco:gof
$ export ENHANCD_FILTER
-
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 doingcd ../../..
.For example, when you are in
/home/lisa/src/github.com/b4b4r07/enhancd
, typecd ..
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.
Give me a trial!
$ curl -L git.io/enhancd | sh
Paste that at a Terminal prompt.
To specify installation location for enhancd:
$ curl -L git.io/enhancd | PREFIX=/path/to/dir sh
PREFIX defaults to ~/.enhancd
.
- Grab enhancd.sh from github.com by using
git
,curl
orwget
- Add
source /path/to/enhancd.sh
to config file whose you use as the login shell
The above and below are almost the same.
$ git clone https://github.com/b4b4r07/enhancd ~/.enhancd
$ echo "source ~/.enhancd/bash/enhancd.bash" >> ~/.bashrc
All you need to do is to source enhancd.zsh
.
NOTE:
If you want to use older versions of enhancd (enhancd v1: dca011aa34), set BRANCH as v1 and run this command:
$ curl -L git.io/enhancd | BRANCH=v1 sh
Are you sure? To uninstall enhancd, paste the command below in a terminal prompt.
$ rm -r ~/.enhancd
The ENHANCD_DIR variable is a base directory path. It defaults to ~/.enhancd
.
-
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 ':'.
-
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 byfzf
and thenot-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.
-
How to find the value of the ENHANCD_FILTER variable?
$ echo $ENHANCD_FILTER /usr/local/bin/peco:fzf:non-existing-filter
The "visual 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.
- percol ๐ percol adds flavor of interactive selection to the traditional pipe concept on UNIX
- peco ๐ Simplistic interactive filtering tool
- hf ๐ hf is a command line utility to quickly find files and execute a command
- fzf ๐ fzf is a blazing fast command-line fuzzy finder written in Go
- gof ๐ gof - Go Fuzzy
- selecta ๐ Selecta is a fuzzy text selector for files and anything else you need to select
- pick ๐ Pick is "just like Selecta, but faster"
- icepick ๐ icepick is a reimplementation of Selecta in Rust
- sentaku ๐ Utility to make sentaku (selection, ้ธๆ(sentaku)) window with shell command
MIT ยฉ๏ธ BABAROT (a.k.a. b4b4r07)