Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up

Chdir to the favorite directory

License

NotificationsYou must be signed in to change notification settings

nil-two/cdf

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

CI

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

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

Requirements

  • Perl (5.14.0 or later)

Installation

  1. Copycdf into your$PATH.
  2. Makecdf executable.
  3. Add the following config to your shell's profile.
Shell
sheval "$(cdf -w)"
basheval "$(cdf -w bash)"
zsheval "$(cdf -w zsh)"
yasheval "$(cdf -w yash)"
fishsource (cdf -w fish | psub)

Example

$ 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.

Commands

cdf [--]

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)

cdf [--] <label>

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")

cdf -a|--add <label> [<path>]

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")

cdf -l|--list

List labels.

$ cdf -lfirsthome

cdf -L|--list-with-paths

List labels with paths.

$ cdf -Lfirst/home/user/work/free/firsthome/home/user

cdf -p|--print <label>

Print the labeled path.

$ cdf -p first/home/user/work/free/first$ cdf -p home/home/user

cdf -r|--remove <label(s)>

Remove labels.

$ cdf -r home(Remove "home" in the registry)$ cdf -r first home(Remove "first" and "home" in the registry)

cdf -w|--wrapper [<shell>]

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)

cdf --help

Print usage.

$ cdf --help(Print usage)

Variables

CDF_REGISTRY

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>",    ...  }}

CDF_FILTER

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 {}'"'"''

License

MIT License

Author

nil2nil2@nil2.org

About

Chdir to the favorite directory

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

[8]ページ先頭

©2009-2025 Movatter.jp