Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save chrisuehlinger/789c541a429fe53dbdb2896d921ce887 to your computer and use it in GitHub Desktop.
Save chrisuehlinger/789c541a429fe53dbdb2896d921ce887 to your computer and use it in GitHub Desktop.
My bash profile
# Timer in the prompt inspired by https://jakemccrary.com/blog/2015/05/03/put-the-last-commands-run-time-in-your-bash-prompt/
function timer_start {
timer=${timer:-$SECONDS}
}
function timer_stop {
timer_total_seconds=$(($SECONDS - $timer))
timer_minutes=$(($timer_total_seconds / 60))
timer_seconds=$(($timer_total_seconds % 60))
timer_show="${timer_minutes}m ${timer_seconds}s"
unset timer
if (( "$timer_total_seconds" > "10"))
then
(afplay /System/Library/Sounds/Hero.aiff &)
fi
}
trap 'timer_start' DEBUG
if [ "$PROMPT_COMMAND" == "" ]; then
PROMPT_COMMAND="timer_stop"
else
PROMPT_COMMAND="$PROMPT_COMMAND; timer_stop"
fi
export PS1='[last: \[\033[1;96m\]${timer_show}\[\033[m\]] \w \nλ '
#export PS1="\[\033[36m\]\u\[\033[m\]@\[\033[32m\]\h:\[\033[33;1m\]\w\[\033[m\]\$ "
export CLICOLOR=1
export LSCOLORS=ExFxBxDxCxegedabagacad
alias ls='ls -GFh'
# Inspired by https://musigma.blog/2016/12/03/ssh-auto-retry.html
function sssh()
{
false
while [ $? -ne 0 ]; do
ssh "$@" || (sleep 1;false)
done
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment