Skip to content

Instantly share code, notes, and snippets.

@petercamfield
Created August 19, 2016 14:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save petercamfield/759d742149f3cf9fac253d0956dcdc57 to your computer and use it in GitHub Desktop.
Save petercamfield/759d742149f3cf9fac253d0956dcdc57 to your computer and use it in GitHub Desktop.
Display the time and status of last command in BASH
function prompt_command {
es=$?
tput sgr0
tput sc
let xpos=$(tput cols)-10
tput cuf $xpos
tput dim
if [ $es -eq 0 ]
then
tput setab 2
else
tput setab 1
fi
echo -n "$(date '+%T')"
tput rc
}
PROMPT_COMMAND=prompt_command
@petercamfield
Copy link
Author

bash

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment