{"id":16649289,"url":"https://github.com/rcmdnk/sd_cl","last_synced_at":"2025-04-09T16:52:29.165Z","repository":{"id":12799038,"uuid":"15472869","full_name":"rcmdnk/sd_cl","owner":"rcmdnk","description":"Save Directory and Change to the Last directly: Make change directory easy and save your time.","archived":false,"fork":false,"pushed_at":"2023-12-01T14:26:44.000Z","size":4495,"stargazers_count":16,"open_issues_count":0,"forks_count":2,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-03-23T18:54:24.295Z","etag":null,"topics":["bash","cd","shellscript","zsh"],"latest_commit_sha":null,"homepage":"","language":"Shell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/rcmdnk.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2013-12-27T11:53:22.000Z","updated_at":"2024-01-31T00:44:01.000Z","dependencies_parsed_at":"2022-08-31T13:50:42.089Z","dependency_job_id":null,"html_url":"https://github.com/rcmdnk/sd_cl","commit_stats":null,"previous_names":[],"tags_count":34,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rcmdnk%2Fsd_cl","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rcmdnk%2Fsd_cl/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rcmdnk%2Fsd_cl/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rcmdnk%2Fsd_cl/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rcmdnk","download_url":"https://codeload.github.com/rcmdnk/sd_cl/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248073414,"owners_count":21043431,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["bash","cd","shellscript","zsh"],"created_at":"2024-10-12T09:08:24.026Z","updated_at":"2025-04-09T16:52:29.142Z","avatar_url":"https://github.com/rcmdnk.png","language":"Shell","funding_links":[],"categories":[],"sub_categories":[],"readme":"# sd_cl (Save Directory and Change to the Last directly)\n\nMake change directory easy and save your time.\n\n\u003cdetails\u003e\n  \u003csummary\u003e\n    \u003cb\u003eTable of Content\u003c/b\u003e\n  \u003c/summary\u003e\n  \u003cdiv\u003e\n\n* [Demo](#demo)\n* [Installation](#installation)\n   * [Get sd_cL](#get-sd_cl)\n      * [cURL](#curl)\n      * [Homebrew at OS X](#homebrew-at-os-x)\n      * [Download](#download)\n   * [Set up sd_cl](#set-up-sd_cl)\n* [Main commands](#main-commands)\n   * [sd (Save Directory)](#sd-save-directory)\n   * [cl (Change to the Last directory)](#cl-change-to-the-last-directory)\n* [Usage](#usage)\n   * [Main functions: sd/cl](#main-functions-sdcl)\n   * [Use selection mode to select from the list](#use-selection-mode-to-select-from-the-list)\n   * [Filtering](#filtering)\n   * [Tab completion](#tab-completion)\n   * [Jump to N-th directory](#jump-to-n-th-directory)\n   * [Directory lists](#directory-lists)\n      * [Last directory list](#last-directory-list)\n      * [Pre-defined directory list](#pre-defined-directory-list)\n      * [Window directory list](#window-directory-list)\n      * [Ranking directory list](#ranking-directory-list)\n      * [History list (Move Back/Forward in the history)](#history-list-move-backforward-in-the-history)\n      * [Vim like file explorer](#vim-like-file-explorer)\n* [Selection tool](#selection-tool)\n* [Bonus functions](#bonus-functions)\n* [Options](#options)\n* [References](#references)\n\n  \u003c/div\u003e\n\u003c/details\u003e\n\n## Demo\n\n* [Main commands](#main-commands)\n\n![main functions](https://raw.githubusercontent.com/rcmdnk/sd_cl/fig/fig/sd_cl_main.gif)\n\n* [Selection tool](#selection-tool)\n\n![selection tool](https://raw.githubusercontent.com/rcmdnk/sd_cl/fig/fig/sd_cl_selection_tool.gif)\n\n* [Pre-defined directory list](#pre-defined-directory-list)\n\n![predef list](https://raw.githubusercontent.com/rcmdnk/sd_cl/fig/fig/sd_cl_predef2.gif)\n\n* [Tab completion](#tab-completion)\n\n![completion](https://raw.githubusercontent.com/rcmdnk/sd_cl/fig/fig/sd_cl_completion.gif)\n\n* [Window directory list](#window-directory-list)\n\n![window list](https://raw.githubusercontent.com/rcmdnk/sd_cl/fig/fig/sd_cl_screen.gif)\n\n* [Ranking directory list](#ranking-directory-list)\n\n![ranking list](https://raw.githubusercontent.com/rcmdnk/sd_cl/fig/fig/sd_cl_ranking.gif)\n\n* [History list (Move Back/Forward in the history)](#history-list-move-backforward-in-the-history)\n\nbd/fd commands\n\n![bd/fd](https://raw.githubusercontent.com/rcmdnk/sd_cl/fig/fig/sd_cl_bdfd.gif)\n\nUse keybindings at Bash\n\n![bd/fd bash](https://raw.githubusercontent.com/rcmdnk/sd_cl/fig/fig/sd_cl_bdfd_bash.gif)\n\nNote: Gif shows keys of Opt in Mac, but it is same as Cmd/Alt (iTerm's setting).\n\nUse keybindings at Zsh\n\n![bd/fd zsh](https://raw.githubusercontent.com/rcmdnk/sd_cl/fig/fig/sd_cl_bdfd_zsh.gif)\n\nNote: Gif shows keys of Opt in Mac, but it is same as Cmd/Alt (iTerm's setting).\n\n* [Vim like file explorer](#vim-like-file-explorer)\n\n![vim mode](https://raw.githubusercontent.com/rcmdnk/sd_cl/fig/fig/sd_cl_vim.gif)\n\n## Installation\n\n### Get sd_cL\n\nYou can get sd_cl by following methods.\n\n#### cURL\n\nYou can use an install script on the web like:\n\n    $ curl -fsSL https://raw.github.com/rcmdnk/sd_cl/install/install.sh| sh\n\nThis will install scripts to `/usr/etc`\nand you may be asked root password.\n\nIf you want to install other directory, do like:\n\n    $ curl -fsSL https://raw.github.com/rcmdnk/sd_cl/install/install.sh|  prefix=~/usr/local/ sh\n\n#### Homebrew at OS X\n\nOn Mac, you can install scripts by [Homebrew](https://github.com/mxcl/homebrew):\n\n    $ brew install rcmdnk/rcmdnkpac/sd_cl\n\nIf you have [brew file](https://github.com/rcmdnk/homebrew-file), add following lines to Brewfile:\n\n    tap 'rcmdnk/rcmdnkpac'\n    brew 'sd_cl'\n\nthen, do:\n\n    $ brew file install\n\nOr if you write like:\n\n    tapall 'rcmdnk/rcmdnkpac'\n\nand do `brew file install`, you will have all useful scripts in\n[rcmdnkpac](https://github.com/rcmdnk/homebrew-rcmdnkpac).\n\nThis installs `sd_cl` to `${HOMEBREW_PREFIX}/etc` (default: `/usr/local/etc/`).\n\n#### Download\n\nOr, simply download scripts and set where you like.\n\n    $ wget https://raw.githubusercontent.com/rcmdnk/sd_cl/master/etc/sd_cl\n\nor you can get it from GitHub directly.\n\n### Set up sd_cl\n\nGet `sd_cl` and set to where you like,\nthen, source it in your `.bashrc` or `.zshrc` like\n\n```bash\nsource /path/to/sd_cl\n```\n\n## Main commands\n\n### sd (Save Directory)\n\nCommands to manage stored directories.\n\n`sd` w/o arguments saves current directory to **the last directory** (default) list.\n\n    Usage: sd [-ecpwrCLh] [directory]\n\n    If neither '-e' nor '-C' is specified, 'directory' (or current directory if 'directory' is not given)\n    is stored in the list.\n\n    Arguments:\n       -e          Edit directory list file\n       -C          Clear directories\n       -H          Use the directory history file (~/.config/sd_cl/history)\n       -c          Use the last directory file (~/.config/sd_cl/lastdir)\n       -p          Use the pre-defiend dirctory file (~/.config/sd_cl/predef)\n       -L          Print license and quit\n       -h          Print this HELP and quit\n\n### cl (Change to the Last directory)\n\nCommands to change the directory to the stored one.\n\n`cl` w/o arguments change the directory to the last saved directory.\n\n    Usage: cl [-lecCpwrbvLh] [-n \u003cnumber\u003e ] [\u003cnumber\u003e] [\u003cdirectory\u003e]\n    If there are no arguments, you will move to the last saved directory by sd command.\n    If you give any directory name, it searches for it in saved directories\n    and cd to there if only one is found.\n    If more than one directories are found, go to the selection mode.\n\n    Arguments:\n       -l          Show saved directories\n       -e          Edit directory list file\n       -c          Show saved directories and choose a directory\n       -C          Clear directories\n       \u003cnumber\u003e    Move to \u003cnumber\u003e-th last directory\n       -n \u003cnumber\u003e Move to \u003cnumber\u003e-th last directory\n       -H          Move to the directory in history (~/.config/sd_cl/history)\n       -p          Move to pre-defiend dirctory in ~/.config/sd_cl/predef\n       -w          Move to other window's (screen/tmux) dirctory in ~/.config/sd_cl/window\n       -r          Move to ranking directory in ~/.config/sd_cl/ranking\n       -b          Move back in moving histories\n       -f          Move forward in moving histories\n       -v          Move from current directory, like Vim\n       -s \u003ctool\u003e   Set selection tool (multi tools can be set by comma separated array, default=sentaku,peco,percol,fzf,fzy,selecta,gof,picka)\n       -L          Print license and quit\n       -h          Print this HELP and quit\n\n`-l`, `-c`, `-C` and `-n` (`\u003cnumber\u003e`) are used exclusively.\n\n`-p` (pre-defined directory list), `-w` (window directory list),\n`-r` (ranking directory), `-b` (back in moving history), `-f` (forward in moving history), or `-v` (vim mode)\nchange the list file.\n\ne.x.) `cl -p 3` moves to the 3rd directory stored in pre-defined directory list.\n\n## Usage\n\n### Main functions: sd/cl\n\n`sd_cl` will load new functions:\n\n* `sd` (Save Directory)\n* `cl` (Change to the Last directory)\n\n`sd` saves current directory to the directory history list.\n\nIf you give a directory name, it saves the given directory.\n\n`cl` is used to change the directory to saved directories.\n\nIf it is called w/o arguments, you will move to the last saved directory by `sd`.\n\n### Use selection mode to select from the list\n\nBy the default, 20 directories are kept as a history.\n\nYou can choose from the history by using\n\n    $ cl -c\n\nThis command invokes a selection tool defined by `SD_CL_TOOL`,\none of installed selection tools or shell interactive selection.\n(See below for more details.)\n\nIf you give `-p`, `-w`, `-r`, `-b`, `-f` or `-v` instead of `-c`,\nthen each list is used for the selection instead of the last directory list.\n(see [Directory lists](#directory-lists).)\n\n### Filtering\n\nIf you give a part of the directory name like:\n\n    $ cl foo\n\nthen it starts a selection mode with directories including `foo`.\n\nIf it is only 1, it directly changes a directory to there.\n\n### Tab completion\n\nTab completion is available for both Bash and Zsh.\n\n    $ cl [Tab] # Completion with saved directory list.\n    $ cl foo [Tab] # Completion with directory names including 'foo'.\n\nIf you give a part of directory name to `cl`,\nyou will just move to the directory like normal `cd`.\n\nAfter tab completion, if there are still some candidates,\n`cl` starts the selection mode.\n\n### Jump to N-th directory\n\nIf you give a number, N, to `cl`,\nyou will jump into N-th direcoty on the list.\n\n    $ cl 3\n\n### Directory lists\n\n#### Last directory list\n\nThis is default list.\n\nThe list is stored in `SD_CL_LASTDIR_FILE`.\n\n`sd` w/o any arguments stores current directory to this list.\n\n`cl` calls this list by default.\n\nThe number of directories stored in the list is defined by `SD_CL_N`.\n\n#### Directory history list\n\nIf you use `-H` for `sd` or `cl`, it uses directory history,\nstored in `SD_CL_HISTORY_FILE`.\n\nIt is updated every `cd`.\n\nSet `SD_CL_HISTORY=0` to disable to update the history.\n\n\nSet `SD_CL_HISTORY_EXCLUDE=/a/b/c,/d/e/f` to exclude directories from hte list.\nThe default value is `$HOME`.\n\nSet `SD_CL_HISTORY_MAX` to set max number of directories in the history.\nThe default is 1000.\n\n#### Pre-defined directory list\n\nIf you use `-p` for `sd` or `cl`, it uses pre-defined directory list,\nstored in `SD_CL_PREDEF_FILE`.\n\nThis list is similar to the last directory list\nbut you can store some dedicated directories which should not be modified by `sd`.\n\nYou can edit the pre-defined list by `sd -e -p`.\n\n#### Window directory list\n\nIf you are working in GNU screen or tmux,\neach window's directory is saved automatically.\n\nThe list is stored in `SD_CL_WINDOW_FILE`.\n\nYou can call this list by `cl -w`.\n\nBy using `cl -w -l`, you can see the list with\n`window_number` and `pane_number` (always 0 for GNU screen).\n\nIf you want to see these numbers even in the selection mode,\nset `SD_CL_SHOW_MORE_INFO=1`\n\n#### Ranking directory list\n\n`sd_cl` makes a directory ranking by your usage of directories.\n\nThe list is stored in `SD_CL_RANKING_FILE`.\n\nThe list can be called by `cl -r`.\n\n`cl -r -l` shows the ranking point, too.\n\nAs same as window directory list,\nif `SD_CL_SHOW_MORE_INFO=1`, then the ranking point is shown in the selection mode, too.\n\nThe default ranking method (`SD_CL_RANKING_METHOD=2`) depends on how much you execute command in the directory.\nAfter any commands, the ranking point is added to the current directory.\n\nIf you set `SD_CL_RANKING_METHOD=1`,\nthe point is added only when `cd` is executed.\n\nIf you don't want to make the ranking list, set `SD_CL_RANKING_METHOD=0`.\n\nTo exclude directories from the ranking,\nset `SD_CL_RANKING_EXCLUDE`.\nIt can be comma separated list if you want to more than one directories, like:\n\n    SD_CL_RANKING_EXCLUDE=/tmp,~/tmp,/home/user/Desktop\n\nThe default value is `SD_CL_RANKING_EXCLUDE=$HOME`.\n\nThe ranking behavior can be changed by\n`SD_CL_RANKING_N_CD` (default: 100) or `SD_CL_RANKING_N_CMD` (default: 1000)\nfor `SD_CL_RANKING_METHOD=1` case or `SD_CL_RANKING_METHOD=2` case, respectively.\n\nThe smaller the value is set, the more the ranking is changable.\n\n#### History list (Move Back/Forward in the history)\n\nWith `cl -b`/`cl -f`, you can go back/foward the directories in your cd history.\n\n#### Vim like file explorer\n\nOption `-v` will give you the continuous selection mode to change the directory,\nlike vim file explorer.\n\n## Selection tool\n\nFor the selection mode, you can use your favorite selection tool.\n\nThe selection tool must accept pipe line input list,\nbe able to select a line, and return the line.\n\nFollowing tools are searched for and one of which is used if exists.\n\n* [rcmdnk/sentaku: Utility to make sentaku (selection, 選択(sentaku)) window with shell command.](https://github.com/rcmdnk/sentaku) (use `sentaku -s line` option)\n* [peco/peco: Simplistic interactive filtering tool](https://github.com/peco/peco)\n* [mooz/percol: adds flavor of interactive filtering to the traditional pipe concept of UNIX shell](https://github.com/mooz/percol)\n* [junegunn/fzf: A command-line fuzzy finder](https://github.com/junegunn/fzf)\n* [jhawthorn/fzy: A better fuzzy finder](https://github.com/jhawthorn/fzy)\n* [garybernhardt/selecta: A fuzzy text selector for files and anything else you need to select. Use it from vim, from the command line, or anywhere you can run a shell command.](https://github.com/garybernhardt/selecta)\n* [mattn/gof](https://github.com/mattn/gof)\n* [mptre/pick: A fuzzy search tool for the command-line](https://github.com/mptre/pick)\n\nYou can decide a selection tool as you like by setting `SD_CL_TOOL`, like\n\n    SD_CL_TOOL=sentaku,peco,percol,fzf,fzy,selecta,gof,picka\n\nin your **.bashrc** or **.zshrc**.\n\nOne or more tools can be set by comma separated array.\n\nIf any of tools is not available,\nsimple shell selection tool is launched.\n\nIf you want to use simple shell selection as top priority, set `SD_CL_TOOL=NONE` or `SD_CL_TOOL=shell` (or SD_CL_TOOL=\"\").\n\n## Bonus functions\n\n* bd (back Directory): Wrap function for `cl -b`.\n* fd (Forward Directory): Wrap function for `cl -f`.\n* up : Move up one directory.\n* cdpwd : works as `cd -P .` or `cd $(pwd -P)`, i.e. resolves symbolic links of the current path.\n* cdlink : works as `cd -P \u003cpath\u003e`, i.e. resolves symbolic links in \u003cpath\u003e.\n* cd : `cd` is wrapped to manage history, ranking, etc...\n\nIf you don't want to wrap `cd`, set `SD_CL_ISCDWRAP=0`.\n\nFor Bash/Zsh, `Meta`(`Alt`)-`o` and `Meta`(`Alt`)-`i`\nare bounden to `bd` and `fd`, respectively.\nIn addition, `Meta`(`Alt`)-`u` is bounden to `up` (move up one directory).\n\nset `SD_CL_BIND=0` to disable these binds.\n\nIf you want to assign different keys, set `SD_CL_BIND=0`.\nThen, for Zsh,  add bindings in **.zshrc** something like:\n\n    SD_CL_ZSH_BIND=0\n\n    source /path/to/sd_cl\n\n    bindkey '^[a' bd\n    bindkey '^[b' fd\n    bindkey '^[c' up\n\nFor Bash, add bindings in **.bashrc** something like:\n\n    SD_CL_ZSH_BIND=0\n\n    source /path/to/sd_cl\n\n    bind '\"\\ea\": \"\\C-ubd\\C-m\"'\n    bind '\"\\eb\": \"\\C-ufd\\C-m\"'\n    bind '\"\\ec\": \"\\C-uup\\C-m\"'\n\n\n## Options\n\nFollowing options can be set before sourcing `sd_cl` in `.bashrc` or `.zshrc`.\n\n    # Selection tool\n    SD_CL_TOOL=${SD_CL_TOOL:-sentaku,peco,percol,fzf,fzy,selecta,gof,picka}\n\n    # Number of kept last directories\n    SD_CL_N=${SD_CL_N:-20}\n\n    # Show window/pane or ranking information at selection\n    SD_CL_SHOW_MORE_INFO=${SD_CL_SHOW_MORE_INFO:-0}\n\n    # Directory store file\n    SD_CL_CONFIG_DIR=${SD_CL_CONFIG_DIR:-$HOME/.config/sd_cl}\n    SD_CL_LASTDIR_FILE=${SD_CL_LASTDIR_FILE:-${SD_CL_CONFIG_DIR}/lastdir}\n    SD_CL_PREDEF_FILE=${SD_CL_PREDEF_FILE:-${SD_CL_CONFIG_DIR}/predef}\n    SD_CL_WINDOW_FILE=${SD_CL_WINDOW_FILE:-${SD_CL_CONFIG_DIR}/window}\n    SD_CL_RANKING_FILE=${SD_CL_RANKING_FILE:-${SD_CL_CONFIG_DIR}/ranking}\n\n    # Ranking method\n    SD_CL_RANKING_METHOD=${SD_CL_RANKING_METHOD:-2}\n    SD_CL_RANKING_TRIAL_FILE=${SD_CL_RANKING_TRIAL_FILE:-${SD_CL_CONFIG_DIR}/ranking_trial}\n    SD_CL_RANKING_N_CD=${SD_CL_RANKING_N_CD:-100}\n    SD_CL_RANKING_N_CMD=${SD_CL_RANKING_N_CMD:-1000}\n    SD_CL_RANKING_EXCLUDE=${SD_CL_RANKING_EXCLUDE:-\"$HOME\"}\n\n    # post cd (overwrite cd (Bash) or chpwd (Zsh))\n    SD_CL_ISPOSTCD=${SD_CL_ISPOSTCD:-1}\n\n    # COMPLETION\n    SD_CL_NOCOMPLETION=${SD_CL_NOCOMPLETION:-0}\n    SD_CL_NOCOMPINIT=${SD_CL_NOCOMPINIT:-0}\n\n    # keybind\n    SD_CL_KEYBIND=1\n\n    # cd wrap to pushd/popd\n    SD_CL_ISCDWRAP=${SD_CL_ISCDWRAP:-1}\n\n\nYou can decide a selection tool as you like by setting `SD_CL_TOOL`, like\n\n    SD_CL_TOOL=sentaku,peco,percol,fzf,fzy,selecta,gof,picka\n\nOne or more tools can be set by comma separated array.\n\nIf any of tools is not available,\nsimple shell selection tool is launched.\n\nIf you want to use simple shell selection as top priority, set `SD_CL_TOOL=NONE` or `SD_CL_TOOL=shell` (or SD_CL_TOOL=\"\").\n\n`SD_CL_N` defines how many directories are kept in the last directory file.\n\nAt selection mode, only directory names are shown by default.\nIf `SD_CL_SHOW_MORE_INFO=1`, additional information of window/pane (for window list)\nor ranking information are shown.\nSuch information are always shown in the list command (`-l`).\n\n`SD_CL_CONFIG_DIR` is the directory for the configuration files.\nNext four file names are file names for the last directories (default),\npredefined directories, window directories, and ranking directories, respectively.\n\n`SD_CL_RANKING_METHOD` sets the method to make a ranking list.\n\n* 0: Do not make a ranking list.\n* 1: Add a directory when cd is executed.\n* 2: Add a directory at any commands.\n\n`SD_CL_RANKING_N_CD` and `SD_CL_RANKING_N_CMD` are parameters of the ranking\nfor `SD_CL_RANKING_METHOD` is 1 and 2 cases, respectively.\n\nIf you set the parameter smaller, the ranking becomes more changeable.\n\nIf you want to exclude some directories from the ranking,\nset `SD_CL_RANKING_EXCLUDE`.\nDefault value is `$HOME`. If you want to exclude several directories,\ngive comma separated directories like:\n\n    SD_CL_RANKING_EXCLUDE=/tmp,~/tmp,/home/user/Desktop\n\nIf you set `SD_CL_ISPOSTCD` to 0, it doesn't save window's directory\nin GNU screen or tmux.\n\nIf you set `SD_CL_NOCOMPLETION` to 1, completion will be disabled.\n\nFor Zsh user, if you already initialized completions with `compinit`,\nplease set `SD_CL_NOCOMPINIT=1`.\nOtherwise `sd_cl` execute:\n\n    autoload -Uz compinit\n    compinit\n\nIf you don't want to bind keys to bd/fd/up,\nset `SD_CL_KEYBIND=0`.\n\nIf you don't want to wrap `cd` with `pushd`, set `SD_CL_ISCDWRAP` to 0.\n\nIf you already have wrapper function for `cd` or the setting for `chpwd` at Zsh,\nyou should be better to set:\n\n    SD_CL_ISPOSTCD=0 # Don't do automatic save\n    SD_CL_ISCDWRAP=0 # Don't wrap cd\n\nOtherwise `sd_cl` overwrites these functions.\n\nIf you want to have automatic save in GNU screen/tmux with your `cd`/`chpwd`,\nfirst, set above SD_CL_ISPOSTCD and SD_CL_ISCDWRAP as 0 to disable to wrap in `sd_cl`,\nthen call `_sd_cl_post_cd` in your `cd` function for Bash like:\n\n    builtin cd \"$@\"\n    local ret=$?\n    if [ $ret -eq 0 ];then\n      _sd_cl_post_cd\n    fi\n    return $ret\n\nor simply call `post_cd` in `chpwd` for Zsh case.\n\nIf you want to enable pushd wrap in your `cd` function,\nreplace your `builtin(command) cd` command with\n\n    _wrap_cd \"$@\"\n\ni.e., if you want to enable both in Bash, you should replace above `builtin cd \"$@\"`\nwith `_wrap_cd \"$@\"`.\n\n## Other similar tools\n\n* `pushd`/`popd`/`dirs`\n\nBuiltin commands of the shell.\n\n`pushd \u003cdir\u003e` stores current directory and then move to given one.\n\n`popd` takes out the directory from the list and move to there.\n\n`dirs` shows the list.\n\nTheir functions are very useful and they are always available.\n\nBut they are not used so much because (I think) `p` `u` `s` `h` `d` are too many to put\nas frequent commands like `cd`.\n\nA lot of attempts to make wrapper functions for these commands can be found.\n\nThe simplest one is something like:\n\n```bash\nalias cd=\"pushd\"\nalias bd=\"popd\"\n```\n\n* [cdhist.sh](http://www.unixuser.org/~euske/doc/bashtips/cdhist.sh)\n\n\u003e [Bash の小枝集](http://www.unixuser.org/~euske/doc/bashtips/index.html)\n\n`chdhist.sh` wraps `cd` to store a directory history.\n\nIt loads following commands, too:\n\n    $ - # Move back\n    $ + # Move forward\n    $ = # Show the list\n\n* [wting/autojump: A cd command that learns - easily navigate directories from the command line](https://github.com/wting/autojump)\n\nCommand selection tool, `autojump`, written in Python.\n\nTo use it, users load a function `j` by sourcing **/usr/local/etc/autojump.sh**,\nand `j` calls `autojump` to select a directory.\n\n**/usr/local/etc/autojump.sh** also add `autojump_add_to_database` to\n`PROMPT_COMMAND`.\n`autojump_add_to_database` updates the directory history list after every command.\n\nEach directory has **key weight**, which is defined by how much user spends in a directory.\n\nUsers can go the directory contains a word `foo` by\n\n    $ j foo\n\nif it is in the list.\n\nIf there are more than one corresponding directories,\nthe highest weight directory is chosen.\n\n    $ jc foo\n\nsearches for directories only under the current directory.\n\nIt also loads command `jo` which opens the directory by an explorer.\n\n* [rupa/z: z - jump around](https://github.com/rupa/z)\n\n`z` is similar tool to autojump, but written in Shell Script.\nSo it is almost no dependency on external commands (though it uses such awk, grep).\n\nSourcing **z.sh** loads `z` command.\nIn addition, it adds `_z --add...` to `PROMPT_COMMAND`.\n`_z --add...` updates the directory list with current directory,\nand adds **frecency**(=frequency+recency), which is defined by how frequently and recently user works in there.\n\n    $ z foo\n\nThis select the directory contains foo.\n\nIf there are more than one corresponding directories,\nthe highest frecency directory is chosen.\n\n`z` has also some selection mode like `z -r foo` (most highest frequency) or `z -t -foo` (most highest recency).\n\n* [b4b4r07/enhancd: A next-generation cd command with an interactive filter](https://github.com/b4b4r07/enhancd)\n\n`cd` wrap tool written in Shell Script.\n\nBy sourcing `init.sh`, `cd` will work as history register and directory searcher.\n\nAfter every `cd`, it adds the current directly,\nall directoies in the path to the current directory,\nand child directories of the current directory.\n**enhancd** doesn't add a weight.\n\n    $ source ./init.sh\n\nThen,\n\n    $ cd foo\n\nsearches for a directory including `foo` from the list.\n\nIf there are more than one directories,\nit launches a selection mode.\nYou need one of selection tools like fzy, fjf, peco, sentaku, etc...\n\n**enhanced** wraps such `cd ..` and `cd -`, too,\nto launches a selection mode for upper directories or past directories, respectively.\n\n## References\n\n* [sd_cl: pecoやfzfなどにも対応したディレクトリ移動効率化ツール](https://rcmdnk.com/blog/2018/08/18/computer-shell/)\n* [ターミナルでのディレクトリ移動を保存、取り出しする](http://rcmdnk.github.io/blog/2013/12/27/computer-bash-zsh-sd-cl/)\n* [ターミナルでのディレクトリ移動](https://rcmdnk.com/blog/2013/04/10/computer-bash/)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frcmdnk%2Fsd_cl","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frcmdnk%2Fsd_cl","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frcmdnk%2Fsd_cl/lists"}