←back to thread

217 points tanelpoder | 1 comments | | HN request time: 0.209s | source
Show context
scudd ◴[] No.26492906[source]
TIL: You can use `echo $?` to get the last process's exit code.
replies(2): >>26493051 #>>26493264 #
enriquto ◴[] No.26493051[source]
this is actually the most useful thing to put in your prompt (much more than your username, the current directory and other redundant stuff), as in PS1='$?\$ '
replies(2): >>26495670 #>>26497266 #
Noumenon72 ◴[] No.26497266[source]
Might be useful but I just spent half an hour trying everything at https://stackoverflow.com/questions/16715103/bash-prompt-wit... on a MacBook Pro and none of it worked.
replies(2): >>26497907 #>>26498559 #
1. JdeBP ◴[] No.26498559[source]
That's because, as a MacOS user, you are probably using the Z shell, not the Bourne Again shell. Prompt syntax is specific to each individual shell program.

One cannot just blindly use a Stack Exchange Q&A that states that it is for "Linux" and "bash" on the Z shell on MacOS, or indeed on the Z shell on a Linux-based operating system for that matter. Or in the C shell. Or in the Korn shell. Or in the Watanabe shell.