Skip to content

Instantly share code, notes, and snippets.

@FranciscoG
Last active December 22, 2015 05:48
Show Gist options
  • Save FranciscoG/6426288 to your computer and use it in GitHub Desktop.
Save FranciscoG/6426288 to your computer and use it in GitHub Desktop.
This is for the terminal on OSX (but probably works on Linux too)
export PATH="$PATH:~/bin"
# Set CLICOLOR if you want Ansi Colors in iTerm2
export CLICOLOR=1
# Set colors to match iTerm2 Terminal Colors
export TERM=xterm-256color
# personal functions
#I like to echo out Ascii art into the terminal, this auto escapes and echoes out the art
function contraArt () {
cat<<"EOT"
-://ooo+++y+/:-. `
.--/+oyhdddmdmdmmmmmdhyos:``..
`:+oyyyhhhyhyyyhhhhhdddmmmhyds:.
-:oyyyyyyss+//---:::+syyhddmNmh/.
-:oyyyyyo/-..` `-+shhhs:.
`:+syyyys::` `....
:/sosyo/- .:///://+/. `:/:` `-//:./////+//:..+/////+:/:-` `:/:`
::/++++/` `/+mhs+-o/hds/.++/osy/` oos:-h/+yyd/o/::hyyyyhd/y+dh.`oddhdho.
`+:://+:. `:+ho````./ho+-h+oo-s++/`o++:..````:oo+:-yssssyh/hohs-.hdh-+ydh/`
``/:/::: `:+ds.....odo+-dddo`.:odssho:. `-os+::mhs///o/h+so.`hdhhhhds+s-``
:/::::. ` `-/+yyyyyyyo/:.hyy+` .+sys:-` -om+::mho.` `:/hdo.hhh--.-:-+sy-
::///::::-.` `..........``---- ``.``` `....`.... ....-`-... `...`
.:-/://////:--....````..-----:/:--.``.`
...--::::::::---:--.-:-..`
`.::-------::-`
EOT
}
function reload () {
source ~/.bash_profile
}
function la () {
ls -lah
}
#switch to git projects folder
function projects () {
cd ~/projects
}
# ACK set to use .ackrc for most commonly used
# $@ spits out any/all arguments: example use: grack -option -option 'string'
# output: ack --ackrc=/Users/me/.ackrc -option -option 'string'
function grack (){
echo "ack --ackrc=/Users/me/.ackrc" $@
ack --ackrc=/Users/me/.ackrc $@
}
#this takes all optional arguments and converts to an array
#it then joins all args as one string with a backslash in between
#example use: contra modules main js
#output cd ~/projects/Contra/modules/main/js
function contra (){
array=( $@ )
_args=$( IFS=$'/'; echo "${array[*]}" )
contraArt
cd ~/projects/Contra/$_args
}
# when leaving a company this will remove all personal info from the machine on a Mac
# add to it as you install personally sensitive info
# usage: killswith rm -rf
function killswitch {
array=( $@ )
_args=$( IFS=$'/'; echo "${array[*]}" )
app_support=~/Library/Application\ Support/
echo "removing spotify"
$_args "$app_support"Spotify
echo "removing Google products data: Chrome Canary, Chrome Beta, Music Manager. Drive, etc"
$_args "$app_support"Google
$_args ~/Google\ Drive
echo "deleting personal folder"
$_args ~/personal
echo "deleting dropbox"
$_args ~/.dropbox
$_args ~/Dropbox
echo "deleting personal github ssh keys"
$_args ~/.ssh/d_rsa-*
}
# the following below is all about customizing my prompt
# slightly modified form this source: http://digitalformula.net/articles/pimp-my-prompt-like-paul-irish/page_4/
# enable the git bash completion commands
#https://github.com/git/git/tree/master/contrib/completion
#get git-completion.sh and git-prompt.sh
#put them in your ~ folder and rename them to:
#.git-completion.sh
#.git-prompt.sh
source ~/.git-completion.sh
source ~/.git-prompt.sh
# enable git unstaged indicators - set to a non-empty value
GIT_PS1_SHOWDIRTYSTATE="."
# enable showing of untracked files - set to a non-empty value
GIT_PS1_SHOWUNTRACKEDFILES="."
# enable stash checking - set to a non-empty value
GIT_PS1_SHOWSTASHSTATE="."
# enable showing of HEAD vs its upstream
GIT_PS1_SHOWUPSTREAM="auto"
BLACK=$(tput setaf 0)
RED=$(tput setaf 1)
GREEN=$(tput setaf 2)
YELLOW=$(tput setaf 3)
LIME_YELLOW=$(tput setaf 190)
POWDER_BLUE=$(tput setaf 153)
BLUE=$(tput setaf 4)
MAGENTA=$(tput setaf 5)
CYAN=$(tput setaf 6)
WHITE=$(tput setaf 7)
BRIGHT=$(tput bold)
NORMAL=$(tput sgr0)
BLINK=$(tput blink)
REVERSE=$(tput smso)
UNDERLINE=$(tput smul)
# set the prompt to show current working directory and git branch name, if it exists
# this prompt is a green username, black @ symbol, cyan host, magenta current working directory and white git branch (only shows if you're in a git branch)
# unstaged and untracked symbols are shown, too (see above)
# this prompt uses the short colour codes defined above
# PS1='${GREEN}\u${BLACK}@${CYAN}\h:${MAGENTA}\w${WHITE}`__git_ps1 " (%s)"`\$ '
# this is a cyan username, @ symbol and host, magenta current working directory and white git branch
# it uses the shorter , but visibly more complex, codes for text colours (shorter because the colour code definitions aren't needed)
# PS1='\[\033[0;36m\]\u@\h\[\033[01m\]:\[\033[0;35m\]\w\[\033[00m\]\[\033[1;30m\]\[\033[0;37m\]`__git_ps1 " (%s)"`\[\033[00m\]\[\033[0;37m\]\$ '
# return the prompt prefix for the second line
function set_prefix {
BRANCH=`__git_ps1`
if [[ -z $BRANCH ]]; then
echo "${NORMAL}>"
else
echo "${NORMAL}+>"
fi
}
# and here's one similar to Paul Irish's famous prompt ... not sure if this is the way he does it, but it works :)
# \033[s = save cursor position
# \033[u = restore cursor position
PS1='${MAGENTA}\u${WHITE} in ${GREEN}\w${WHITE}${MAGENTA}`__git_ps1 " on %s"`${WHITE}\r\n`set_prefix`${NORMAL}${CYAN}\033[s\033[u${WHITE} '
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment