Pastebin launched a little side project called VERYVIRAL.com, check it out ;-) Want more features on Pastebin? Sign Up, it's FREE!
Guest

zach’s bashrc

By: a guest on Oct 27th, 2012  |  syntax: Bash  |  size: 10.73 KB  |  views: 275  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. #colored terminal stuff & fixes
  2. export TERM="xterm-color"
  3. export CLICOLOR=1
  4. export LSCOLORS=ExFxCxDxBxegedabagacad
  5. export GREP_OPTIONS='--color=auto'
  6. source "`brew --prefix grc`/etc/grc.bashrc"
  7. #tmux stuff
  8. #check if tmux is installed
  9. #if which tmux 2>&1 >/dev/null; then
  10. #    #if no session is started, start a new session
  11. #    test -z ${TMUX} && tmux -2
  12. #
  13. #    #when quitting tmux, try to attach
  14. #    while test -z ${TMUX}; do
  15. #        tmux attach || break
  16. #    done
  17. #fi
  18. # FIXES
  19. ################################################################################
  20. # set sane process limit
  21. ulimit -n 4096
  22. # remove duplicates from command history list
  23. export HISTCONTROL=erasedups
  24. # increase history size
  25. export HISTSIZE=10000
  26. # set UTF-8 support
  27. export LC_ALL="en_US.UTF-8"
  28. #export LANG=en_US.UTF-8
  29. # make Terminal interact with user in English
  30. export LANG="en_US"
  31. #set LC_CTYPE="en_US.UTF-8"
  32. # fix some iTerm inputs for international characters
  33. #set meta-flag on
  34. #set input-meta on
  35. #set output-meta on
  36. #set convert-meta off
  37. # prevent clobbering
  38. set -o noclobber
  39. # ensure history from session is appended to ~/.bash_history on exit
  40. shopt -s histappend
  41. # check the window size after each command and, if necessary,
  42. # update the values of LINES and COLUMNS.
  43. shopt -s checkwinsize
  44. # don't autocomplete empty lines
  45. shopt -s no_empty_cmd_completion
  46. # allow case-insensitive auto-completion
  47. shopt -s nocaseglob
  48. # allow minor typos in directory names for cd command
  49. shopt -s cdspell
  50. # allow extended glob patterns
  51. shopt -s extglob
  52. # allow builtin echo to expand backslash escape sequences
  53. shopt -s xpg_echo
  54. # use most instead of less for paging
  55. export PAGER="most"
  56. # configure TextMate as editor and for remote editing
  57. export EDITOR="/usr/local/bin/mate -w"
  58. export RMATE_HOST=auto
  59. export RMATE_PORT=52698
  60.  
  61.  
  62. # NOTES
  63. ################################################################################
  64. # To temporarily bypass an alias, we preceed the command with a \  
  65. # EG:  the ls command is aliased, but to use the normal ls command you would
  66. # type \ls
  67.  
  68. #ALIASES
  69. ################################################################################
  70. # make ls use human readable file sizes
  71. alias ls="gls -h --color=always"
  72. # make ls list one entry per line
  73. alias dir="gls -hG1 --color=always"
  74. # make df more readable
  75. alias df="gdf -H"
  76. # GNU echo
  77. alias echo="gecho"
  78. # colors script
  79. alias colors="perl ~/Dropbox/Scripts/Colortest/256colors.perl"
  80. # kill GeekTool
  81. alias kgeek="killall GeekTool\ Helper"
  82. # make htop sort by CPU usage and update only every 2 seconds and only show processes of current logged in user
  83. alias htop="htop --sort-key PERCENT_CPU -d 20 -u `whoami`"
  84. # delete all Apple System Log files (speeds up Terminal.app on first login)
  85. alias delasl="sudo rm -f /private/var/log/asl/*.asl"
  86. # flush dns cache (may not work after OS X 10.8?)
  87. alias flushcache="dscacheutil -flushcache"
  88. # get PID of a process by name
  89. alias pidof="sh /Library/Scripts/pidof.sh"
  90. # set a reminder at a certain time or after a number of minutes
  91. alias remindin="sh /Library/Scripts/eggtimer.sh"
  92. alias remindat="sh /Library/Scripts/remindat.sh"
  93. alias cleartimers="atrm"
  94. # weather script - can take a zipcode argument to get weather for that location, otherwise tries to get current location based off of zipcode
  95. alias weather="sh ~/Dropbox/Scripts/Weather.sh"
  96. # zipcode - tries to determine current zipcode from ipinfodb.com based on current IP address
  97. alias currentzip="sh /Library/Scripts/zipcode.sh"
  98. # display text with figlet and toilet
  99. alias toilet="toilet --gay -f mono9"
  100. #alias destep="figlet -w 80 -nkf rowancap DESTEP TRED | tr 'd' '▟' | tr 'P' '▛' | tr 'M' '█' | tr 'V' '▜' | tr '\"' ' ' | tr '.' ' ' | tr 'a' '▟' | tr 'b' '▙' | tr 'K' '█' | tr 'A' '▟' | tr 'F' '▛' | tr 'Y' '▜' | tr 'v' '█' | tr 'm' '█' | tr 'r' '▛' | toilet -w 80 --gay -f term"
  101. #alias destep="echo "" && figlet -f rowancap DESTEP TRED | tr '[A-Z]|[a-z]' '▐' | tr '.' ' ' | tr '\"' ' ' | toilet --gay -f term"
  102. #alias destep="clear && echo "" && echo "" && echo "" && echo "" && echo "" && toilet -f future --gay '          destep'; toilet -f future --gay '           tred' && echo "" && echo "" && echo "" && echo """
  103. #alias destep="clear && echo "" && echo "" && echo "" && echo "" && toilet -f kban --gay '     destep' | tr \|  ▉ | tr \.  ▄ | tr \' ▀ && toilet -f kban --gay '        tred' | tr \|  ▉ | tr \.  ▄ | tr \' ▀ && echo "" && echo """
  104. alias destep="clear && toilet -f mono9 --gay destep tred"
  105. #repair disk permissions
  106. alias repair="diskutil repairpermissions"
  107. #problem?
  108. alias problem="clear && figlet -pf future problem? | toilet --gay -f term | cowsay -nf coolface | tr '/|\|_|-' ' ' | tr '\\' ' '"
  109. #soon...
  110. alias soon="clear && figlet -pf future SOON... | toilet --gay -f term | cowsay -nf tidus | tr '/|\|_|-' ' ' | tr '\\' ' '"
  111. #start mpd with proper config file
  112. alias mpd="killall mpd; open /Users/zach/Dropbox/Scripts/mpd\ configure.app;"
  113. #view colorised live system log entries
  114. alias syslog="tail -F /var/log/system.log | grcat conf.log"
  115. #colorize tree output
  116. alias tree="tree -AC"
  117. #display some system info (OS X version, CPU, Mac model, GPU/display, disks)
  118. alias sysprofile="sw_vers; system_profiler SPHardwareDataType | head -n 15; echo ""; system_profiler SPDisplaysDataType; df;"
  119. #clear the terminal display
  120. alias cl="clear"
  121. #update WebKit nightly
  122. alias updatewebkit="sh ~/Dropbox/Scripts/WebkitNightlyUpgradeScript.sh"
  123. #poll Google Finance data for stock information
  124. alias stockinfo="osascript ~/Dropbox/Scripts/stockinfo.applescript"
  125. #a terminal clock
  126. alias clock="tty-clock -s -c -t -C 1"
  127. #fuck u python
  128. alias pip="/usr/local/share/python/pip"
  129. alias beet="/usr/local/share/python/beet"
  130. #use graphical characters for pstree
  131. alias pstree="pstree -g 3"
  132. #make tmux use all available colors
  133. alias tmux="tmux -2"
  134. #use rmtrash instead of rm
  135. alias rm="rmtrash"
  136. #edit file in TextMate α with wait option
  137. alias edit="mate -w"
  138. #unregister applications from LaunchServices in order to remove duplicate items
  139. alias kls="/System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/LaunchServices.framework/Versions/A/Support/lsregister -kill -r -domain local -domain system -domain user"
  140. #aliases for Brandeis COSI servers
  141. alias sshcoeus="ssh zyocum@coeus.cs.brandeis.edu"
  142. alias sshthemis="ssh zyocum@themis.cs.brandeis.edu"
  143. #use ssh protocol 2.0 and IPv6
  144. #alias ssh="ssh -2 -6"
  145. #ssh via BackToMyMac
  146. alias sshzora="ssh -2 -6 zach@zora.289987032.members.btmm.icloud.com"
  147. alias sshfarore="ssh -2 -6 zach@farore.289987032.members.btmm.icloud.com"
  148. #remotely edit in TextMate 2
  149. alias rmssh="ssh -R 52698:$HOSTNAME.local.:52698"
  150.  
  151.  
  152. #TEXT COLORS
  153. ################################################################################
  154. TXTBLK='\e[0;30m'               # Black - Regular
  155. TXTRED='\e[0;31m'               # Red
  156. TXTGRN='\e[0;32m'               # Green
  157. TXTYLW='\e[0;33m'               # Yellow
  158. TXTBLU='\e[0;34m'               # Blue
  159. TXTPUR='\e[0;35m'               # Purple
  160. TXTCYN='\e[0;36m'               # Cyan
  161. TXTWHT='\e[0;37m'               # White
  162. BLDBLK='\e[1;30m'               # Black - Bold
  163. BLDRED='\e[1;31m'               # Red
  164. BLDGRN='\e[1;32m'               # Green
  165. BLDYLW='\e[1;33m'               # Yellow
  166. BLDBLU='\e[1;34m'               # Blue
  167. BLDPUR='\e[1;35m'               # Purple
  168. BLDCYN='\e[1;36m'               # Cyan
  169. BLDWHT='\e[1;37m'               # White
  170. UNDBLK='\e[4;30m'               # Black - Underline
  171. UNDRED='\e[4;31m'               # Red
  172. UNDGRN='\e[4;32m'               # Green
  173. UNDYLW='\e[4;33m'               # Yellow
  174. UNDBLU='\e[4;34m'               # Blue
  175. UNDPUR='\e[4;35m'               # Purple
  176. UNDCYN='\e[4;36m'               # Cyan
  177. UNDWHT='\e[4;37m'               # White
  178. BAKBLK='\e[40m'                 # Black - Background
  179. BAKRED='\e[41m'                 # Red
  180. BAKGRN='\e[42m'                 # Green
  181. BAKYLW='\e[43m'                 # Yellow
  182. BAKBLU='\e[44m'                 # Blue
  183. BAKPUR='\e[45m'                 # Purple
  184. BAKCYN='\e[46m'                 # Cyan
  185. BAKWHT='\e[47m'                 # White
  186. TXTRST='\e[0m'                  # Text Reset
  187.  
  188. TXT236='\e[38;5;236m'           # Darkest Grey - Regular
  189. TXT238='\e[38;5;238m'           # Darker Grey
  190. TXT000='\e[38;5;000m'           # Dark Grey
  191. TXT232='\e[38;5;232m'           # Black
  192. TXTBRD='\e[38;5;088m'           # Bright Red
  193. TXTBBR='\e[38;5;196m'           # Brightest Red
  194.  
  195. BAK233='\e[48;5;233m'           # Darkest Grey - Background
  196. BAK241='\e[48;5;241m'           # Darker Grey
  197. BAK000='\e[48;5;000m'           # Dark Grey
  198. BAKBRD='\e[48;5;130m'           # Bright Red
  199. BAKBBR='\e[48;5;166m'           # Brightest Red
  200.  
  201. #PROMPT
  202. ################################################################################
  203. # cool prompt stuff
  204. # based on a function found in bashtstyle-ng 5.0b1
  205. # Original author Christopher Roy Bratusek (http://www.nanolx.org)
  206. # Last arranged by zach Tue Jul 24 06:40:19 EDT 2012
  207. function pre_prompt {
  208.     specPWD=$(echo -n ${PWD} | sed "s/\/Users\/$USER/~/")       #Should now properly sed path of current user
  209.     newPWD=$specPWD
  210.     let promptsize=$(echo -n "_!___${USER}@${HOSTNAME}__${specPWD}"\ | wc -c | tr -d " ")
  211.     let fillsize=(${COLUMNS})-${promptsize}
  212. fill=""
  213.     while [ "$fillsize" -gt "0" ]
  214.     do
  215.        fill="${fill} "
  216.         let fillsize=${fillsize}-1
  217.     done
  218.     if [ "$fillsize" -lt "0" ]
  219.     then
  220.         let cutt=1-${fillsize}
  221.         newPWD="…$(echo -n $specPWD | sed -e "s/\(^.\{$cutt\}\)\(.*\)/\2/")"
  222.    fi
  223. }
  224.  
  225. PROMPT_COMMAND=pre_prompt
  226.  
  227. PS1="\`if [ \$? = 0 ]; then echo \"${TXTBLK}${BAK241} \$ ${TXT236}${BAKBLK}\"; else echo \"${TXTBLK}${BAKRED} ! ${TXTBRD}${BAKBLK}\"; fi\`${TXTGRN}${BAKBLK} \u${BLDBLK}@${BLDCYN}\h ${TXTBLK}${BAKBLU}${TXTRST}${BAKBLU}${BLDBLU} \$newPWD\${fill}${TXTRST}\n"
  228.  
  229. PS2="${TXTBLK}»${TXTRST}"
  230. PS3="${TXTBLK}»${TXTRST}"
  231. PS4="${TXTBLK}»${TXTRST}"
  232.  
  233. #EXTRAS
  234. ################################################################################
  235. # Bash completion
  236. if [ -f /etc/bash_completion ]; then
  237.         . /etc/bash_completion
  238. fi
  239.  
  240. # Better manual pages (uses --help as fallback if no man page exists)
  241. man () {
  242.    /usr/bin/man $@ || ($@ --help 2> /dev/null && $@ --help | $PAGER)
  243. }
  244.  
  245. # Extract things. Thanks to urukrama, Ubuntuforums.org 
  246. extract () {
  247.     if [ -f $1 ] ; then
  248.         case $1 in
  249.             *.tar.bz2)   tar xjf $1        ;;
  250.             *.tar.gz)    tar xzf $1     ;;
  251.             *.bz2)       bunzip2 $1       ;;
  252. #             *.rar)       rar x $1     ;;
  253.             *.gz)        gunzip $1     ;;
  254.             *.tar)       tar xf $1        ;;
  255.             *.tbz2)      tar xjf $1      ;;
  256.             *.tgz)       tar xzf $1       ;;
  257.             *.zip)       unzip $1     ;;
  258.             *.Z)         uncompress $1  ;;
  259. #             *.7z)        7z x $1    ;;
  260.             *)           echo "'$1' cannot be extracted via extract()" ;;
  261.         esac
  262.     else
  263.         echo "'$1' is not a valid file"
  264.     fi
  265. }
  266.  
  267. imgur ()
  268. {
  269.        for FILE in "$@"
  270.        do
  271.                curl -F "image=@-" -F "key=1913b4ac473c692372d108209958fd15" http://api.imgur.com/2/upload.xml < "$FILE" |
  272.                        grep -Eo "<original>(.)*</original>" |
  273.                        grep -Eo "http://i.imgur.com/[^<]*"
  274.        done
  275. }
clone this paste RAW Paste Data