Skip to content

Instantly share code, notes, and snippets.

@dvessel
Last active December 18, 2015 05:48
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save dvessel/5734923 to your computer and use it in GitHub Desktop.
Save dvessel/5734923 to your computer and use it in GitHub Desktop.
A few of my dot files.
# Styles @see man terminfo
__blu=`tput setaf 25` # blue
__gra=`tput setaf 245` # gray
__ora=`tput setaf 208` # orange
__end=`tput setaf 0` # end colors
__bol=`tput bold` # bold
__res=`tput sgr0` # reset
# /usr/local/* defined so it comes before /usr/bin and /bin. Required for
# Homebrew. Default PATH=/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin
export PATH=/usr/local/bin:/usr/bin:/bin:/usr/local/sbin:/usr/sbin:/sbin
# Gem binary path. (homebrew)
export PATH=/usr/local/opt/ruby/bin:$PATH
# Node path as instructed by homebrew.
export NODE_PATH=/usr/local/lib/node_modules
# For npm-installed binaries. (homebrew)
export PATH=/usr/local/share/npm/bin:$PATH
# Tools in my home folder.
export PATH=$HOME/bin:$PATH
# Editors
export EDITOR='subl -w'
export GIT_EDITOR='subl -w'
# History options
export HISTCONTROL=ignoreboth
export HISTSIZE=1000
export HISTIGNORE=ls:ll:la:llm:lam
# Custom prompt.
# Requires sourced homebrew bash completion.
export PROMPT_COMMAND='__git_ps1 "\n$__blu\u@\h:$__gra\w$__end\n " "\W > " "`___git_status`\n "'
# Tab completion for homebrew.
# `brew install bash-completion` first
source `brew --prefix`/etc/bash_completion
# Git options for `__git_ps1` within PROMPT_COMMAND.
GIT_PS1_SHOWCOLORHINTS=true
GIT_PS1_SHOWDIRTYSTATE=true
GIT_PS1_SHOWUNTRACKEDFILES=true
GIT_PS1_SHOWUPSTREAM='auto'
GIT_PS1_DESCRIBE_STYLE='contains'
# Aliases
alias cl='clear'
alias ls='ls -G'
alias ll='ls -hl'
alias la='ls -hla'
alias llm='ll | more'
alias lam='la | more'
alias gz='tar czf'
alias hide='chflags hidden'
alias show='chflags nohidden'
# Sublime Text
alias st='subl'
# Parallels command line tools helper. https://github.com/dvessel/prlvm
alias vm='prlvm'
# SSH tunneling for rsub. Usually set in ~/.ssh/config but can be called
# directly with this. https://github.com/henrikpersson/rsub
alias rssh='ssh -R 52698:localhost:52698'
# MySQL (homebrew)
ldmysql='/Library/LaunchDaemons/homebrew.mxcl.mysql.plist'
alias mysql.load="sudo launchctl load $ldmysql"
alias mysql.unload="sudo launchctl unload $ldmysql"
alias mysql.reload="mysql.unload && mysql.load"
# Apache
ldhttpd='/System/Library/LaunchDaemons/org.apache.httpd.plist'
alias http.load="sudo launchctl load $ldhttpd"
alias http.unload="sudo launchctl unload $ldhttpd"
alias http.reload="http.unload && http.load"
# Web development
alias web.load="mysql.load && http.load"
alias web.unload="mysql.unload && http.unload"
alias web.reload="mysql.reload && http.reload"
# Parallels Launcher
prllauncher="/Applications/Parallels\ Desktop.app/Contents/MacOS/launcher"
alias prl.load="$prllauncher start"
alias prl.unload="$prllauncher stop"
alias prl.reload="$prllauncher restart"
# DNS flush: http://support.apple.com/kb/HT5343
alias dns.flush='sudo killall -HUP mDNSResponder'
# Solr
alias solr.example='cd ~/dir/to/project/solr/ && java -jar start.jar'
# Update
alias update.homebrew="brew update && brew upgrade && brew cleanup -s"
alias update.bundle="bundle update && gem cleanup"
alias update.all="update.homebrew && update.bundle"
# Git
alias gitr=git-recursive
# https://github.com/dvessel/git-cached
alias git=gitc
# Drush
alias dr=drush
# History piped to less.
alias history="history | less"
# Recursively call git on current and all child directories.
function git-recursive() {
echo "`find . -name '.git' | sort`" | while read i; do
cd `dirname ${i}` && echo '' && echo ">>>> $@ `dirname ${i#./}`"
git "$@"
cd - > /dev/null;
done
}
# Git status for terminal prompt.
function ___git_status() {
if [[ `git rev-parse --is-inside-work-tree 2>/dev/null` || `git rev-parse --is-inside-git-dir 2>/dev/null` ]]; then
local path=`git rev-parse --show-toplevel`
local base=${path##*/}
local cached=
local sha1=`git rev-parse --short=10 HEAD 2>/dev/null`
if [[ -n `git config -z --get git-cached.cache-dir 2> /dev/null` ]]; then
cached=c
fi
echo "${__bol}$base${__res} %s ${__gra}$sha1 ${__ora}$cached${__end}"
fi
}
# Make auto-complete case-insensitive.
set completion-ignore-case on
# Search history. https://coderwall.com/p/oqtj8w
"\e[A": history-search-backward
"\e[B": history-search-forward
set show-all-if-ambiguous on
set completion-ignore-case on
@dvessel
Copy link
Author

dvessel commented Jul 13, 2013

Demo of git status from the terminal prompt:

https://www.youtube.com/watch?v=CUeSVJy50Lc

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