README 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  1. Z(1) User Commands Z(1)
  2. NAME
  3. z - jump around
  4. SYNOPSIS
  5. z [-chlrtx] [regex1 regex2 ... regexn]
  6. AVAILABILITY
  7. bash, zsh
  8. DESCRIPTION
  9. Tracks your most used directories, based on 'frecency'.
  10. After a short learning phase, z will take you to the most 'frecent'
  11. directory that matches ALL of the regexes given on the command line, in
  12. order.
  13. For example, z foo bar would match /foo/bar but not /bar/foo.
  14. OPTIONS
  15. -c restrict matches to subdirectories of the current directory
  16. -e echo the best match, don't cd
  17. -h show a brief help message
  18. -l list only
  19. -r match by rank only
  20. -t match by recent access only
  21. -x remove the current directory from the datafile
  22. EXAMPLES
  23. z foo cd to most frecent dir matching foo
  24. z foo bar cd to most frecent dir matching foo, then bar
  25. z -r foo cd to highest ranked dir matching foo
  26. z -t foo cd to most recently accessed dir matching foo
  27. z -l foo list all dirs matching foo (by frecency)
  28. NOTES
  29. Installation:
  30. Put something like this in your $HOME/.bashrc or $HOME/.zshrc:
  31. . /path/to/z.sh
  32. cd around for a while to build up the db.
  33. PROFIT!!
  34. Optionally:
  35. Set $_Z_CMD to change the command name (default z).
  36. Set $_Z_DATA to change the datafile (default $HOME/.z).
  37. Set $_Z_MAX_SCORE lower to age entries out faster (default
  38. 9000).
  39. Set $_Z_NO_RESOLVE_SYMLINKS to prevent symlink resolution.
  40. Set $_Z_NO_PROMPT_COMMAND to handle PROMPT_COMMAND/precmd your-
  41. self.
  42. Set $_Z_EXCLUDE_DIRS to an array of directory trees to exclude.
  43. Set $_Z_OWNER to allow usage when in 'sudo -s' mode.
  44. (These settings should go in .bashrc/.zshrc before the line
  45. added above.)
  46. Install the provided man page z.1 somewhere in your MANPATH,
  47. like /usr/local/man/man1.
  48. Aging:
  49. The rank of directories maintained by z undergoes aging based on a sim-
  50. ple formula. The rank of each entry is incremented every time it is
  51. accessed. When the sum of ranks is over 9000, all ranks are multiplied
  52. by 0.99. Entries with a rank lower than 1 are forgotten.
  53. Frecency:
  54. Frecency is a portmanteau of 'recent' and 'frequency'. It is a weighted
  55. rank that depends on how often and how recently something occurred. As
  56. far as I know, Mozilla came up with the term.
  57. To z, a directory that has low ranking but has been accessed recently
  58. will quickly have higher rank than a directory accessed frequently a
  59. long time ago.
  60. Frecency is determined at runtime.
  61. Common:
  62. When multiple directories match all queries, and they all have a common
  63. prefix, z will cd to the shortest matching directory, without regard to
  64. priority. This has been in effect, if undocumented, for quite some
  65. time, but should probably be configurable or reconsidered.
  66. Tab Completion:
  67. z supports tab completion. After any number of arguments, press TAB to
  68. complete on directories that match each argument. Due to limitations of
  69. the completion implementations, only the last argument will be com-
  70. pleted in the shell.
  71. Internally, z decides you've requested a completion if the last argu-
  72. ment passed is an absolute path to an existing directory. This may
  73. cause unexpected behavior if the last argument to z begins with /.
  74. ENVIRONMENT
  75. A function _z() is defined.
  76. The contents of the variable $_Z_CMD is aliased to _z 2>&1. If not set,
  77. $_Z_CMD defaults to z.
  78. The environment variable $_Z_DATA can be used to control the datafile
  79. location. If it is not defined, the location defaults to $HOME/.z.
  80. The environment variable $_Z_NO_RESOLVE_SYMLINKS can be set to prevent
  81. resolving of symlinks. If it is not set, symbolic links will be
  82. resolved when added to the datafile.
  83. In bash, z appends a command to the PROMPT_COMMAND environment variable
  84. to maintain its database. In zsh, z appends a function _z_precmd to the
  85. precmd_functions array.
  86. The environment variable $_Z_NO_PROMPT_COMMAND can be set if you want
  87. to handle PROMPT_COMMAND or precmd yourself.
  88. The environment variable $_Z_EXCLUDE_DIRS can be set to an array of
  89. directory trees to exclude from tracking. $HOME is always excluded.
  90. Directories must be full paths without trailing slashes.
  91. The environment variable $_Z_OWNER can be set to your username, to
  92. allow usage of z when your sudo environment keeps $HOME set.
  93. FILES
  94. Data is stored in $HOME/.z. This can be overridden by setting the
  95. $_Z_DATA environment variable. When initialized, z will raise an error
  96. if this path is a directory, and not function correctly.
  97. A man page (z.1) is provided.
  98. SEE ALSO
  99. regex(7), pushd, popd, autojump, cdargs
  100. Please file bugs at https://github.com/rupa/z/
  101. z January 2013 Z(1)