Time for me show off some ZSH magic, specifically my prompt (because that’s the “in thing” these days)
ec 0 15-01-27 9:28
me@server:~
%
Kinda neat, the integer after the ‘ec’ is the exit code of the previous command, and the timestamp after is the current time. This means I can copy that line with the output of my last command to show when it the command finished and what it’s exit code was. e.g.:
ec 127 15-01-27 9:43
me@server:~/misc
% ls -la
total 12
drwxrwxr-x 3 me me 4096 Jan 23 15:14 .
drwx------ 24 me me 4096 Jan 27 09:22 ..
ec 0 15-01-27 9:43
me@server:~/misc
%
For my own sake, the ‘ec’ integer is red if above zero and green otherwise which lets me easily see if the command ended successfully.
Code below for those who are interested, stick it in your .zshrc somewhere:
# update error code depending on output
local smiley="ec %(?,%{%F{green}%?%{$reset_color%},%{%F{red}%}%?%{$reset_color%})"
local date="%{%F{yellow}%D %T%}"
# show a custom prompt
setprompt() {
PROMPT='$smiley $date
%{%F{white}%}%n@%m:%{%F{cyan}%}%~%{%f%}
%{%F{yellow}%}%#%{%f%} '
RPROMPT=''
}
setprompt