- Notifications
You must be signed in to change notification settings - Fork0
Chdir to the favorite directory
License
nil-two/cdf
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
Chdir to the favorite directory.
$ pwd/home/user/work/projects/first$ cdf -a first(Label the path of the working directory with "first")$ cd$ pwd/home/user$ cdf first(Chdir to the directory labeled with "first")$ pwd/home/user/work/projects/first
usage: cdf [--] select a label and chdir to the labeled path cdf [--] <label> chdir to the labeled path cdf {-a|--add} <label> [<path>] label the path (default: working directory) cdf {-l|--list} list labels cdf {-L|--list-with-paths} list labels with paths cdf {-p|--print} <label> print the labeled path cdf {-r|--remove} <label(s)> remove labels cdf {-w|--wrapper} [<shell>] output the wrapper script (default: sh) cdf --help print usage and exitsupported-shells: sh, bash, zsh, yash, fishenvironment-variables: CDF_REGISTRY the registry path (default: ~/.config/cdf/registry.json) CDF_FILTER the interactive filtering command for selecting a label
- Perl (5.14.0 or later)
- Copy
cdf
into your$PATH
. - Make
cdf
executable. - Add the following config to your shell's profile.
Shell | |
---|---|
sh | eval "$(cdf -w)" |
bash | eval "$(cdf -w bash)" |
zsh | eval "$(cdf -w zsh)" |
yash | eval "$(cdf -w yash)" |
fish | source (cdf -w fish | psub) |
$ curl -L https://raw.githubusercontent.com/nil-two/cdf/master/cdf > ~/bin/cdf$ chmod +x ~/bin/cdf$ echo 'eval "$(cdf -w bash)"' >> ~/.bashrc
Note: In this example,$HOME/bin
must be included in$PATH
.
Select a label and chdir to the labeled path.It works only when the shell integration is enabled.
$ cdf(Select a label from labels in the registry, and chdir to the labeled path)
Chdir to the labeled path.It works only when the shell integration is enabled.
$ cdf first(Chdir to /home/user/work/free/first if /home/user/work/free/first is labeled with "first")$ cdf home(Chdir to /home/user if /home/user is labeled with "home")
Label the path.The default path is the working directory.
$ cdf -a work(Label the working directory with "work")$ cdf -a bin /home/user/bin(Label /home/user/bin with "bin")
List labels.
$ cdf -lfirsthome
List labels with paths.
$ cdf -Lfirst/home/user/work/free/firsthome/home/user
Print the labeled path.
$ cdf -p first/home/user/work/free/first$ cdf -p home/home/user
Remove labels.
$ cdf -r home(Remove "home" in the registry)$ cdf -r first home(Remove "first" and "home" in the registry)
Print the wrapper script.The default shell issh
.
Supported shells are as follows:
- sh
- bash
- zsh
- yash
- fish
$ eval "$(cdf -w)"(Enable the shell integration for the shell compatible with Bourne Shell)$ eval "$(cdf -w bash)"(Enable the shell integration for Bash)$ eval "$(cdf -w zsh)"(Enable the shell integration for Zsh)$ eval "$(cdf -w yash)"(Enable the shell integration for Yash)$ source (cdf -w fish | psub)(Enable the shell integration for Fish)
Print usage.
$ cdf --help(Print usage)
The path of the registry file.The default value is$HOME/.config/cdf/registry.json
.
The structure of JSON is as follows:
{ "version": "<registry-version>", "labels": { "<label1>": "<path1>", "<label2>": "<path2>", ... }}
The command to use select a label.The default value ispercol
.
# Use fzy to select the labelexport CDF_FILTER=fzy# Use fzf with preview to select the labelexport CDF_FILTER='fzf --layout=reverse --preview='"'"'printf "# %s\n" {}; cdf --print {}'"'"''
MIT License
nil2nil2@nil2.org
About
Chdir to the favorite directory