Skip to content

Instantly share code, notes, and snippets.

@17twenty
Last active May 20, 2019 02:10
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 17twenty/f993b344dd2523a79ae9c57ae4a153b7 to your computer and use it in GitHub Desktop.
Save 17twenty/f993b344dd2523a79ae9c57ae4a153b7 to your computer and use it in GitHub Desktop.
Mac bash profile to add Git, nice prompt and ls colours, bash completion (requires brew install bash-completion)
if [ -f /usr/local/etc/bash_completion ]; then
. /usr/local/etc/bash_completion
fi
PS1='\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ '
unset color_prompt force_color_prompt
# If this is an xterm set the title to user@host:dir
case "$TERM" in
xterm*|rxvt*)
PS1="\[\e]0;\u@\h: \w\a\]$PS1"
;;
*)
;;
esac
export CLICOLOR=1
export LSCOLORS=ExFxBxDxCxegedabagacad
alias ls='ls -GFh'
function git_color ()
{
# Get the status of the repo and chose a color accordingly
local STATUS=`git status 2>&1`
if [[ "$STATUS" == *'Not a git repository'* ]]
then
echo ""
else
if [[ "$STATUS" != *'working directory clean'* ]]
then
# red if need to commit
echo -e '\033[0;31m'
else
if [[ "$STATUS" == *'Your branch is ahead'* ]]
then
# yellow if need to push
echo -e '\033[0;33m'
else
# else cyan
echo -e '\033[0;36m'
fi
fi
fi
}
function diary {
[ -d ~/diary ] || mkdir ~/diary
vim /Users/$USER/diary/$(date +%Y-%m-%d).md
}
function parse_git_branch {
ref=$(git symbolic-ref HEAD 2> /dev/null) || return
echo "("${ref#refs/heads/}")"
}
export -f git_color
export -f diary
export -f parse_git_branch
export PS1='\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w \[$(git_color)\]$(parse_git_branch)\[\033[00m\] \$ '
export GOPATH=$HOME/go
export PATH=$PATH:$GOPATH/bin/:$HOME/flutter/bin
export CDPATH=.:$GOPATH/src/
export HISTCONTROL=ignoredups:erasedups # no duplicate entries
export HISTSIZE=100000 # big big history
export HISTFILESIZE=100000 # big big history
shopt -s histappend # append to history, don't overwrite it
# Save and reload the history after each command finishes
export PROMPT_COMMAND="history -a; history -c; history -r; $PROMPT_COMMAND"
@17twenty
Copy link
Author

Hardcoded path to brew as it's slow as balls - also removed debian root stuff which isn't relevant

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