Created
January 20, 2020 18:30
-
-
Save btskinner/cefdf572af29067b50a455b8a4319404 to your computer and use it in GitHub Desktop.
Bash profile settings
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
# ------- | |
# .bashrc | |
# ------- | |
# fix colors | |
export TERM=xterm-256color | |
# add to path | |
export PATH="/usr/local/opt:/usr/local/opt/ruby/bin:$PATH" | |
# aliases | |
alias ll="ls -alhG" | |
alias grep="grep --color=auto" | |
alias stata="/Applications/Stata/StataMP.app/Contents/MacOS/stata-mp" | |
alias emacs="/Applications/Emacs.app/Contents/MacOS/Emacs -nw" | |
# locale | |
export LANG=en_US.UTF-8 | |
export LC_ALL=en_US.UTF-8 | |
# use emacs as git editor in Terminal | |
export GIT_EDITOR="/Applications/Emacs.app/Contents/MacOS/Emacs -nw" | |
# ------------------------------------------------------------------------------ | |
# updated git-aware prompt from mathiasbynens dotfiles repo | |
# https://github.com/mathiasbynens/dotfiles/blob/master/.bash_prompt | |
# ------------------------------------------------------------------------------ | |
prompt_git() { | |
local s=''; | |
local branchName=''; | |
# Check if the current directory is in a Git repository. | |
git rev-parse --is-inside-work-tree &>/dev/null || return; | |
# Check for what branch we’re on. | |
# Get the short symbolic ref. If HEAD isn’t a symbolic ref, get a | |
# tracking remote branch or tag. Otherwise, get the | |
# short SHA for the latest commit, or give up. | |
branchName="$(git symbolic-ref --quiet --short HEAD 2> /dev/null || \ | |
git describe --all --exact-match HEAD 2> /dev/null || \ | |
git rev-parse --short HEAD 2> /dev/null || \ | |
echo '(unknown)')"; | |
# Early exit for Chromium & Blink repo, as the dirty check takes too long. | |
# Thanks, @paulirish! | |
# https://github.com/paulirish/dotfiles/blob/dd33151f/.bash_prompt#L110-L123 | |
repoUrl="$(git config --get remote.origin.url)"; | |
if grep -q 'chromium/src.git' <<< "${repoUrl}"; then | |
s+='*'; | |
else | |
# Check for uncommitted changes in the index. | |
if ! $(git diff --quiet --ignore-submodules --cached); then | |
s+='+'; | |
fi; | |
# Check for unstaged changes. | |
if ! $(git diff-files --quiet --ignore-submodules --); then | |
s+='!'; | |
fi; | |
# Check for untracked files. | |
if [ -n "$(git ls-files --others --exclude-standard)" ]; then | |
s+='?'; | |
fi; | |
# Check for stashed files. | |
if $(git rev-parse --verify refs/stash &>/dev/null); then | |
s+='$'; | |
fi; | |
fi; | |
[ -n "${s}" ] && s=" [${s}]"; | |
echo -e "${1}${branchName}${2}${s}"; | |
} | |
if tput setaf 1 &> /dev/null; then | |
tput sgr0; # reset colors | |
bold=$(tput bold); | |
reset=$(tput sgr0); | |
# Zenburn colors taken from Terminal.app. | |
black=$(tput setaf 0); | |
blue=$(tput setaf 4); | |
cyan=$(tput setaf 6); | |
green=$(tput setaf 2); | |
orange=$(tput setaf 130); | |
red=$(tput setaf 1); | |
white=$(tput setaf 7); | |
yellow=$(tput setaf 3); | |
fi; | |
# Set the terminal title and prompt. | |
PS1="\[${bold}\]\n"; | |
PS1+="\[${green}\][\w]"; | |
PS1+="\$(prompt_git \"\[${white}\] on \[${blue}\](\" \")\[${red}\]\")"; | |
PS1+="\n"; | |
PS1+="\[${white}\]\$ \[${reset}\]"; | |
export PS1; | |
PS2="\[${yellow}\]→ \[${reset}\]"; | |
export PS2; | |
# ------------------------------------------------------------------------------ | |
# ------------------------------------------------------------------------------ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment