4 ms·
Oh, how do you automate that? I usually add a "& say done | say failed" to long-running tasks if I remember to do it.
by tclancy 1y ago
Oh, how do you automate that? I usually add a "& say done | say failed" to long-running tasks if I remember to do it.
- teo_zero 1y agoIn bash, it's enough to remember that $? expands to the exit code of the previous command, and $((x)) evaluate x as an integer expression, including the ternary operator x?y:z. For example the following prints the exit code in green if zero, in red otherwise: PS1='\[\e[$(($??31:32))m\]$? \[\e[39m\]'
- deathanatos 1y agohttps://github.com/thanatos/dotfiles/blob/master/shell/zsh/prompt-alpha#L108-L174 https://github.com/thanatos/dotfiles/blob/master/shell/zsh/p... That was my prompt when it was written in zsh. Sort of like TFA, I've since moved to Rust: https://github.com/thanatos/dotfiles/blob/master/zsh-prompt-in-rust/src/prompt.rs#L242-L270 https://github.com/thanatos/dotfiles/blob/master/zsh-prompt-... I think (if I am reading TFA's code right) unlike the article, I'm using zsh's module functionality, so the Rust here is a .so that is loaded directly into the shell's memory. (I.e., I do not have to fork/exec a separate Rust bin to compute the prompt, though I think zsh might fork-but-not-exec for computing the prompt itself.) The latter is, of course, somewhat more complicated in some senses. (Esp. on macOS, which work forces me to use, where dlopen(2) is just utterly insane.)