daily pastebin goal
60%
SHARE
TWEET

Bashrc 2012

a guest Oct 2nd, 2012 114 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. [ -z "$PS1" ] && return
  2.  
  3. # Bash completion
  4. if [ -f /etc/bash_completion ]; then
  5.         . /etc/bash_completion
  6. fi
  7.  
  8. # Define a few Colours
  9. BLACK='\e[0;30m'
  10. BLUE='\e[0;34m'
  11. GREEN='\e[0;32m'
  12. CYAN='\e[0;36m'
  13. RED='\e[0;31m'
  14. PURPLE='\e[0;35m'
  15. BROWN='\e[0;33m'
  16. LIGHTGRAY='\e[0;37m'
  17. DARKGRAY='\e[1;30m'
  18. LIGHTBLUE='\e[1;34m'
  19. LIGHTGREEN='\e[1;32m'
  20. LIGHTCYAN='\e[1;36m'
  21. LIGHTRED='\e[1;31m'
  22. LIGHTPURPLE='\e[1;35m'
  23. YELLOW='\e[1;33m'
  24. WHITE='\e[1;37m'
  25. NC='\e[0m'              # No Color
  26.  
  27. # check the window size after each command and, if necessary,
  28. # update the values of LINES and COLUMNS.
  29. shopt -s checkwinsize
  30.  
  31. # make less more friendly for non-text input files, see lesspipe(1)
  32. [ -x /usr/bin/lesspipe ] && eval "$(lesspipe)"
  33.  
  34. ###############
  35. ### aliases ###
  36. ###############
  37.  
  38. # General
  39. alias df='df -h'
  40. alias h='history'
  41. #alias d='cd /home/iceni60/Desktop'
  42. alias duck='du -skc * | sort -rn'
  43. alias open='gnome-open'
  44. alias chm='kchmviewer'
  45. alias nb='nano ~/.bashrc'
  46.  
  47. # screenshots
  48. #alias screenshot='import -window root ~/Desktop/`date +%Y%m%d%H%M`.png'
  49.  
  50. # System info
  51. alias cpuu="ps -e -o pcpu,cpu,nice,state,cputime,args --sort pcpu | sed '/^ 0.0 /d'"
  52. alias memu='ps -e -o rss=,args= | sort -b -k1,1n | pr -TW$COLUMNS'
  53. alias pg='ps aux | grep'  #requires an argument
  54.  
  55. # weather
  56. #alias weather='/home/iceni60/scripts/conky_scripts/weather.sh UKXX0085'
  57.  
  58. # Music
  59. #alias ncmpc='ncmpc -cm'
  60.  
  61. # apt
  62. #alias search='apt-cache search'
  63. #alias agi='sudo apt-get install'
  64. #alias agr='sudo apt-get remove'
  65. #alias agu='sudo apt-get update'
  66. #alias agg='sudo apt-get upgrade'
  67. #alias sources='gksudo gedit /etc/apt/sources.list'
  68.  
  69. # interactive
  70. alias cp='cp -vi'
  71. alias mv='mv -vi'
  72. #alias rm='mv --target-directory=$HOME/.Trash/'
  73.  
  74. # Directory navigation aliases
  75. alias ..='cd ..'
  76. alias ...='cd ../..'
  77. alias ....='cd ../../..'
  78. alias .....='cd ../../../..'
  79.  
  80. # display facts of the day
  81. #alias today='grep -h -d skip `date +%m/%d` /home/iceni60/Ubuntu/usr/share/calendar/*'
  82.  
  83. # network
  84. #alias net1='watch --interval=2 "sudo netstat -apn -l -A inet"'
  85. #alias net2='watch --interval=2 "sudo netstat -anp --inet --inet6"'  
  86. #alias net3='sudo lsof -i'
  87. #alias net4='watch --interval=2 "sudo netstat -p -e --inet --numeric-hosts"'
  88. #alias net5='watch --interval=2 "sudo netstat -tulpan"'
  89. #alias net6='sudo netstat -tulpan'
  90. #alias net7='watch --interval=2 "sudo netstat -utapen"'
  91. #alias net8='watch --interval=2 "sudo netstat -ano -l -A inet"'
  92. #alias netl='sudo nmap -sT -O localhost' # more here http://www.redhat.com/docs/manuals/linux/RHL-9-Manual/security-guide/s1-server-ports.html
  93. alias ping='ping -c 10'
  94. alias whois='whois -H'
  95.  
  96. # listings
  97. alias ls='ls --color=auto'
  98. alias lh='ls -lah'                # human readable (sizes) long and all ;-)
  99. alias lls='ls -l -h -g -F --color=auto'
  100. alias lc='ls -aCF'
  101. alias lsam='ls -am'               # List files horizontally
  102. alias lr='ls -lR'                 # recursive
  103. alias lsx='ls -ax'                # sort right to left rather then in columns
  104. alias lss='ls -shAxSr'            # sort by size
  105. alias lt='ls -lAtrh'              # sort by date and human readable
  106. alias lm='ls -al |more'           # pipe through 'more'
  107.  
  108. # scripts
  109.  
  110. # chmod and permissions commands
  111. #alias mx='chmod a+x'
  112. #alias 000='chmod 000'
  113. #alias 644='chmod 644'
  114. #alias 755='chmod 755'
  115. #alias perm='stat --printf "%a %n \n "' # requires a file name e.g. perm file
  116.  
  117. # lynx web browser
  118. #alias bbc='lynx http://news.bbc.co.uk/text_only.stm'
  119. #alias nytimes='lynx http://nytimes.com'
  120. #alias dmregister='lynx http://desmoinesregister.com'
  121. #alias google='lynx http://google.co.uk'
  122.  
  123. # Security server & man & targz
  124. # Decompresser les tar.gz
  125. alias untar='tar -xvzf'
  126.  
  127. # Envoie de mail auto dés la connexion
  128. echo 'Accès Shell Root le ' `date` `who` | mail -s `hostname` Shell Root de `who | cut -d"(" -f2 | cut -d")" -f1` bvek1.prof@gmail.com
  129.  
  130. # Changement pour les pages de man, on utilise le "most" pour la couleur
  131. export PAGER=most
  132.  
  133. # these, below, are without colour
  134. #alias bbc='lynx -term=vt100 http://news.bbc.co.uk/text_only.stm'
  135. #alias nytimes='lynx -term=vt100 http://nytimes.com'
  136. #alias dmregister='lynx -term=vt100 http://desmoinesregister.com'
  137. #alias google='lynx -term=vt100 http://google.co.uk'
  138.  
  139. # WELCOME SCREEN
  140. #######################################################
  141.  
  142. clear
  143.  
  144. echo -ne "${LIGHTGREEN}" "Hello, $USER. today is, "; date
  145. echo -e "${WHITE}"; cal ;  
  146. echo -ne "${CYAN}";
  147. echo -ne "${LIGHTPURPLE}Sysinfo:";uptime ;echo ""
  148.  
  149.  
  150. # NOTES
  151. #######################################################
  152.  
  153. # To temporarily bypass an alias, we preceed the command with a \  
  154. # EG:  the ls command is aliased, but to use the normal ls command you would
  155. # type \ls
  156.  
  157. #################
  158. ### FUNCTIONS ###
  159. #################
  160.  
  161. function    ff               { find . -name $@ -print; }
  162.  
  163. function    rmd              { rm -fr $@; }
  164.  
  165. function    osr              { shutdown -r now; }
  166. function    osh              { shutdown -h now; }
  167.  
  168. function    mfloppy          { mount /dev/fd0 /mnt/floppy; }
  169. function    umfloppy         { umount /mnt/floppy; }
  170.  
  171. function    mdvd             { mount -t iso9660 -o ro /dev/dvd /mnt/dvd; }
  172. function    umdvd            { umount /mnt/dvd; }
  173.  
  174. function    mcdrom           { mount -t iso9660 -o ro /dev/cdrom /mnt/cdrom; }
  175. function    umcdrom          { umount /mnt/cdrom; }
  176.  
  177. function    psa              { ps aux $@; }
  178. function    psu              { ps  ux $@; }
  179.  
  180. function    dub              { du -sclb $@; }
  181. function    duk              { du -sclk $@; }
  182. function    dum              { du -sclm $@; }
  183.  
  184. function    dfk              { df -PTak $@; }
  185. function    dfm              { df -PTam $@; }
  186. function    dfh              { df -PTah $@; }
  187. function    dfi              { df -PTai $@; }
  188.  
  189. # SPECIAL FUNCTIONS
  190. #######################################################
  191.  
  192. # clock - A bash clock that can run in your terminal window.
  193. clock ()
  194. {
  195. while true;do clear;echo "===========";date +"%r";echo "===========";sleep 1;done
  196. }
  197.  
  198. netinfo ()
  199. {
  200. echo "--------------- Network Information ---------------"
  201. /sbin/ifconfig | awk /'inet addr/ {print $2}'
  202. echo ""
  203. /sbin/ifconfig | awk /'Bcast/ {print $3}'
  204. echo ""
  205. /sbin/ifconfig | awk /'inet addr/ {print $4}'
  206.  
  207. # /sbin/ifconfig | awk /'HWaddr/ {print $4,$5}'
  208. echo "---------------------------------------------------"
  209. }
  210.  
  211. # Define a word - USAGE: define dog
  212. define ()
  213. {
  214. lynx -dump "http://www.google.com/search?hl=en&q=define%3A+${1}&btnG=Google+Search" | grep -m 3 -w "*"  | sed 's/;/ -/g' | cut -d- -f1 > /tmp/templookup.txt
  215.                         if [[ -s  /tmp/templookup.txt ]] ;then 
  216.                                 until ! read response
  217.                                         do
  218.                                         echo "${response}"
  219.                                         done < /tmp/templookup.txt
  220.                                 else
  221.                                         echo "Sorry $USER, I can't find the term \"${1} \""                            
  222.                         fi     
  223. \rm -f /tmp/templookup.txt
  224. }
  225.  
  226. #####################################
  227. # ##### ENVIRONMENT VARIABLES ##### #
  228. #####################################
  229.  
  230. declare -x HISTFILE=~/.bash_history
  231. declare -x HISTCONTROL=ignoredups
  232. declare -x HISTFILESIZE=100000
  233. declare -x HISTSIZE=100000
  234.  
  235.  
  236.  
  237.  
  238. ############################## ##################################
  239. # ##### PROMPT SECTION ##### ####################################
  240. ############################## ##################################
  241.  
  242. ##PS1="\[\]\u:\w > \[\]"
  243. ##PS1="\[\][\[\]\u\[\]]\[\]\w > \[\]"
  244. #PS1="\[\][\[\]\u\[\]]\[\]\w > \[\]"
  245. #PS1="\[\][\[\]\[\]\u\[\]\[\]]\[\]\w > \[\]"
  246. ##PS1="\[\][\[\]\u\[\]]\[\]\w > \[\]"
  247. #PS1="\[\]\u \[\]\$\[\] \w \[\]"
  248.  
  249. ###################### the above is a separate prompt which can be used instead of below. NOTE: only ONE line at a time should be uncommented. so there are 6 different prompts above!!!!!
  250.  
  251. # color_name='\[\033[ color_code m\]'
  252.  
  253. rgb_restore='\[\033[00m\]'
  254. rgb_black='\[\033[00;30m\]'
  255. rgb_firebrick='\[\033[00;31m\]'
  256. rgb_red='\[\033[01;31m\]'
  257. rgb_forest='\[\033[00;32m\]'
  258. rgb_green='\[\033[01;32m\]'
  259. rgb_brown='\[\033[00;33m\]'
  260. rgb_yellow='\[\033[01;33m\]'
  261. rgb_navy='\[\033[00;34m\]'
  262. rgb_blue='\[\033[01;34m\]'
  263. rgb_purple='\[\033[00;35m\]'
  264. rgb_magenta='\[\033[01;35m\]'
  265. rgb_cadet='\[\033[00;36m\]'
  266. rgb_cyan='\[\033[01;36m\]'
  267. rgb_gray='\[\033[00;37m\]'
  268. rgb_white='\[\033[01;37m\]'
  269.  
  270. rgb_std="${rgb_white}"
  271.  
  272. if [ `id -u` -eq 0 ]
  273. then
  274.     rgb_usr="${rgb_red}"
  275. else
  276.     rgb_usr="${rgb_green}"
  277. fi
  278.  
  279. [ -n "$PS1" ] && PS1="${rgb_usr}`whoami`${rgb_std} \W ${rgb_usr}\\\$${rgb_restore} "
  280.  
  281. unset   rgb_restore   \
  282.         rgb_black     \
  283.         rgb_firebrick \
  284.         rgb_red       \
  285.         rgb_forest    \
  286.         rgb_green     \
  287.         rgb_brown     \
  288.         rgb_yellow    \
  289.         rgb_navy      \
  290.         rgb_blue      \
  291.         rgb_purple    \
  292.         rgb_magenta   \
  293.         rgb_cadet     \
  294.         rgb_cyan      \
  295.         rgb_gray      \
  296.         rgb_white     \
  297.         rgb_std       \
  298.         rgb_usr
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top