my xfce4 dotfiles
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

159 lines
4.8 KiB

3 years ago
  1. # scd - smart change of directory
  2. Define `scd` shell function for changing to any directory with
  3. a few keystrokes.
  4. `scd` keeps history of the visited directories, which serves as an index of
  5. the known paths. The directory index is updated after every `cd` command in
  6. the shell and can be also filled manually by running `scd -a`. To switch to
  7. some directory, `scd` needs few fragments of the desired path to match with
  8. the index. A selection menu is displayed in case of several matches, with a
  9. preference given to recently visited paths. `scd` can create permanent
  10. directory aliases, which appear as named directories in zsh session.
  11. ## INSTALLATION NOTES
  12. Besides oh-my-zsh, `scd` can be used with *bash*, *dash* or *tcsh*
  13. shells and is also available as Vim plugin
  14. [scd.vim](https://github.com/pavoljuhas/scd.vim) and
  15. [IPython](https://ipython.org) extension. For installation details, see
  16. https://github.com/pavoljuhas/smart-change-directory.
  17. ## SYNOPSIS
  18. ```sh
  19. scd [options] [pattern1 pattern2 ...]
  20. ```
  21. ## PATTERNS
  22. Patterns may use all zsh [glob operators](
  23. http://zsh.sourceforge.net/Doc/Release/Expansion.html#Glob-Operators)
  24. available with *extendedglob* option. Specified patterns must match
  25. the absolute path and at least one of them must match in the tail.
  26. Several special patterns are also recognized as follows:
  27. <dl><dt>
  28. ^PAT</dt><dd>
  29. PAT must match at the beginning of the path, for example, "^/home"</dd><dt>
  30. PAT$</dt><dd>
  31. require PAT to match the end of the path, "man$"</dd><dt>
  32. ./</dt><dd>
  33. match only subdirectories of the current directory</dd><dt>
  34. :PAT</dt><dd>
  35. require PAT to match over the tail component, ":doc", ":re/doc"</dd>
  36. </dl>
  37. ## OPTIONS
  38. <dl><dt>
  39. -a, --add</dt><dd>
  40. add current or specified directories to the directory index.</dd><dt>
  41. --unindex</dt><dd>
  42. remove current or specified directories from the index.</dd><dt>
  43. -r, --recursive</dt><dd>
  44. apply options <em>--add</em> or <em>--unindex</em> recursively.</dd><dt>
  45. --alias=ALIAS</dt><dd>
  46. create alias for the current or specified directory and save it to
  47. <em>~/.scdalias.zsh</em>.</dd><dt>
  48. --unalias</dt><dd>
  49. remove ALIAS definition for the current or specified directory from
  50. <em>~/.scdalias.zsh</em>. Use "OLD" to purge aliases to non-existent
  51. directories.</dd><dt>
  52. -A, --all</dt><dd>
  53. display all directories even those excluded by patterns in
  54. <em>~/.scdignore</em>. Disregard the unique matching for a
  55. directory alias and filtering of less likely paths.</dd><dt>
  56. -p, --push</dt><dd>
  57. use "pushd" to change to the target directory.</dd><dt>
  58. --list</dt><dd>
  59. show matching directories and exit.</dd><dt>
  60. -v, --verbose</dt><dd>
  61. display directory rank in the selection menu.</dd><dt>
  62. -h, --help</dt><dd>
  63. display this options summary and exit.</dd>
  64. </dl>
  65. ## Examples
  66. ```sh
  67. # Index recursively some paths for the very first run
  68. scd -ar ~/Documents/
  69. # Change to a directory path matching "doc"
  70. scd doc
  71. # Change to a path matching all of "a", "b" and "c"
  72. scd a b c
  73. # Change to a directory path that ends with "ts"
  74. scd "ts$"
  75. # Show selection menu and ranking of 20 most likely directories
  76. scd -v
  77. # Alias current directory as "xray"
  78. scd --alias=xray
  79. # Jump to a previously defined aliased directory
  80. scd xray
  81. ```
  82. ## FILES
  83. <dl><dt>
  84. ~/.scdhistory</dt><dd>
  85. time-stamped index of visited directories.</dd><dt>
  86. ~/.scdalias.zsh</dt><dd>
  87. scd-generated definitions of directory aliases.</dd><dt>
  88. ~/.scdignore</dt><dd>
  89. <a href="http://zsh.sourceforge.net/Doc/Release/Expansion.html#Glob-Operators">
  90. glob patterns</a> for paths to be ignored in the scd search, for example,
  91. <code>/mnt/backup/*</code>. The patterns are specified one per line
  92. and are matched assuming the <em>extendedglob</em> zsh option. Lines
  93. starting with "#" are skipped as comments. The .scdignore patterns
  94. are not applied in the <em>--all</em> mode.</dd>
  95. </dl>
  96. ## ENVIRONMENT
  97. <dl><dt>
  98. SCD_HISTFILE</dt><dd>
  99. path to the scd index file (by default ~/.scdhistory).</dd><dt>
  100. SCD_HISTSIZE</dt><dd>
  101. maximum number of entries in the index (5000). Index is trimmed when it
  102. exceeds <em>SCD_HISTSIZE</em> by more than 20%.</dd><dt>
  103. SCD_MENUSIZE</dt><dd>
  104. maximum number of items for directory selection menu (20).</dd><dt>
  105. SCD_MEANLIFE</dt><dd>
  106. mean lifetime in seconds for exponential decay of directory
  107. likelihood (86400).</dd><dt>
  108. SCD_THRESHOLD</dt><dd>
  109. threshold for cumulative directory likelihood. Directories with
  110. a lower likelihood compared to the best match are excluded (0.005).
  111. </dd><dt>
  112. SCD_SCRIPT</dt><dd>
  113. command script file where scd writes the final <code>cd</code>
  114. command. This variable must be defined when scd runs in its own
  115. process rather than as a shell function. It is up to the
  116. scd caller to use the output in <em>SCD_SCRIPT</em>.</dd>
  117. </dl>