Merge branch 'master' into ordered_args
This commit is contained in:
commit
a830cc1cd4
3 files changed
+14
-2
No files matched your search
@@ -61,6 +61,7 @@ NOTES
|
||||
Set $_Z_NO_PROMPT_COMMAND to handle PROMPT_COMMAND/precmd your-
|
||||
self.
|
||||
Set $_Z_EXCLUDE_DIRS to an array of directories to exclude.
|
||||
Set $_Z_OWNER to allow usage when in 'sudo -s' mode.
|
||||
(These settings should go in .bashrc/.zshrc before the line
|
||||
added above.)
|
||||
Install the provided man page z.1 somewhere like
|
||||
@@ -123,6 +124,9 @@ ENVIRONMENT
|
||||
directories to exclude from tracking. $HOME is always excluded. Direc-
|
||||
tories must be full paths without trailing slashes.
|
||||
|
||||
The environment variable $_Z_OWNER can be set to your username, to
|
||||
allow usage of z when your sudo enviroment keeps $HOME set.
|
||||
|
||||
FILES
|
||||
Data is stored in $HOME/.z. This can be overridden by setting the
|
||||
$_Z_DATA environment variable. When initialized, z will raise an error
|
||||
|
||||
@@ -84,6 +84,9 @@ Set \fB$_Z_NO_PROMPT_COMMAND\fR to handle \fBPROMPT_COMMAND/precmd\fR yourself.
|
||||
Set \fB$_Z_EXCLUDE_DIRS\fR to an array of directories to exclude.
|
||||
.RE
|
||||
.RS
|
||||
Set \fB$_Z_OWNER\fR to allow usage when in 'sudo -s' mode.
|
||||
.RE
|
||||
.RS
|
||||
(These settings should go in .bashrc/.zshrc before the line added above.)
|
||||
.RE
|
||||
.RS
|
||||
@@ -146,6 +149,9 @@ handle \fBPROMPT_COMMAND\fR or \fBprecmd\fR yourself.
|
||||
The environment variable \fB$_Z_EXCLUDE_DIRS\fR can be set to an array of
|
||||
directories to exclude from tracking. \fB$HOME\fR is always excluded.
|
||||
Directories must be full paths without trailing slashes.
|
||||
.P
|
||||
The environment variable \fB$_Z_OWNER\fR can be set to your username, to
|
||||
allow usage of \fBz\fR when your sudo enviroment keeps \fB$HOME\fR set.
|
||||
.SH
|
||||
FILES
|
||||
Data is stored in \fB$HOME/.z\fR. This can be overridden by setting the
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
# set $_Z_NO_RESOLVE_SYMLINKS to prevent symlink resolution.
|
||||
# set $_Z_NO_PROMPT_COMMAND if you're handling PROMPT_COMMAND yourself.
|
||||
# set $_Z_EXCLUDE_DIRS to an array of directories to exclude.
|
||||
# set $_Z_OWNER to your username if you want use z while sudo with $HOME kept
|
||||
#
|
||||
# USE:
|
||||
# * z foo # cd to most frecent dir matching foo
|
||||
@@ -30,8 +31,8 @@ _z() {
|
||||
|
||||
local datafile="${_Z_DATA:-$HOME/.z}"
|
||||
|
||||
# bail if we don't own ~/.z (we're another user but our ENV is still set)
|
||||
[ -f "$datafile" -a ! -O "$datafile" ] && return
|
||||
# bail if we don't own ~/.z and $_Z_OWNER not set
|
||||
[ -z "$_Z_OWNER" -a -f "$datafile" -a ! -O "$datafile" ] && return
|
||||
|
||||
# add entries
|
||||
if [ "$1" = "--add" ]; then
|
||||
@@ -78,6 +79,7 @@ _z() {
|
||||
if [ $? -ne 0 -a -f "$datafile" ]; then
|
||||
env rm -f "$tempfile"
|
||||
else
|
||||
[ -n "$_Z_OWNER" ] && chown $_Z_OWNER:$(id -ng $_Z_OWNER) "$tempfile"
|
||||
env mv -f "$tempfile" "$datafile" || env rm -f "$tempfile"
|
||||
fi
|
||||
|
||||
|
||||
Reference in new issue
Block a user