diff --git a/README.md b/README.md index d5a7555..d81d809 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/example_configs/zsh.conf b/example_configs/zsh.conf index 2a5e567..a665308 100644 --- a/example_configs/zsh.conf +++ b/example_configs/zsh.conf @@ -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]% diff --git a/prompt b/prompt index 87e69bb..d5cd24d 100644 --- a/prompt +++ b/prompt @@ -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 +