rename z() to _z(), aliased to z. update manpage and readme.
Alias allows cmd to be overriden, and makes it so z prints to STDOUT as expected. Not well tested on zsh.
This commit is contained in:
1 parent
f24af5c4a0
commit
84ace8e8a9
3 files changed
+60
-35
No files matched your search
@@ -1,4 +1,4 @@
|
|||||||
Z(1) User Commands Z(1)
|
Z(1) User Commands Z(1)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -17,8 +17,8 @@ AVAILABILITY
|
|||||||
DESCRIPTION
|
DESCRIPTION
|
||||||
Tracks your most used directories, based on 'frecency'.
|
Tracks your most used directories, based on 'frecency'.
|
||||||
|
|
||||||
After a short learning phase, z will take you to the most 'frecent'
|
After a short learning phase, z will take you to the most 'frecent' direc‐
|
||||||
directory that matches ALL of the regexes given on the command line.
|
tory that matches ALL of the regexes given on the command line.
|
||||||
|
|
||||||
|
|
||||||
OPTIONS
|
OPTIONS
|
||||||
@@ -29,39 +29,49 @@ OPTIONS
|
|||||||
|
|
||||||
|
|
||||||
EXAMPLES
|
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 foo bar cd to most frecent dir matching foo and bar
|
||||||
z -r foo cd to highest ranked dir matching foo
|
z -r foo cd to highest ranked dir matching foo
|
||||||
z -t foo cd to most recently accessed 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 -l foo list all dirs matching foo (by frecency)
|
||||||
|
|
||||||
|
|
||||||
NOTES
|
NOTES
|
||||||
Installation:
|
Installation:
|
||||||
|
|
||||||
|
optionally:
|
||||||
|
set $_Z_CMD in .bashrc/.zshrc to change the command (default z).
|
||||||
|
|
||||||
put something like this in your $HOME/.bashrc:
|
put something like this in your $HOME/.bashrc:
|
||||||
|
|
||||||
. /path/to/z.sh
|
. /path/to/z.sh
|
||||||
|
|
||||||
put something like this in your $HOME/.zshrc:
|
put something like this in your $HOME/.zshrc:
|
||||||
|
|
||||||
. /path/to/z.sh
|
. /path/to/z.sh
|
||||||
function precmd () {
|
function precmd () {
|
||||||
z --add "$(pwd -P)"
|
_z --add "$(pwd -P)"
|
||||||
}
|
}
|
||||||
|
|
||||||
cd around for a while to build up the db.
|
cd around for a while to build up the db.
|
||||||
|
|
||||||
PROFIT!!
|
PROFIT!!
|
||||||
|
|
||||||
Frecency:
|
Frecency:
|
||||||
|
|
||||||
Frecency is a portmantaeu of 'recent' and 'frequency'. It is a weighted
|
Frecency is a portmantaeu of 'recent' and 'frequency'. It is a weighted
|
||||||
rank that depends on 'how often' and 'how recently' something occured.
|
rank that depends on how often and how recently something occured. As far
|
||||||
As far as I know, Mozilla came up with the term.
|
as I know, Mozilla came up with the term.
|
||||||
|
|
||||||
In z, a directory that has low ranking but has been accessed recently
|
In z, a directory that has low ranking but has been accessed recently will
|
||||||
will quickly have higher rank than a directory accessed frequently a
|
quickly have higher rank than a directory accessed frequently a long time
|
||||||
long time ago.
|
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
|
FILES
|
||||||
@@ -75,4 +85,4 @@ SEE ALSO
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
z February 2011 Z(1)
|
z February 2011 Z(1)
|
||||||
@@ -39,30 +39,41 @@ directory that matches ALL of the regexes given on the command line.
|
|||||||
|
|
||||||
\fBInstallation:\fR
|
\fBInstallation:\fR
|
||||||
.P
|
.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
|
.P
|
||||||
. /path/to/z.sh
|
put something like this in your \fB$HOME/.bashrc\fR:
|
||||||
.P
|
.P
|
||||||
put something like this in your $HOME/.zshrc:
|
\fB. /path/to/z.sh\fR
|
||||||
.P
|
.P
|
||||||
. /path/to/z.sh
|
put something like this in your \fB$HOME/.zshrc\fR:
|
||||||
|
.P
|
||||||
|
\fB. /path/to/z.sh
|
||||||
function precmd () {
|
function precmd () {
|
||||||
z --add "$(pwd -P)"
|
_z --add "$(pwd -P)"
|
||||||
}
|
}\fR
|
||||||
|
.P
|
||||||
|
\fBcd\fR around for a while to build up the db.
|
||||||
.P
|
.P
|
||||||
cd around for a while to build up the db.
|
|
||||||
.br
|
|
||||||
PROFIT!!
|
PROFIT!!
|
||||||
|
.br
|
||||||
|
|
||||||
\fBFrecency:\fR
|
\fBFrecency:\fR
|
||||||
.P
|
.P
|
||||||
Frecency is a portmantaeu of 'recent' and 'frequency'. It is a weighted rank
|
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.
|
know, Mozilla came up with the term.
|
||||||
.P
|
.P
|
||||||
In \fBz\fR, a directory that has low ranking but has been accessed recently
|
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
|
will quickly have higher rank than a directory accessed frequently a long time
|
||||||
ago.
|
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
|
.SH FILES
|
||||||
data is stored in \fB$HOME/.z\fR
|
data is stored in \fB$HOME/.z\fR
|
||||||
|
|||||||
@@ -3,12 +3,14 @@
|
|||||||
# maintains a jump-list of the directories you actually use
|
# maintains a jump-list of the directories you actually use
|
||||||
#
|
#
|
||||||
# INSTALL:
|
# INSTALL:
|
||||||
|
# * optionally:
|
||||||
|
# set $_Z_CMD in .bashrc/.zshrc to change the command (default z).
|
||||||
# * put something like this in your .bashrc:
|
# * put something like this in your .bashrc:
|
||||||
# . /path/to/z.sh
|
# . /path/to/z.sh
|
||||||
# * put something like this in your .zshrc:
|
# * put something like this in your .zshrc:
|
||||||
# . /path/to/z.sh
|
# . /path/to/z.sh
|
||||||
# function precmd () {
|
# function precmd () {
|
||||||
# z --add "$(pwd -P)"
|
# _z --add "$(pwd -P)"
|
||||||
# }
|
# }
|
||||||
# * cd around for a while to build up the db
|
# * cd around for a while to build up the db
|
||||||
# * PROFIT!!
|
# * PROFIT!!
|
||||||
@@ -20,7 +22,7 @@
|
|||||||
# * z -t foo # cd to most recently accessed 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 -l foo # list all dirs matching foo (by frecency)
|
||||||
|
|
||||||
z() {
|
_z() {
|
||||||
|
|
||||||
local datafile="$HOME/.z"
|
local datafile="$HOME/.z"
|
||||||
|
|
||||||
@@ -166,18 +168,20 @@ z() {
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
alias ${_Z_CMD:-z}='_z 2>&1'
|
||||||
|
|
||||||
if complete &> /dev/null; then
|
if complete &> /dev/null; then
|
||||||
# bash tab completion
|
# 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.
|
# populate directory list. avoid clobbering other PROMPT_COMMANDs.
|
||||||
echo $PROMPT_COMMAND | grep -q "z --add"
|
echo $PROMPT_COMMAND | grep -q "_z --add"
|
||||||
[ $? -gt 0 ] && PROMPT_COMMAND='z --add "$(pwd -P 2>/dev/null)" 2>/dev/null;'"$PROMPT_COMMAND"
|
[ $? -gt 0 ] && PROMPT_COMMAND='_z --add "$(pwd -P 2>/dev/null)" 2>/dev/null;'"$PROMPT_COMMAND"
|
||||||
elif compctl &> /dev/null; then
|
elif compctl &> /dev/null; then
|
||||||
# zsh tab completion
|
# zsh tab completion
|
||||||
_z_zsh_tab_completion() {
|
_z_zsh_tab_completion() {
|
||||||
local compl
|
local compl
|
||||||
read -l 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
|
fi
|
||||||
Reference in new issue
Block a user