]> git.phdru.name Git - dotfiles.git/commitdiff
.bash_prompt: show success/error status of the previous command
authorOleg Broytman <phd@phdru.name>
Wed, 24 Feb 2016 10:38:15 +0000 (13:38 +0300)
committerOleg Broytman <phd@phdru.name>
Wed, 24 Feb 2016 10:38:15 +0000 (13:38 +0300)
Show error code in case of an error.

.bash_prompt

index 6284416032fca32b1292d364d11c7abb459e811d..6126ef25240e8358dbb2ef4f25f09c420072f18c 100644 (file)
@@ -1,7 +1,8 @@
 #!/bin/bash
 
 # bash_prompt; adapted from
-# https://github.com/necolas/dotfiles/blob/master/shell/bash_prompt
+# https://github.com/necolas/dotfiles/blob/master/shell/bash_prompt and
+# http://vitus-wagner.livejournal.com/1176589.html?thread=40146189#t40146189
 
 prompt_git() {
     local s=""
@@ -179,6 +180,7 @@ set_prompts() {
     PS1+="\[$hostStyle\]\h " # host
     #PS1+="\[$charStyle\]: "
     PS1+="\[$wdirStyle\]\W " # working directory
+    PS1+='`erco=$?; [ $erco == 0 ] && echo -n ":)" || echo -n '"\"\[$red\]:(\[$reset\] $\""'?=$erco` '
     PS1+="\$(prompt_git \"$gitStyle\")" # git repository details
     #PS1+="\n"
     PS1+="\[$charStyle\]\$ \[$reset\]" # $ (and reset color)