diff --git a/README b/README index e4fc948..56fbfc3 100644 --- a/README +++ b/README @@ -1,4 +1,4 @@ -Z(1) User Commands Z(1) +Z(1) User Commands Z(1) @@ -17,8 +17,8 @@ AVAILABILITY DESCRIPTION Tracks your most used directories, based on 'frecency'. - After a short learning phase, z will take you to the most 'frecent' - directory that matches ALL of the regexes given on the command line. + After a short learning phase, z will take you to the most 'frecent' direc‐ + tory that matches ALL of the regexes given on the command line. OPTIONS @@ -29,39 +29,49 @@ OPTIONS EXAMPLES - z foo cd to most frecent dir matching foo + z foo cd to most frecent dir matching foo z foo bar cd to most frecent dir matching foo and bar - z -r foo cd to highest ranked dir matching foo - z -t foo cd to most recently accessed dir matching foo - z -l foo list all dirs matching foo (by frecency) + z -r foo cd to highest ranked dir matching foo + z -t foo cd to most recently accessed dir matching foo + z -l foo list all dirs matching foo (by frecency) NOTES Installation: + optionally: + set $_Z_CMD in .bashrc/.zshrc to change the command (default z). + put something like this in your $HOME/.bashrc: - . /path/to/z.sh + . /path/to/z.sh put something like this in your $HOME/.zshrc: - . /path/to/z.sh - function precmd () { - z --add "$(pwd -P)" - } + . /path/to/z.sh + function precmd () { + _z --add "$(pwd -P)" + } cd around for a while to build up the db. + PROFIT!! Frecency: - Frecency is a portmantaeu of 'recent' and 'frequency'. It is a weighted - rank that depends on 'how often' and 'how recently' something occured. - As far as I know, Mozilla came up with the term. + Frecency is a portmantaeu of 'recent' and 'frequency'. It is a weighted + rank that depends on how often and how recently something occured. As far + as I know, Mozilla came up with the term. - In z, a directory that has low ranking but has been accessed recently - will quickly have higher rank than a directory accessed frequently a - long time ago. + In z, a directory that has low ranking but has been accessed recently will + quickly have higher rank than a directory accessed frequently a long time + ago. + + +ENVIRONMENT + A function _z() is defined. + + An alias $_Z_CMD='_z 2>&1' is defined. If not set, $_Z_CMD defaults to z. FILES @@ -75,4 +85,4 @@ SEE ALSO -z February 2011 Z(1) +z February 2011 Z(1) diff --git a/z.1 b/z.1 index c774f70..ca85648 100644 --- a/z.1 +++ b/z.1 @@ -39,30 +39,41 @@ directory that matches ALL of the regexes given on the command line. \fBInstallation:\fR .P -put something like this in your $HOME/.bashrc: +optionally: + set \fB$_Z_CMD\fR in .bashrc/.zshrc to change the command (default \fBz\fR). .P - . /path/to/z.sh +put something like this in your \fB$HOME/.bashrc\fR: .P -put something like this in your $HOME/.zshrc: + \fB. /path/to/z.sh\fR .P - . /path/to/z.sh +put something like this in your \fB$HOME/.zshrc\fR: +.P + \fB. /path/to/z.sh function precmd () { - z --add "$(pwd -P)" - } + _z --add "$(pwd -P)" + }\fR +.P +\fBcd\fR around for a while to build up the db. .P -cd around for a while to build up the db. -.br PROFIT!! +.br \fBFrecency:\fR .P Frecency is a portmantaeu of 'recent' and 'frequency'. It is a weighted rank -that depends on 'how often' and 'how recently' something occured. As far as I +that depends on how often and how recently something occured. As far as I know, Mozilla came up with the term. .P In \fBz\fR, a directory that has low ranking but has been accessed recently will quickly have higher rank than a directory accessed frequently a long time ago. +.br + +.SH ENVIRONMENT +A function \fB_z()\fR is defined. +.P +An alias \fB$_Z_CMD\fR='_z 2>&1' is defined. If not set, \fB$_Z_CMD\fR defaults +to \fBz\fR. .SH FILES data is stored in \fB$HOME/.z\fR diff --git a/z.sh b/z.sh index 6bcc4cf..9d4dc2b 100755 --- a/z.sh +++ b/z.sh @@ -3,12 +3,14 @@ # maintains a jump-list of the directories you actually use # # INSTALL: +# * optionally: +# set $_Z_CMD in .bashrc/.zshrc to change the command (default z). # * put something like this in your .bashrc: # . /path/to/z.sh # * put something like this in your .zshrc: # . /path/to/z.sh # function precmd () { -# z --add "$(pwd -P)" +# _z --add "$(pwd -P)" # } # * cd around for a while to build up the db # * PROFIT!! @@ -20,7 +22,7 @@ # * z -t foo # cd to most recently accessed dir matching foo # * z -l foo # list all dirs matching foo (by frecency) -z() { +_z() { local datafile="$HOME/.z" @@ -166,18 +168,20 @@ z() { fi } +alias ${_Z_CMD:-z}='_z 2>&1' + if complete &> /dev/null; then # bash tab completion - complete -C 'z --complete "$COMP_LINE"' z + complete -C '_z --complete "$COMP_LINE"' ${_Z_CMD:-z} # populate directory list. avoid clobbering other PROMPT_COMMANDs. - echo $PROMPT_COMMAND | grep -q "z --add" - [ $? -gt 0 ] && PROMPT_COMMAND='z --add "$(pwd -P 2>/dev/null)" 2>/dev/null;'"$PROMPT_COMMAND" + echo $PROMPT_COMMAND | grep -q "_z --add" + [ $? -gt 0 ] && PROMPT_COMMAND='_z --add "$(pwd -P 2>/dev/null)" 2>/dev/null;'"$PROMPT_COMMAND" elif compctl &> /dev/null; then # zsh tab completion _z_zsh_tab_completion() { local compl read -l compl - reply=(${(f)"$(z --complete "$compl")"}) + reply=(${(f)"$(_z --complete "$compl")"}) } - compctl -U -K _z_zsh_tab_completion z + compctl -U -K _z_zsh_tab_completion ${_Z_CMD:-z} fi