Package: bash
Severity: wishlist
Version: 4.3-12
Tags: patch

It would be great if the default bash prompt on debian systems included
the return code of the last-executed pipeline.

  Visible return codes are useful for debugging, and for problem
  reports.  They can also expose some failures that otherwise wouldn't
  be obvious from the stdout/stderr of the process alone.
  
  Visible return codes are also useful in shell interactions that may
  eventually become part of a script, because they encourage thinking
  about the shell programmatically (even if it is as simple as
  considering "if then" conditionals).
  
The patch below provides this change.

Thanks for maintaining bash in debian!

Regards,

        --dkg

------------------------------------------------------------
revno: 30
committer: [email protected]
branch nick: bash
timestamp: Wed 2015-06-03 12:21:25 -0400
message:
  add return code to the default prompt
  
  Visible return codes are useful for debugging, and for problem
  reports.  They can also expose some failures that otherwise wouldn't
  be obvious from the stdout/stderr of the process alone.
  
  Visible return codes are also useful in shell interactions that may
  eventually become part of a script, because they encourage thinking
  about the shell programmatically (even if it is as simple as
  considering "if then" conditionals).
  
  This patch exposes the return code in the beginning of all the default
  prompts.
diff:
=== modified file 'etc.bash.bashrc'
--- etc.bash.bashrc	2015-01-29 23:36:31 +0000
+++ etc.bash.bashrc	2015-06-03 16:21:25 +0000
@@ -16,7 +16,7 @@
 fi
 
 # set a fancy prompt (non-color, overwrite the one in /etc/profile)
-PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ '
+PS1='${debian_chroot:+($debian_chroot)}$? \u@\h:\w\$ '
 
 # Commented out, don't overwrite xterm -T "title" -n "icontitle" by default.
 # If this is an xterm set the title to user@host:dir

=== modified file 'etc.profile'
--- etc.profile	2011-09-11 19:07:36 +0000
+++ etc.profile	2015-06-03 16:21:25 +0000
@@ -9,7 +9,7 @@
 
 if [ "$PS1" ]; then
   if [ "$BASH" ]; then
-    PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ '
+    PS1='${debian_chroot:+($debian_chroot)}$? \u@\h:\w\$ '
     if [ -f /etc/bash.bashrc ]; then
         . /etc/bash.bashrc
     fi

=== modified file 'skel.bashrc'
--- skel.bashrc	2015-01-29 23:36:31 +0000
+++ skel.bashrc	2015-06-03 16:21:25 +0000
@@ -57,9 +57,9 @@
 fi
 
 if [ "$color_prompt" = yes ]; then
-    PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ '
+    PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]%? \u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ '
 else
-    PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ '
+    PS1='${debian_chroot:+($debian_chroot)}$? \u@\h:\w\$ '
 fi
 unset color_prompt force_color_prompt

Reply via email to