README 5.2 KB

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