randalltux

bashrc full help

Jan 8th, 2016
180
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 8.82 KB | None | 0 0
  1. # Colors
  2. RS="\[\033[0m\]"    # reset
  3. HC="\[\033[1m\]"    # hicolor
  4. UL="\[\033[4m\]"    # underline
  5. INV="\[\033[7m\]"   # inverse background and foreground
  6. FBLK="\[\033[30m\]" # foreground black
  7. FRED="\[\033[31m\]" # foreground red
  8. FGRN="\[\033[32m\]" # foreground green
  9. FYEL="\[\033[33m\]" # foreground yellow
  10. FBLE="\[\033[34m\]" # foreground blue
  11. FMAG="\[\033[35m\]" # foreground magenta
  12. FCYN="\[\033[36m\]" # foreground cyan
  13. FWHT="\[\033[37m\]" # foreground white
  14. BBLK="\[\033[40m\]" # background black
  15. BRED="\[\033[41m\]" # background red
  16. BGRN="\[\033[42m\]" # background green
  17. BYEL="\[\033[43m\]" # background yellow
  18. BBLE="\[\033[44m\]" # background blue
  19. BMAG="\[\033[45m\]" # background magenta
  20. BCYN="\[\033[46m\]" # background cyan
  21. BWHT="\[\033[47m\]" # background white
  22.  
  23. # Dircolors
  24. eval $( dircolors -b $HOME/.LS_COLORS )
  25.  
  26. # Prompt
  27. PS1="
  28. \@ $FBLE \W $RS "
  29.  
  30. # Prompt
  31. # PS1='${debian_chroot:+($debian_chroot)} \e[01;32m\u\e[m@\e[0;36m\h\e[m \e[01;34m\w\e[m\n $ '
  32.  
  33. if [ "$TERM" = "linux" ]; then
  34.     echo -en "\e]P00a0f0d" #black
  35.     echo -en "\e]P8567366" #darkgrey
  36.     echo -en "\e]P1134f4b" #darkred
  37.     echo -en "\e]P9134f4b" #red
  38.     echo -en "\e]P2fcfefe" #darkgreen
  39.     echo -en "\e]PAfcfefe" #green
  40.     echo -en "\e]P37ea298" #brown
  41.     echo -en "\e]PB7ea298" #yellow
  42.     echo -en "\e]P41E7D77" #darkblue
  43.     echo -en "\e]PC626E68" #blue
  44.     echo -en "\e]P5134f4b" #darkmagenta
  45.     echo -en "\e]PD1D7872" #magenta
  46.     echo -en "\e]P61db5a2" #darkcyan
  47.     echo -en "\e]PE1db5a2" #cyan
  48.     echo -en "\e]P7d0d1d2" #lightgrey
  49.     echo -en "\e]PFd0d1d2" #white
  50.     clear #for background artifacting
  51. fi
  52.  
  53.  
  54. # Auto-CD
  55. shopt -s autocd
  56.  
  57. # Path
  58. if [ -d "$HOME/bin" ];
  59.     then PATH="$HOME/bin:$PATH"
  60. fi
  61.  
  62. if [ -d "$HOME/etc/windowMangler/bin" ];
  63.     then PATH="$HOME/etc/windowMangler/bin:$PATH"
  64. fi
  65.  
  66. if [ -d "$HOME/etc/windowMangler/wm" ];
  67.     then PATH="$HOME/etc/windowMangler/wm:$PATH"
  68. fi
  69.  
  70. if [ -d "/usr/local/sbin" ];
  71.     then PATH="/usr/local/sbin:$PATH"
  72. fi
  73.  
  74. if [ -d "/usr/local/bin" ];
  75.     then PATH="/usr/local/bin:$PATH"
  76. fi
  77.  
  78. if [ -d "/usr/sbin" ];
  79.     then PATH="/usr/sbin:$PATH"
  80. fi
  81.  
  82. if [ -d "/usr/bin" ];
  83.     then PATH="/usr/bin:$PATH"
  84. fi
  85.  
  86. if [ -d "/sbin" ];
  87.     then PATH="/sbin:$PATH"
  88. fi
  89.  
  90. if [ -d "$HOME/bin" ];
  91.     then PATH="$HOME/bin:$PATH"
  92. fi
  93.  
  94. # CD
  95. alias cd..='cd ..'
  96. alias ...='cd ..'
  97. alias ....='cd ../..'
  98.  
  99. # Directory
  100. alias Git='cd $HOME/Git'
  101. alias blog='cd $HOME/Git/nullrndtx.github.io'
  102. alias Project='cd $HOME/Project'
  103. alias bin='cd $HOME/bin'
  104. alias Desktop='cd ~/Desktop'
  105. alias Documents='cd ~/Documents'
  106. alias Downloads='cd ~/Downloads'
  107. alias Music='cd ~/Music'
  108. alias Pictures='cd ~/Pictures'
  109. alias Videos='cd ~/Videos'
  110.  
  111. # LS
  112. alias ls='ls --color=auto'
  113. alias ll='ls --color=auto -l -hGg'
  114. alias lsa='ls --color=auto -l -a -hGg'
  115.  
  116. # APT
  117. alias update='sudo apt-get update'
  118. alias fixInstall='sudo apt-get install -f'
  119. alias install='sudo apt-get install'
  120. alias upgrade='sudo apt-get upgrade'
  121. alias remove='sudo apt-get remove'
  122. alias purge='sudo apt-get purge'
  123. alias purgeRemove='sudo apt-get --purge remove'
  124. alias search='apt-cache search'
  125. alias policy='apt-cache policy'
  126.  
  127. # EDIT
  128. alias editDns='nano /etc/resolv.conf'
  129.  
  130. # GIT
  131. alias push='git push origin master'
  132. alias add='git add'
  133. alias status='git status'
  134. alias commit='git commit -m'
  135. alias clone='git clone'
  136.  
  137. # KEYS
  138. alias fixkey='sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys'
  139. alias autokey='sudo apt-get update 2> /tmp/keymissing; for key in $(grep "NO_PUBKEY" /tmp/keymissing |sed "s/.*NO_PUBKEY //"); do echo -e "\nProcessing key: $key"; gpg --keyserver pool.sks-keyservers.net --recv $key && gpg --export --armor $key | sudo apt-key add -; done'
  140. alias exportkey='sudo apt-key export'
  141.  
  142.  
  143. # MISC
  144. alias updateFonts='mkfontdir ~/.fonts; mkfontscale ~/.fonts; fc-cache -vf ~/.fonts; xset +fp ~/.fonts; xset fp rehash'
  145. alias compile='make; sudo make install'
  146. alias recompile='sudo make uninstall; make clean; make; sudo make install'
  147.  
  148. # Get all IPs via ifconfig
  149. function allips()
  150. {
  151. ifconfig | awk '/inet / {sub(/addr:/, "", $2); print $2}'
  152. }
  153.  
  154. # Clear iptables rules safely
  155. function clearIptables()
  156. {
  157. iptables -P INPUT ACCEPT; iptables -P FORWARD ACCEPT; iptables -P OUTPUT ACCEPT; iptables -F; iptables -X; iptables -L
  158. }
  159.  
  160. # Online check
  161. function connected() { ping -c1 -w2 google.com > /dev/null 2>&1; }
  162. function connected_() { rm -f /tmp/connect; http_proxy='http://a.b.c.d:8080' wget -q -O /tmp/connect http://www.google.com; if [[ -s /tmp/connect ]]; then return 0; else return 1; fi; }
  163.  
  164. # find an unused unprivileged TCP port
  165. function findtcp()
  166. {
  167. (netstat  -atn | awk '{printf "%s\n%s\n", $4, $4}' | grep -oE '[0-9]*$'; seq 32768 61000) | sort -n | uniq -u | head -n 1
  168. }
  169.  
  170. # Ifconfig connection check
  171. function ips()
  172. {
  173.     if [ "$OS" = "Linux" ]; then
  174.         for i in $( /sbin/ifconfig | grep ^e | awk '{print $1}' | sed 's/://' ); do echo -n "$i: ";  /sbin/ifconfig $i | perl -nle'/dr:(\S+)/ && print $1'; done
  175.     elif [ "$OS" = "Darwin" ]; then
  176.         for i in $( /sbin/ifconfig | grep ^e | awk '{print $1}' | sed 's/://' ); do echo -n "$i: ";  /sbin/ifconfig $i | perl -nle'/inet (\S+)/ && print $1'; done
  177.     fi
  178. }
  179.  
  180. # Netinfo
  181. function netinfo()
  182. {
  183. echo "--------------- Network Information ---------------"
  184. /sbin/ifconfig | awk /'inet addr/ {print $2}'
  185. /sbin/ifconfig | awk /'Bcast/ {print $3}'
  186. /sbin/ifconfig | awk /'inet addr/ {print $4}'
  187. /sbin/ifconfig | awk /'HWaddr/ {print $4,$5}'
  188. myip=`lynx -dump -hiddenlinks=ignore -nolist http://checkip.dyndns.org:8245/ | sed '/^$/d; s/^[ ]*//g; s/[ ]*$//g' `
  189. echo "${myip}"
  190. echo "---------------------------------------------------"
  191. }
  192.  
  193. # infobox
  194. function ff() { find . -type f -iname '*'$*'*' -ls ; }
  195. function bak() { cp $1 $1_`date +%Y-%m-%d_%H:%M:%S`.bak ; }
  196. function today() { echo -n "Today's date is:\n"; date +"%A, %B %-d, %Y"; }
  197. function space() { du -skh * | sort -hr ; }
  198. function dduse() { echo -e " `df -h / | grep dev | awk '{print $5}'` used -- `df -h / | grep dev | awk '{print $4}'` free"; }
  199. function mmuse() { echo -e " `free -m | grep buffers/cache | awk '{print $3}'`M used -- `free -m | grep buffers/cache | awk '{print $4}'`M free"; }
  200. function my_ps() { ps $@ -u $USER -o pid,%cpu,%mem,bsdtime,command ; }
  201. function pp() { my_ps f | awk '!/awk/ && $0~var' var=${1:-".*"} ; }
  202. function core() { cat /proc/cpuinfo | grep "model name" | cut -c14- ; }
  203. function graph() { lspci | grep -i vga | cut -d: -f3 ; }
  204. function ethcard() { lspci | grep -i ethernet | cut -d: -f3 ; }
  205. function wfcard() { lspci | grep -i network | cut -d: -f3 ; }
  206. function my_eip()
  207. {
  208.     if [ "$(cat /sys/class/net/eth0/operstate)" = "up" ] || [ "$(cat /sys/class/net/eth0/operstate)" = "up" ] || [ "$(cat /sys/class/net/wlan0/operstate)" = "up" ];then
  209.         MY_EXIP=$(wget -q -O - checkip.dyndns.org | sed -e 's/[^[:digit:]\|.]//g')
  210.     else
  211.         MY_EXIP=$(echo "not connected")
  212.     fi
  213.     # output
  214.     echo -e " $MY_EXIP"
  215. }
  216. #
  217. function ii()
  218. {
  219.     echo
  220.     echo -e ""
  221.     echo -e "${cyan}   Kali Linux InfoBox"
  222.     echo -e "   -------------------------$NC"
  223.     echo -e "${blue} agenda$NC"
  224.     echo -e " `date +'%A, %B %-d, %Y -- %I:%M %P'`"
  225.     echo -e "${blue} processor information$NC"
  226.     echo -e " `core`"
  227.     echo -e "${blue} graphic information$NC"
  228.     echo -e "`graph`"
  229.     echo -e "${blue} ethernet information$NC"
  230.     echo -e "`ethcard`"
  231.     echo -e "${blue} wireless information$NC"
  232.     echo -e "`wfcard`"
  233.     echo ""
  234.     echo -e "${yellow} kernel information$NC"
  235.     echo -e " `uname -a`"
  236.     echo -e "${yellow} machine stats$NC"
  237.     echo -e "`uptime`"
  238.     echo -e "${yellow} memory stats$NC"
  239.     echo -e "`mmuse`"
  240.     echo -e "${yellow} disk stats$NC"
  241.     echo -e "`dduse`"
  242.     echo -e "${yellow} external IP address$NC"
  243.     echo -e "`my_eip`"
  244.     echo -e ""
  245.     echo ""
  246. }
  247.  
  248. # functions
  249. function extract()
  250. {
  251.      if [ -f $1 ] ; then
  252.          case $1 in
  253.              *.tar.bz2)   tar xvjf $1     ;;
  254.              *.tar.gz)    tar xvzf $1     ;;
  255.              *.bz2)       bunzip2 $1      ;;
  256.              *.rar)       unrar x $1      ;;
  257.              *.gz)        gunzip $1       ;;
  258.              *.tar)       tar xvf $1      ;;
  259.              *.tbz2)      tar xvjf $1     ;;
  260.              *.tgz)       tar xvzf $1     ;;
  261.              *.zip)       unzip $1        ;;
  262.              *.Z)         uncompress $1   ;;
  263.              *.7z)        7z x $1         ;;
  264.              *.xz)        unxz $1         ;;
  265.              *)           echo "'$1' cannot be extracted via >extract<" ;;
  266.          esac
  267.      else
  268.          echo "'$1' is not a valid file"
  269.      fi
  270. }
  271.  
  272. # compress
  273. mktar() { tar cvf  "${1%%/}.tar"     "${1%%/}/"; }
  274. mktgz() { tar cvzf "${1%%/}.tar.gz"  "${1%%/}/"; }
  275. mktbz() { tar cvjf "${1%%/}.tar.bz2" "${1%%/}/"; }
  276. mktxz() { tar cvJf "${1%%/}.tar.xz" "${1%%/}/"; }
  277.  
  278. # export
  279. export EDITOR="vim"
  280. export BROWSER="firefox"
Advertisement
Add Comment
Please, Sign In to add comment