Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

respect _Z_NO_PROMPT_COMMAND environment variable

For those who wish to set their PROMPT_COMMAND manually. Closes #44.
  • Loading branch information...
commit 8272e6ff7fe1da5d6e912f95e7f1db9d65048d35 1 parent 30cbc62
@rupa authored
Showing with 18 additions and 5 deletions.
  1. +5 −1 README
  2. +6 −1 z.1
  3. +7 −3 z.sh
View
6 README
@@ -43,6 +43,7 @@ NOTES
Set $_Z_CMD in .bashrc/.zshrc to change the command (default z).
Set $_Z_DATA to change the datafile (default $HOME/.z).
Set $_Z_NO_RESOLVE_SYMLINKS to prevent symlink resolution.
+ Set $_Z_NO_PROMPT_COMMAND if you're handling PROMPT_COMMAND yourself.
(These settings should go before the lines below.)
Put something like this in your $HOME/.bashrc:
@@ -122,9 +123,12 @@ ENVIRONMENT
to any existing PROMPT_COMMAND. zsh users need to manually set precmd()
as described in the installation instructions.
+ The environment variable $_Z_NO_PROMPT_COMMAND can be set if you want
+ to handle PROMPT_COMMAND yourself.
+
FILES
- Data is stored in $HOME/.z. This can be overridden by setting the
+ Data is stored in $HOME/.z. This can be overridden by setting the
$_Z_DATA environment variable.
A man page (z.1) is provided.
View
7 z.1
@@ -46,6 +46,8 @@ Optionally:
.br
Set \fB$_Z_NO_RESOLVE_SYMLINKS\fR to prevent symlink resolution.
.br
+ Set \fB$_Z_NO_PROMPT_COMMAND\fR if you're handling \fBPROMPT_COMMAND\fR yourself.
+.br
(These settings should go before the lines below.)
.P
Put something like this in your \fB$HOME/.bashrc\fR:
@@ -126,8 +128,11 @@ its database. Specifically it prepends:
.P
\fB_z --add "$(pwd -P 2>/dev/null)" 2>/dev/null;\fR
.P
-to any existing \fbPROMPT_COMMAND\fR. zsh users need to manually set
+to any existing \fBPROMPT_COMMAND\fR. zsh users need to manually set
\fBprecmd()\fR as described in the installation instructions.
+.P
+The environment variable \fB$_Z_NO_PROMPT_COMMAND\fR can be set if you want to
+handle \fRPROMPT_COMMAND\fR yourself.
.SH FILES
Data is stored in \fB$HOME/.z\fR. This can be overridden by setting the
View
10 z.sh
@@ -6,6 +6,8 @@
# * optionally:
# set $_Z_CMD in .bashrc/.zshrc to change the command (default z).
# set $_Z_DATA in .bashrc/.zshrc to change the datafile (default ~/.z).
+# set $_Z_NO_RESOLVE_SYMLINKS to prevent symlink resolution.
+# set $_Z_NO_PROMPT_COMMAND if you're handling PROMPT_COMMAND yourself.
# * put something like this in your .bashrc:
# . /path/to/z.sh
# * put something like this in your .zshrc:
@@ -184,9 +186,11 @@ alias ${_Z_CMD:-z}='_z 2>&1'
if complete &> /dev/null; then
# bash tab completion
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 '$_Z_RESOLVE_SYMLINKS' 2>/dev/null)" 2>/dev/null;'"$PROMPT_COMMAND"
+ [ "$_Z_NO_PROMPT_COMMAND" ] || {
+ # populate directory list. avoid clobbering other PROMPT_COMMANDs.
+ echo $PROMPT_COMMAND | grep -q "_z --add"
+ [ $? -gt 0 ] && PROMPT_COMMAND='_z --add "$(pwd '$_Z_RESOLVE_SYMLINKS' 2>/dev/null)" 2>/dev/null;'"$PROMPT_COMMAND"
+ }
elif compctl &> /dev/null; then
# zsh tab completion
_z_zsh_tab_completion() {
Please sign in to comment.
Something went wrong with that request. Please try again.