1 # scd - smart change of directory
3 Define `scd` shell function for changing to any directory with
6 `scd` keeps history of the visited directories, which serves as an index of
7 the known paths. The directory index is updated after every `cd` command in
8 the shell and can be also filled manually by running `scd -a`. To switch to
9 some directory, `scd` needs few fragments of the desired path to match with
10 the index. A selection menu is displayed in case of several matches, with a
11 preference given to recently visited paths. `scd` can create permanent
12 directory aliases, which appear as named directories in zsh session.
16 Besides oh-my-zsh, `scd` can be used with *bash*, *dash* or *tcsh*
17 shells and is also available as Vim plugin
18 [scd.vim](https://github.com/pavoljuhas/scd.vim) and
19 [IPython](https://ipython.org) extension. For installation details, see
20 https://github.com/pavoljuhas/smart-change-directory.
25 scd [options] [pattern1 pattern2 ...]
30 Patterns may use all zsh [glob operators](
31 http://zsh.sourceforge.net/Doc/Release/Expansion.html#Glob-Operators)
32 available with *extendedglob* option. Specified patterns must match
33 the absolute path and at least one of them must match in the tail.
34 Several special patterns are also recognized as follows:
38 PAT must match at the beginning of the path, for example, "^/home"</dd><dt>
40 require PAT to match the end of the path, "man$"</dd><dt>
42 match only subdirectories of the current directory</dd><dt>
44 require PAT to match over the tail component, ":doc", ":re/doc"</dd>
52 add current or specified directories to the directory index.</dd><dt>
55 remove current or specified directories from the index.</dd><dt>
57 -r, --recursive</dt><dd>
58 apply options <em>--add</em> or <em>--unindex</em> recursively.</dd><dt>
60 --alias=ALIAS</dt><dd>
61 create alias for the current or specified directory and save it to
62 <em>~/.scdalias.zsh</em>.</dd><dt>
65 remove ALIAS definition for the current or specified directory from
66 <em>~/.scdalias.zsh</em>. Use "OLD" to purge aliases to non-existent
70 display all directories even those excluded by patterns in
71 <em>~/.scdignore</em>. Disregard the unique matching for a
72 directory alias and filtering of less likely paths.</dd><dt>
75 use "pushd" to change to the target directory.</dd><dt>
78 show matching directories and exit.</dd><dt>
80 -v, --verbose</dt><dd>
81 display directory rank in the selection menu.</dd><dt>
84 display this options summary and exit.</dd>
91 # Index recursively some paths for the very first run
94 # Change to a directory path matching "doc"
97 # Change to a path matching all of "a", "b" and "c"
100 # Change to a directory path that ends with "ts"
103 # Show selection menu and ranking of 20 most likely directories
106 # Alias current directory as "xray"
109 # Jump to a previously defined aliased directory
116 ~/.scdhistory</dt><dd>
117 time-stamped index of visited directories.</dd><dt>
119 ~/.scdalias.zsh</dt><dd>
120 scd-generated definitions of directory aliases.</dd><dt>
122 ~/.scdignore</dt><dd>
123 <a href="http://zsh.sourceforge.net/Doc/Release/Expansion.html#Glob-Operators">
124 glob patterns</a> for paths to be ignored in the scd search, for example,
125 <code>/mnt/backup/*</code>. The patterns are specified one per line
126 and are matched assuming the <em>extendedglob</em> zsh option. Lines
127 starting with "#" are skipped as comments. The .scdignore patterns
128 are not applied in the <em>--all</em> mode.</dd>
135 SCD_HISTFILE</dt><dd>
136 path to the scd index file (by default ~/.scdhistory).</dd><dt>
138 SCD_HISTSIZE</dt><dd>
139 maximum number of entries in the index (5000). Index is trimmed when it
140 exceeds <em>SCD_HISTSIZE</em> by more than 20%.</dd><dt>
142 SCD_MENUSIZE</dt><dd>
143 maximum number of items for directory selection menu (20).</dd><dt>
145 SCD_MEANLIFE</dt><dd>
146 mean lifetime in seconds for exponential decay of directory
147 likelihood (86400).</dd><dt>
149 SCD_THRESHOLD</dt><dd>
150 threshold for cumulative directory likelihood. Directories with
151 a lower likelihood compared to the best match are excluded (0.005).
155 command script file where scd writes the final <code>cd</code>
156 command. This variable must be defined when scd runs in its own
157 process rather than as a shell function. It is up to the
158 scd caller to use the output in <em>SCD_SCRIPT</em>.</dd>