Last active
May 20, 2019 02:10
-
-
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)
This file contains 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
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" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hardcoded path to brew as it's slow as balls - also removed debian root stuff which isn't relevant