Created
October 13, 2010 04:27
-
-
Save nothingmuch/623449 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| _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