diff options
author | Tom Ryder <tom@sanctum.geek.nz> | 2013-08-26 15:09:22 +1200 |
---|---|---|
committer | Tom Ryder <tom@sanctum.geek.nz> | 2013-08-26 15:09:22 +1200 |
commit | e4ad3ed3e2fa5b0c0e59cabf8662781d1b47a5b3 (patch) | |
tree | ee11f01d2714b593da97738eb0e2ce7726182162 | |
parent | Use single quotes for printf (diff) | |
download | dotfiles-e4ad3ed3e2fa5b0c0e59cabf8662781d1b47a5b3.tar.gz dotfiles-e4ad3ed3e2fa5b0c0e59cabf8662781d1b47a5b3.zip |
Rearrange prompt to put last return status last
-rw-r--r-- | README.markdown | 4 | ||||
-rw-r--r-- | bash/bashrc.d/prompt.bash | 8 |
2 files changed, 6 insertions, 6 deletions
diff --git a/README.markdown b/README.markdown index c3e32d67..1a3dc016 100644 --- a/README.markdown +++ b/README.markdown @@ -83,14 +83,14 @@ My prompt generally looks like this, colored bright green: It expands based on context to include these elements in this order: -* The exit status of the last command, if it was non-zero * Whether in a Git, Mercurial, or Subversion repository, and punctuation to show whether there are local modifications at a glance * The number of running background jobs +* The exit status of the last command, if non-zero With all of the above (a rare situation), it might look something like this: - [user@hostname:~/gitrepo]<127>(git:master?){1}$ + [user@hostname:~/gitrepo](git:master?){1}<127>$ This is all managed within the `prompt` function. Some of the Git stuff was adapted from @necolas' [superb dotfiles][19]. diff --git a/bash/bashrc.d/prompt.bash b/bash/bashrc.d/prompt.bash index 6d273185..a3baaa3b 100644 --- a/bash/bashrc.d/prompt.bash +++ b/bash/bashrc.d/prompt.bash @@ -2,17 +2,17 @@ prompt() { # Variables for use only within this function - local -i ret=$? colors=$(tput colors) - local -a state=() local color reset branch info url root + local -i colors=$(tput colors) + local -a state=() # What's done next depends on the first argument to the function case $1 in # Turn complex, colored prompt on on) - PROMPT_COMMAND='history -a' - PS1='\[\a\][\u@\h:\w]$(prompt ret)$(prompt vcs)$(prompt job)\$' + PROMPT_COMMAND='ret=$? ; history -a' + PS1='\[\a\][\u@\h:\w]$(prompt vcs)$(prompt job)$(prompt ret)\$' # Check if we have non-bold bright green available if ((colors > 8)); then |