Skip to content

Instantly share code, notes, and snippets.

@huwan
Created April 14, 2019 13:06
Show Gist options
  • Save huwan/8ee53559bb7ddb4d9ac0437c7fd93379 to your computer and use it in GitHub Desktop.
Save huwan/8ee53559bb7ddb4d9ac0437c7fd93379 to your computer and use it in GitHub Desktop.
BASH configuration
# https://unix.stackexchange.com/a/368927
prompt_command() {
# initialize the timestamp, if it isn't already
_bashrc_timestamp=${_bashrc_timestamp:-$(stat -c %Y "$HOME/.bashrc")}
# if it's been modified, test and load it
if [[ $(stat -c %Y "$HOME/.bashrc") -gt $_bashrc_timestamp ]]
then
# only load it if `-n` succeeds ...
if $BASH -n "$HOME/.bashrc" >& /dev/null
then
¦ source "$HOME/.bashrc"
else
¦ printf "Error in $HOME/.bashrc; not sourcing it\n" >&2
fi
# ... but update the timestamp regardless
_bashrc_timestamp=$(stat -c %Y "$HOME/.bashrc")
fi
}
PROMPT_COMMAND='prompt_command'
export LC_ALL=en_US.UTF-8
export LANG=en_US.UTF-8
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment