# ~/.bashrc: executed by bash(1) for non-login shells. ########################################## ## ## ## .bashrc by fa, fa[at]art-core.org ## ## ## ########################################## ## 2005-06-06 ## my_version='0.36' ########################################## ## ## ## many ideas by Moshe Jacobsen ## ## (http://runslinux.net) ## ## and Emmanuel Rouat ## ## (emmanuel.rouat[at]wanadoo.fr) ## ########################################## ############################## ## aliases ## alias ls='ls -hF --color=always' alias ll='ls -Al' alias lx='ls -lXB' # sort by extension alias lk='ls -lSr' # sort by size alias lc='ls -lcr' # sort by change time alias lu='ls -lur' # sort by access time alias lr='ls -lR' # recursive ls alias lt='ls -ltr' # sort by date alias lala='ll' alias mkdir='mkdir -p' alias vi='vim' alias ci='vim' alias df='df -h' alias du='du -h' alias grep='grep --color=always' alias px='ps aux|grep' alias cp='cp -i -r' alias rm='rm -i' alias ..='cd ..' alias un='uname -a' alias die='kill -9' export TERM='xterm' export para='user@host1' export cip='user@host2' export arno='user@host3' export gondo='user@host4' alias distpara='echo "copying to paradox..." && scp ~/.bashrc ${para}:/home/user/.bashrc' alias distcip='echo "copying to cip..." && scp ~/.bashrc ${cip}:/home/user/' alias distarno='echo "copying to arnor..." && scp -P 139 ~/.bashrc ${arno}:/home/user/.bashrc' alias distgondo='echo "copying to gondor..." && scp -P 139 ~/.bashrc ${gondo}:/home/user/.bashrc' complete -W "`pear 2>&1 | awk '{ORS=" "} /[a-zA-Z-]+ / {print $1}'`" -f pear #complete -W "`apt-get 2>&1 | awk '{ORS=" "} /(^ [a-z])([a-zA-Z-]*)( - )/ {print $1}'`" -f apt-get export file_comp='/etc/bash_completion' if [ ! -e "$file_comp" ] then echo "Konnte "$file_comp" nicht finden" else source $file_comp fi bind 'set bell-style visible' # No beeping bind 'set show-all-if-ambiguous on' # Tab once for complete bind 'set visible-stats on' # Show file info in complete shopt -s cdspell #correct minor spelling errors in a cd command shopt -s cmdhist #cause multi-line commands to be appended to your bash history as a single line command set -o ignoreeof #disables the use of Ctrl-D to exit the shell ############################## ## bash colors ## BLACK="\[\033[0;30m\]" DARK_GRAY="\[\033[1;30m\]" RED="\[\033[0;31m\]" LIGHT_RED="\[\033[1;31m\]" GREEN="\[\033[0;32m\]" LIGHT_GREEN="\[\033[1;32m\]" BROWN="\[\033[0;33m\]" YELLOW="\[\033[1;33m\]" BLUE="\[\033[0;34m\]" LIGHT_BLUE="\[\033[1;34m\]" PURPLE="\[\033[0;35m\]" LIGHT_PURPLE="\[\033[1;35m\]" CYAN="\[\033[0;36m\]" LIGHT_CYAN="\[\033[1;36m\]" LIGHT_GRAY="\[\033[0;37m\]" WHITE="\[\033[1;37m\]" black='\e[0;30m' dark_gray='\e[1;30m' red='\e[0;31m' light_red='\e[1;31m' green='\e[0;32m' light_green='\e[1;32m' brown='\e[0;33m' yellow='\e[1;33m' blue='\e[0;34m' light_blue='\e[1;34m' purple='\e[0;35m' light_purple='\e[1;35m' cyan='\e[0;36m' light_cyan='\e[1;36m' light_gray='\e[0;37m' white='\e[1;37m' nocolor='\e[0m' ############################## ## Get proper hostname ## HOSTNAME=$(hostname -f 2>/dev/null || hostname) ############################## ## host-specific actions ## case $HOSTNAME in paradox*) HOST="paradox"; HC=$LIGHT_GREEN; alias dist='distcip && distarno && distgondo' ;; a1516*) HOST="arnor"; HC=$LIGHT_BLUE; alias dist='distpara && distcip && distgondo' ;; a1517*) HOST="gondor"; HC=$LIGHT_CYAN; alias dist='distpara && distcip && distarno' ;; *informatik*) HOST=`hostname`; HC=$LIGHT_BLUE; alias dist='distpara && distarno && distgondo' ;; *ifi.lmu.de*) HOST=`hostname`; HC=$LIGHT_BLUE; alias dist='distpara && distarno && distgondo' ;; valinor*) HOST="valinor"; HC=$WHITE; alias dist='distpara' ;; moria*) HOST="moria"; HC=$GREEN; alias dist='distpara' ;; *erato*) HOST="erato"; HC=$CYAN; alias dist='distpara' ;; 101) HOST="rohan"; HC=$LIGHT_BLUE; alias dist='distpara' ;; *) HOST=$HOSTNAME; HC=$LIGHT_CYAN; alias dist='distpara' ;; esac ############################## ## user-specific actions ## case $USER in root) UC=$LIGHT_RED; PR="$WHITE # "; alias update='apt-get update'; alias upgrade='apt-get upgrade'; alias install='apt-get install'; alias remove='apt-get remove'; alias clean='apt-get clean'; alias autoclean='apt-get autoclean'; alias check='apt-get check'; alias search='apt-cache search'; alias distup='apt-get dist-upgrade'; alias udb='updatedb &'; ;; user) UC=$YELLOW; PR="$LIGHT_BLUE $ $WHITE"; alias update='sudo apt-get update'; alias upgrade='sudo apt-get upgrade'; alias install='sudo apt-get install'; alias remove='sudo apt-get remove'; alias clean='sudo apt-get clean'; alias autoclean='sudo apt-get autoclean'; alias check='sudo apt-get check'; alias search='sudo apt-cache search'; alias distup='sudo apt-get dist-upgrade'; alias udb='sudo updatedb &'; alias suvi='sudo vim'; alias sutail='sudo tail'; alias sumutt='sudo mutt'; ;; user2) UC=$LIGHT_CYAN; PR="$PURPLE # $WHITE" ;; user3) UC=$LIGHT_GRAY; PR="$LIGHT_GRAY # $WHITE" ;; *) UC=$WHITE ;; esac ############################## ## functions ## function ver() { echo -e ${yellow}".bashrc by fa, version "${light_red}${my_version} >&2; } function tails() { tail -n 30 $*; } function my_ps() { ps $@ -u $USER -o pid,%cpu,%mem,bsdtime,command ; } function _exit() # function to run upon exit of shell { echo -e "${light_red}Hasta la vista, baby${nocolor}" } trap _exit EXIT # find something function ff() { find . -type f -iname '*'$*'*' -ls ; } function my_ip() # get IP adresses { MY_IP=$(/sbin/ifconfig eth0 | awk '/inet/ { print $2 } ' | sed -e s/addr://) MY_ISP=$(/sbin/ifconfig ppp0 | awk '/inet/ { print $3 } ' | sed -e s/addr://) } function ii() # get current host related info { echo -e "\nYou are logged on ${light_red}$HOST" echo -e "\nAdditionnal information:$nocolor " ; uname -a echo -e "\n${light_red}Users logged on:$nocolor " ; w -h echo -e "\n${light_red}Current date :$nocolor " ; date echo -e "\n${light_red}Machine stats :$nocolor " ; uptime echo -e "\n${light_red}Memory stats :$nocolor " ; free my_ip 2>&- ; echo -e "\n${light_red}Local IP Address :$nocolor" ; echo ${MY_IP:-"Not connected"} echo -e "\n${light_red}ISP Address :$nocolor" ; echo ${MY_ISP:-"Not connected"} echo } ############################## ## exports ## export PATH=$PATH":~/bin" export PS_STANDARD="\u@\h:\w\$ " export JOBS=${LIGHT_GRAY}"("${DARK_GRAY}$(jobs > /dev/null 2>&1; jobs 2>&1)$(IFS=""; set -- $(jobs); echo $#)"j"${LIGHT_GRAY}")" export PS1=${JOBS}${DARK_GRAY}"("${UC}"\u"${LIGHT_GRAY}"@"${HC}${HOST}${DARK_GRAY}"):("${UC}"\w"${DARK_GRAY}")"${PR} export bashcolors="$white""(""$black""black""$white"")(""$dark_gray""dark_gray""$white)($light_gray""light_gray""$white)($white""white""$white)($red""red""$white)($light_red""light_red""$white)($green""light_green""$white)($brown""brown""$white)($blue""blue""$white)($light_blue""light_blue""$white)($purple""purple""$white)($light_purple""light_purple""$white)($cyan""cyan""$white)($light_cyan""light_cyan""$white)($yellow""yellow""$white)"