# stef's bashrc file, http://www.bigpointyteeth.se/ # $Id: .bashrc,v 0.17 2009/12/07 18:43:20 stef Exp stef $ # only run if we're interactive test -z "$PS1" && return PATH=$HOME/bin:/bin:/sbin:/usr/bin:/usr/sbin:/usr/X11R6/bin:/usr/local/bin:/usr/local/sbin:/usr/games:/usr/share/texmf/bin; export PATH VISUAL='/usr/bin/vim'; export VISUAL EDITOR='/usr/bin/vim'; export EDITOR PAGER='/usr/bin/less'; export PAGER LS_COLORS='no=00:fi=00:di=01;34:ln=01;36:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=40;31;01:su=37;41:sg=30;43:tw=30;42:ow=34;42:st=37;44:ex=01;32:*.tar=01;31:*.tgz=01;31:*.arj=01;31:*.rar=01;31:*.taz=01;31:*.lzh=01;31:*.zip=01;31:*.z=01;31:*.Z=01;31:*.gz=01;31:*.bz2=01;31:*.deb=01;31:*.rpm=01;31:*.jar=01;31:*.jpg=0;35:*.jpeg=0;35:*.gif=0;35:*.bmp=0;35:*.pbm=0;35:*.pgm=0;35:*.ppm=0;35:*.tga=0;35:*.xbm=0;35:*.xpm=0;35:*.tif=0;35:*.tiff=0;35:*.png=0;35:*.mov=0;33:*.flv=0;33:*.m4v=0;33:*.mpg=0;33:*.wmv=0;33:*.mpeg=0;33:*.mp4=0;33:*.asf=0;33:*.avi=0;33:*.fli=0;33:*.gl=01;35:*.dl=01;35:*.flac=1;35:*.mp3=1;35:*.mpc=1;35:*.ogg=1;35:*.wav=1;35:*.pdf=01;30:*.txt=01;30:'; export LS_COLORS unset HISTFILE umask 027 set -o noclobber set -o vi # red prompt if root, green otherwise if test $(id -u) = "0"; then PS1='\[\033[1;31m\]\u \[\033[1;33m\]\h\[\033[0;36m\] \W# \[\033[00m\]' else PS1='\[\033[0;32m\]\u \[\033[1;33m\]\h\[\033[0;36m\] \W$ \[\033[00m\]' fi if test -f /etc/bash_completion; then . /etc/bash_completion fi # root's ls shows hidden files if test $(id -u) = "0"; then alias ls='ls -AF --color=auto' # show hidden files type and colour else alias ls='ls -F --color=auto' # show hidden files type and colour fi alias ll='ls -hl' # long listing with human readable size alias la='ls -a' # show hidden files alias lls='ll -S' # sort after file size alias lla='ll -ut' # show atime alias llc='ll -ct' # show ctime alias llm='ll -t' # show mtime alias lsx='ls | fgrep "*"' # list executables alias lsd='ls | fgrep "/"' # list directories alias ls.='ls -d .[-_a-zA-Z0-9]*' # list hidden files alias grep='grep --color=auto' alias fgrep='fgrep --color=auto' alias egrep='egrep --color=auto' alias ..='cd ..' # old habit alias df='df -Th' # print type and human readable sizes alias du='du -ch' # print totals and human readable sizes alias cal='cal -m' # monday is the first day of the week alias less='less -m -S' # show percent and don't wrap long lines # fat-finger-guard alias rm='rm -i' alias mv='mv -i' alias cp='cp -i' # various shortcuts alias rcslocks='rlog -L -R RCS/*' alias mplayer="mplayer -vo x11 -vf screenshot" alias shred="shred -n 3 -u -z" alias msgs='tail -n 15 /var/log/messages' alias indent='indent -i 4 -bli0 -ncs -npcs -nut' alias port='cat /usr/local/share/nmap/nmap-services | grep -i ' alias mac='cat /usr/local/share/nmap/nmap-mac-prefixes | grep -i ' alias d2h='perl -e "printf qq|%X\n|, int( shift )"' alias h2d='perl -e "printf qq|%d\n|, hex( shift )"' alias newest='ls -t | head -1' alias sortip="sort -u -n -t . -k 1,1 -k 2,2 -k 3,3 -k 4,4" alias striptags="sed 's/<[^>]*>//g'" # short version of whois swhois() { whois "$1" | egrep -i "inetnum|netname|descr|country" echo "" } # swap two file names around function swap() { local tmpfile=tmp.$$ mv "$1" $tmpfile mv "$2" "$1" mv $tmpfile "$2" } # output the current date or time function datestamp() { echo -n "$(date +'%Y-%m-%d')"; } function timestamp() { echo -n "$(date +'%H:%M:%S')"; } # repeat a command n times function repeat() { local count="$1" i; shift; for i in $(seq 1 "$count") do eval "$@"; done } # move filenames in dir to lowercase # it cannot handle spaces in filenames function lowercase() { for file in $@; do filename=${file##*/} case "$filename" in */*) dirname==${file%/*} ;; *) dirname=.;; esac nf=$(echo $filename | tr A-Z a-z) newname="${dirname}/${nf}" if test "$nf" != "$filename" then mv "$file" "$newname" echo "lowercase: $file --> $newname" else echo "lowercase: $file unchanged" fi done } # eof