Skip to content

Instantly share code, notes, and snippets.

@nothingmuch
Created October 13, 2010 04:27
Show Gist options
  • Select an option

  • Save nothingmuch/623449 to your computer and use it in GitHub Desktop.

Select an option

Save nothingmuch/623449 to your computer and use it in GitHub Desktop.
_update_prompt () {
if [ -z "$_dumb_prompt" ]; then
# if $_dumb_prompt isn't set, do something potentially expensive, e.g.:
git status --porcelain | perl -ne 'exit(1) if /^ /; exit(2) if /^[?]/'
case "$?" in
# handle all the normal cases
...
# but also add a case for exit due to SIGINT
"130" ) _dumb_prompt=1 ;;
esac
else
# in this case the user asked the prompt to be dumbed down
...
fi
}
# helper commands to explicitly change the setting:
dumb_prompt () {
_dumb_prompt=1
}
smart_prompt () {
unset _dumb_prompt
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment