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

bashrc

By: a guest on Feb 9th, 2011  |  syntax: Bash  |  size: 7.02 KB  |  views: 1,062  |  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. VERSION="00101011001"
  2. VDATE="0101-01-01"
  3. case $- in
  4.     *i*)
  5.         ;;
  6. esac
  7. ################INIT
  8. # If this is called non-interactively bypass the rest
  9. [ -z "$PS1" ] && return
  10.  
  11. # Check size of window and update LINES and COLUMNS if needed
  12. shopt -s checkwinsize
  13.  
  14. # Set colored prompt if we support it
  15. case "$TERM" in
  16.     xterm-color) color_prompt=yes;;
  17. esac
  18.  
  19. ################GENERAL
  20. PATH=$PATH:$HOME/bin:/sbin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/var/netconf/bin:/opt/csw:/opt/sfw:/opt/csw/bin:/opt/sfw/bin:/usr/local/mysql/bin:/sw/bin:/opt/local/bin:/opt/local/sbin:/usr/java/latest/bin:/Applications
  21. TERM=xterm-color
  22. export PATH;
  23. export TERM;
  24.  
  25. ################SCRIPTS
  26. set +H #deactivate  history expansion during parsing for current session
  27. mk() { eval ${1:-MKPWD}=\"`pwd`\"; }
  28. rt() { eval cd \"\$${1:-MKPWD}\";pwd; }
  29. str2hex() { echo -n "str: " && read x && echo -n "$x" |xxd -c 256 -p |sed 's/0a//1'|awk '{print $1}';}
  30. maxcrypt() { echo -n "str: " && read x && echo -n "$x"|openssl dgst -sha512 |openssl dgst -ripemd160;}
  31. netinfo() { /sbin/ifconfig|grep "inet"|grep -v "inet6"|awk '{print $1" "$2" "$3" "$4}'|grep -v "127.0.0.1";}
  32.  
  33. ################GENERIC ALIASES
  34. alias 400='chmod 400'
  35. alias 600='chmod 600'
  36. alias 644='chmod 644'
  37. alias 700='chmod 700'    
  38. alias 755='chmod 755'
  39. alias 777='chmod 777'
  40. alias c='cp -i'
  41. alias curl='curl -O -A ""Mozilla/4.0"" --compressed --connect-timeout 5 '
  42. alias cx='cd ..'
  43. alias e='emacs -nw'
  44. alias emacs='emacs -nw'
  45. alias encrypt='openssl enc -whirlpool -a -salt -in'
  46. alias decrypt='openssl enc -whirlpool -d -salt -in'
  47. alias m='mv -i'
  48. alias mountedinfo='df -hT'
  49. alias openports='netstat -nape --inet'
  50. alias google='ping -c 10240000 google.com'
  51. alias psa='ps axo "user,pid,ppid,%cpu,%mem,tty,stime,state,command"'
  52. alias px='psa | grep -v "grep" | grep'
  53. alias r='rm -i'
  54. alias rm='rm -i'
  55. alias rmdir='rm -rfi'
  56. alias s='ssh'
  57. alias sc='scp -p'
  58. alias scp='scp -p'
  59. alias file_cat_no_comments="sed -e '/^#/d' $1 | more < "
  60. alias files_find_symlinks='find ./ -type l -exec ls -l {} \;'
  61. alias files_find_executable='find ./ -type f -perm -o+rx -exec ls -ld '{}' \;'
  62. alias files_remove_all_matching='echo -n "filename match to remove [rm -i]: " && read f; find ./ -name ${f} -exec rm -i {} \;'
  63. alias files_FORCE_remove_all_matching='echo -n "filename match to [rm -rf]: " && read f; find ./ -name ${f} -exec rm -rf {} \;'
  64. alias files_size_order_topten='du -a ./ | sort -n -r | head -n 10'
  65. alias files_size_order_all='du -a ./ | sort -n -r'
  66. alias files_type_summary='for t in files links directories; do echo `find . -type ${t:0:1} | wc -l` $t; done 2> /dev/null'
  67. alias find_file_name='find ./ -name'
  68. alias wg='wget --server-response --progress=bar'
  69. alias wget='wget --server-response --progress=bar'
  70. ################OS-SPECIFIC
  71. OSNAME=`uname`
  72. if [ "$OSNAME" = "Linux" ]; then
  73.     alias px='psa | grep -v "grep" | grep'
  74.     alias d='du --max-depth=1'
  75.     alias df='df -T'
  76.     alias ls='ls --color=auto'
  77.     alias l='ls -l --color=auto'
  78.     alias ll='ls -al --color=auto'
  79.     alias llh='ls -alh --color=auto'        
  80.     alias lls='ls -lSr' #sort by size
  81.     alias llsh='ls -lSrh' #sort by size
  82.     alias md5str='unset HISTFILE && echo -n "str: " && read x && echo -n "$x" | md5sum'
  83.     if [ -e /etc/redhat-release ]; then
  84.         alias pkg_add='sudo yum install'
  85.         alias pkg_search='yum search'
  86.         alias pkg_remove='sudo yum remove'
  87.     fi
  88.     if [ -e /etc/debian_version ]; then
  89.         alias pkg_add='sudo apt-get install'
  90.         alias pkg_search='apt-cache search'
  91.         alias pkg_remove='sudo apt-get remove'
  92.     fi
  93. elif [ "$OSNAME" = "SunOS" ]; then
  94.     #This assumes you have installed the "coreutils" package
  95.     #from http://www.sunfreeware.com/indexintel10.html
  96.     alias ls='/usr/local/bin/ls --color=auto'
  97.     alias l='/usr/local/bin/ls -l --color=auto'
  98.     alias ll='/usr/local/bin/ls -al --color=auto'
  99.     alias llh='/usr/local/bin/ls -alh --color=auto'
  100.     alias d='du -d 1'
  101. elif [ "$OSNAME" = "Darwin" ] || [ "$OSNAME" = "FreeBSD" ]; then
  102.     alias df='df -lh'
  103.     alias ls='ls -G'
  104.     alias l='ls -lG'
  105.     alias ll='ls -alG'
  106.     alias llh='ls -alhG'
  107.     alias lls='ls -lSr' #sort by size
  108.     alias llsh='ls -lSrh' #sort by size
  109.     alias d='du -d 1'
  110.     alias socksoff='networksetup -setsocksfirewallproxystate Airport off'
  111.     alias sockson='networksetup -setsocksfirewallproxystate Airport on'
  112.     alias bootmode_64bit='sudo systemsetup -setkernelbootarchitecture x86_64'
  113.     alias bootmode_32bit='sudo systemsetup -setkernelbootarchitecture i386'
  114.     alias md5str='unset HISTFILE && echo -n "str: " && read x && echo -n "$x" | md5'
  115. elif [ "$OSNAME" = "OpenBSD" ]; then
  116.     RELEASE=`uname -r`
  117.     ARCH=`uname -m`
  118.     export PKG_PATH="ftp://openbsd.mirrors.tds.net/pub/OpenBSD/$RELEASE/packages/$ARCH/"
  119.     portsearcher() {
  120.         if [ "$1" = "" ]; then
  121.             echo "please enter a search term"
  122.         else
  123.             cd /usr/ports
  124.             make search key=$1
  125.         fi
  126.     }    
  127.     alias pkg_search='echo -n "search: " && read x && pkg_add -i -v $x'
  128.     alias dum='du -d 1'
  129.     if [ -e /usr/local/bin/colorls ]; then
  130.         alias ls='/usr/local/bin/colorls -G'
  131.         alias l='/usr/local/bin/colorls -lG'
  132.         alias ll='/usr/local/bin/colorls -alG'
  133.         alias llh='/usr/local/bin/colorls -alhG'
  134.     else
  135.         alias ls='ls'
  136.         alias l='ls -l'
  137.         alias ll='ls -al'
  138.         alias llh='ls -alh'
  139.     fi
  140.     alias md5str='unset HISTFILE && echo -n "str: " && read x && echo -n "$x" | md5sum'
  141. fi
  142. ################PROMPT-SHIT
  143. NORMAL="\[\033[0m\]"
  144. WHITE="\[\033[0;37;40m\]"
  145. MAGENTA="\[\033[0;43;40m\]"
  146. BRIGHTBLUE="\[\033[0;31;40m\]"
  147. BRIGHTWHITE="\[\033[1;37;40m\]"
  148. BRIGHTMAGENTA="\[\033[0;33;40m\]"
  149. if [ $UID -eq 0 ] ; then
  150.    SYM='ROOT'
  151. else
  152.    SYM=''
  153. fi
  154. P1="$MAGENTA$SYM$BRIGHTMAGENTA-$BRIGHTBLUE($WHITE\u$MAGENTA@$WHITE"
  155. P2="\h$BRIGHTBLUE)$BRIGHTMAGENTA-$BRIGHTBLUE($BRIGHTWHITE\w$BRIGHTBLUE"
  156. P3=")$BRIGHTMAGENTA-$MAGENTA$SYM$NORMAL\n$MAGENTA$SYM$BRIGHTMAGENTA"
  157. P4="$WHITE>$NORMAL "
  158. PS1="$P1$P2$P3$P4"
  159.  
  160. ################COLORS
  161. BLACK='\e[0;30m'
  162. BLUE='\e[0;34m'
  163. GREEN='\e[0;32m'
  164. CYAN='\e[0;36m'
  165. RED='\e[0;31m'
  166. PURPLE='\e[0;35m'
  167. BROWN='\e[0;33m'
  168. LIGHTGRAY='\e[0;37m'
  169. DARKGRAY='\e[1;30m'
  170. LIGHTBLUE='\e[1;34m'
  171. LIGHTGREEN='\e[1;32m'
  172. LIGHTCYAN='\e[1;36m'
  173. LIGHTRED='\e[1;31m'
  174. LIGHTPURPLE='\e[1;35m'
  175. YELLOW='\e[1;33m'
  176. WHITE='\e[1;37m'
  177. NC='\e[0m'
  178. ################END
  179. if [ "$OSNAME" = "Linux" ]; then
  180.     echo -ne "${RED}Today: ${LIGHTGRAY}" && date +'%A %B %e'
  181.     echo -ne "${RED}Load: ${LIGHTGRAY}"; uptime|awk -F, '{print $4" "$5" "$6}'|awk -F: '{print $2}'
  182.     echo -ne "${RED}Uptime: ${LIGHTGRAY}"; uptime|awk -F, '{print $1}'|awk '{print $3" "$4}'
  183.     echo -ne "${RED}Networks: ${LIGHTGRAY}"; netinfo
  184.     echo -ne "${RED}Kernel: ${LIGHTGRAY}" `uname -smr`; echo ""
  185.     echo -e "${DARKGRAY}"; df -lhT
  186.  
  187. elif [ "$OSNAME" = "Darwin" ] || [ "$OSNAME" = "FreeBSD" ]; then
  188.     echo -n "Today: " && date +'%A %B %e'
  189.     echo -n "Networks: "; netinfo
  190.     echo -n "Kernel: " `uname -smr`; echo ""
  191.     echo  ""; df -lh
  192. fi