#######INFO######################### #.bashrc by 3nd3r on 01 July, 2010## #######Prompt####################### export PATH=$PATH:$HOME/bin:/usr/local/bin #export PS1='\[\033[1;36m\]\d\[\033[0m\]\[\033[1;36m\] \@ \[\033[0m\]\n\[\033[1;32m\]\u\[\033[0m\]\[\033[1;37m\] @ \[\033[0m\]\[\033[1;32m\]$PWD\[\033[0m\]\[\e[1;36m\] \$ ' #export PS1="┌─[\[\e[36;1m\]\u @ \[\e[32;1m\]\H\[\033[1;37m\]] \n\[\033[1;37m\]└─[\[\033[0;36m\]\w\[\033[1;37m\]]> \[\e[0m\]" #export PS1='C:${PWD//\//\\\}>' #export PS1='\[\033[1;34m\]┌─[ \[\033[0m\033[1;32m\]\u\[\033[0m\] @ \[\033[1;36m\]\h\[\033[0m\033[1;34m\] ] - [ \[\033[0m\]\t\[\033[1;34m\] ]\n\[\033[1;34m\]└─[\[\033[0m\]\w\[\033[1;34m\]]-[\[\033[0m\033[1;35m\]\$\[\033[0m\033[1;34m\]]>\[\033[0m\] ' #export PS1='\[\033[0;32m\]┌─[ \[\033[0m\033[0;32m\]\u\[\033[0m\] @ \[\033[0;36m\]\h\[\033[0m\033[0;32m\] ] - [ \[\033[0m\]\t \d\[\033[0;32m\] ] - [ \[\033[0m\]\w\[\033[0;32m\] ]\n\[\033[0;32m\]└─[\[\033[0m\033[0;32m\]\$\[\033[0m\033[0;32m\]]>\[\033[0m\] ' prompt_command () { local rts=$? local w=$(echo "${PWD/#$HOME/~}" | sed 's/.*\/\(.*\/.*\/.*\)$/\1/') # pwd max depth 3 # pwd max length L, prefix shortened pwd with m local L=30 m='<' [ ${#w} -gt $L ] && { local n=$((${#w} - $L + ${#m})) local w="\[\033[0;32m\]${m}\[\033[0;37m\]${w:$n}\[\033[0m\]" ; } \ || local w="\[\033[0;37m\]${w}\[\033[0m\]" # different colors for different return status [ $rts -eq 0 ] && \ local p="\[\033[1;30m\]>\[\033[0;32m\]>\[\033[1;32m\]>\[\033[m\]" || \ local p="\[\033[1;30m\]>\[\033[0;31m\]>\[\033[1;31m\]>\[\033[m\]" PS1="${w} ${p} " } PROMPT_COMMAND=prompt_command #######Aliases####### # Aliases if [ -f .alias ]; then . .alias fi #######Misc Options####### umask 022 set -o emacs bind 'C-u:kill-whole-line' bind 'set bell-style visible' bind 'set show-all-if-ambiguous on' bind 'set visible-stats on' if [ ! $ENV_DONE ]; then export ENV_DONE=TRUE fi if [ -z "$INPUTRC" -a ! -f "$HOME/.inputrc" ]; then INPUTRC=/etc/inputrc fi if [[ $- != *i* ]]; then # Shell is non-interactive. Be done now return fi shopt -s checkwinsize safe_term=${TERM//[^[:alnum:]]/.} # sanitize TERM if [[ -f /etc/DIR_COLORS ]]; then grep -q "^TERM ${safe_term}" /etc/DIR_COLORS && use_color=true elif dircolors --print-database | grep -q "^TERM ${safe_term}"; then use_color=true fi if [[ -f /etc/profile.d/bash-completion ]]; then ## For this to work ya must have a /etc/profile.d/bash-completion. If your on gentoo emerge app-shells/bash-completion and source /etc/profile.d/bash-completion ## app-shells/gentoo-bashcomp.If not, fucks knows. fi #######Functions####### findgrep () { # find | grep if [ $# -eq 0 ]; then echo "findgrep: No arguments entered."; return 1 else # "{.[a-zA-Z],}*" instead of "." makes the output cleaner find {.[a-zA-Z],}* -type f | xargs grep -n $* /dev/null \ 2> /dev/null fi } swap () { # swap 2 filenames around if [ $# -ne 2 ]; then echo "swap: 2 arguments needed"; return 1 fi if [ ! -e $1 ]; then echo "swap: $1 does not exist"; return 1 fi if [ ! -e $2 ]; then echo "swap: $2 does not exist"; return 1 fi local TMPFILE=tmp.$$ ; mv $1 $TMPFILE ; mv $2 $1 ; mv $TMPFILE $2 } rot13 () { # For some reason, rot13 pops up everywhere if [ $# -eq 0 ]; then tr '[a-m][n-z][A-M][N-Z]' '[n-z][a-m][N-Z][A-M]' else echo $* | tr '[a-m][n-z][A-M][N-Z]' '[n-z][a-m][N-Z][A-M]' fi } function scour() { find / -iname '*'$1'*'; } dirsize () { TotalBytes=0 for Bytes in $(ls -l | grep "^-" | awk '{ print $5 }') do let TotalBytes=$TotalBytes+$Bytes done TotalMeg=$(echo -e "scale=3 \n$TotalBytes/1048576 \nquit" | bc) echo -n "$TotalMeg" } extract () { if [ -f $1 ] ; then case $1 in *.tar.bz2) tar xjf $1 ;; *.tar.gz) tar xzf $1 ;; *.bz2) bunzip2 $1 ;; *.rar) rar x $1 ;; *.gz) gunzip $1 ;; *.tar) tar xf $1 ;; *.tbz2) tar xjf $1 ;; *.tgz) tar xzf $1 ;; *.zip) unzip $1 ;; *.Z) uncompress $1 ;; *) echo "'$1' cannot be extracted via extract()" ;; esac else echo "'$1' is not a valid file" fi } grab() { sudo chown -R ${USER} ${1:-.} } psgrep() { if [ ! -z $1 ] ; then echo "Grepping for processes matching $1..." ps aux | grep $1 | grep -v grep else echo "!! Need name to grep for" fi } #clock - A bash clock that can run in your terminal window. clock () { while true;do clear; echo “===========”; date +”%r”; echo “===========”; sleep 1; done } netinfo () { echo "--------------- Network Information ---------------" /sbin/ifconfig | awk /'inet addr/ {print $2}' echo "" /sbin/ifconfig | awk /'Bcast/ {print $3}' echo "" /sbin/ifconfig | awk /'inet addr/ {print $4}' # /sbin/ifconfig | awk /'HWaddr/ {print $4,$5}' echo "---------------------------------------------------" } spin () { echo -ne "${RED}-" echo -ne "${WHITE}\b|" echo -ne "${BLUE}\bx" sleep .02 echo -ne "${RED}\b+${NC}" } HISTFILESIZE=100000000 HISTSIZE=100000 if [ -f /etc/bash_completion ]; then . /etc/bash_completion fi encrypt () { gpg -ac –no-options "$1" } decrypt () { gpg –no-options "$" } # showip - show the current IP address if connected to the internet. # Usage: showip. # ip () { lynx -dump -hiddenlinks=ignore -nolist http://checkip.dyndns.org:8245/ | awk '{ print $4 }' | sed '/^$/d; s/^[ ]*//g; s/[ ]*$//g' } alias ls='ls --color=auto' alias nethack='nethack -dec' alias edit='vim' if [ "$TERM" = "linux" ]; then echo -en "\e]P0000000" echo -en "\e]P8555555" echo -en "\e]P1ed1b0b" echo -en "\e]P9982b2b" echo -en "\e]P26cb52c" echo -en "\e]PA89b83f" echo -en "\e]P3FFBA00" echo -en "\e]PBefef60" echo -en "\e]P4106ebd" echo -en "\e]PC2b4f98" echo -en "\e]P5bc295a" echo -en "\e]PD826ab1" echo -en "\e]P692b19e" echo -en "\e]PEa1cdcd" echo -en "\e]P7ffffff" echo -en "\e]PFdedede" clear #for background artifacting fi