Timeline for Bash: Display exit status in prompt:
Current License: CC BY-SA 4.0
14 events
| when toggle format | what | by | license | comment | |
|---|---|---|---|---|---|
| Sep 19, 2018 at 14:22 | history | edited | Mikel | CC BY-SA 4.0 |
added 14 characters in body
|
| Sep 19, 2018 at 14:20 | comment | added | Mikel | @ilkkachu Thanks for the comment and correction. I was about to edit, and noticed you had already done so. Thank you! | |
| Sep 19, 2018 at 14:10 | history | edited | ilkkachu | CC BY-SA 4.0 |
The comparison with 'echo' is just wrong. Gilles' answer explains it correctly, but this was missing the point entirely.
|
| Sep 19, 2018 at 13:56 | comment | added | ilkkachu |
"Bash is effectively calling echo on your PS1, not echo -e" -- well that's wrong or just missing the point. Bash does expand backslash-escapes like \e and \033 (and \[/\], \u, and \h) from the prompt, it just does so before expanding the variables. So PS1='\e[1;31m red' works, red='\e[1;31m'; PS1='$red red' doesn't.
|
|
| Oct 27, 2015 at 20:55 | comment | added | Mikel | Yeah, I was just surprised by mixing of data and presentation, but I get it. :) | |
| Oct 27, 2015 at 19:48 | comment | added | Mingye Wang | Well, someone just want to emphasize the codes… Sometimes I do the same: github.com/AOSC-Dev/bash-config/issues/8 | |
| Oct 27, 2015 at 19:46 | comment | added | Mikel | @Arthur2e5 Ew, I totally missed that. :) Why would you put colors... never mind. :) | |
| Oct 27, 2015 at 19:28 | comment | added | Mingye Wang | The problem is it does contain some -- the colors. (ANSI Escapes) | |
| Oct 27, 2015 at 19:13 | comment | added | Mikel |
@Arthur2e5 Do you mean \] is \2? And do you mean that's why it's needed for ${exitStatus}? My point was that ${exitStatus} does not contain non-printing characters, so bash should be able to correctly determine how many characters it moves the prompt without the \[ and \] in \[${exitStatus}\].
|
|
| Oct 27, 2015 at 18:53 | comment | added | Mingye Wang |
\[ is \1, and \[ is \2. Those to corresponds to some readline's RL_PROMPT_{START,END}_IGNORE thing which asks it to ignore the bytes when counting the prompt length on screen. See lists.gnu.org/archive/html/bug-bash/2015-08/msg00027.html.
|
|
| Mar 4, 2011 at 9:43 | vote | accept | dogbane | ||
| Mar 3, 2011 at 2:44 | history | edited | Mikel | CC BY-SA 2.5 |
deleted 1 characters in body
|
| Mar 3, 2011 at 2:23 | history | edited | Mikel | CC BY-SA 2.5 |
added 588 characters in body; added 68 characters in body
|
| Mar 3, 2011 at 2:16 | history | answered | Mikel | CC BY-SA 2.5 |