Added optional feature to show non-zero exit codes in prompt

macos_completion
Aaron Johnson 6 years ago
parent b68c002b1a
commit 8242450d12

@ -45,6 +45,18 @@ If you just name a path, the shell will assume you intended to change directorie
ajohnson@helios:~ % git/zsh
ajohnson@helios:~/git/zsh [add_readme]%
```
#### SHOW_NZ_EXIT
This option will display exit codes of the previous command at the beginning of your prompt, but only when the exit code is non-zero. If the previous command returns 0, then your prompt will not show any exit code.
```
ajohnson@helios:~ %
ajohnson@helios:~ % true
ajohnson@helios:~ % false
1:ajohnson@helios:~ %
1:ajohnson@helios:~ % true
ajohnson@helios:~ %
ajohnson@helios:~ % zsh -c "exit 42"
42:ajohnson@helios:~ %
```
#### cd Search and Replace
You can substitute one word for another in your current working directory by using the cd syntax:
```
@ -64,7 +76,6 @@ ajohnson@helios:~/git/heatbot [rewrite]% git checkout dev
Switched to branch 'dev'
Your branch is up to date with 'origin/dev'.
ajohnson@helios:~/git/heatbot [dev]%
```
## Epilogue

@ -8,6 +8,7 @@ HISTORY_NO_DUPS=true #Ignore duplicate back-to-back commands in shell history
# Prompt Style
PROMPT_STYLE=bsd2 #Valid options: bsd, bsd2, ar5
COMPLETION_STYLE=bash #ZSH "automenu" option toggle - Valid options: bash, zsh (defaults to bash)
SHOW_NZ_EXIT=true #When true, prints non-zero exit codes into prompt (zero exit codes are not shown)
# Example prompts:
# bsd: user@host:~/storage/git[git-branch]%

@ -36,3 +36,9 @@ fi
### UNUSED ### New style with primary-coloured %/#
#PROMPT="%B%{$fg[$COLOR_USER]%}%n@%m%b%{$reset_color%}:%{$fg[$COLOR_PWD]%}%~%{$fg[$COLOR_VCS]%}%B\$vcs_info_msg_0_%b%{$fg[$COLOR_PWD]%}%B%{$fg[$COLOR]%}%# %{$reset_color%}"
# Print previous exit code only if exit code was non-zero
if [ "$SHOW_NZ_EXIT" = "true" ]
then
PROMPT="%(?..%?:)${PROMPT}"
fi

Loading…
Cancel
Save