# Rod's .bashrc file (Rod Moffitt rod@rod.info) # $Id: bashrc,v 1.108 2008-12-07 21:56:32 rmoffitt Exp $ # Copyright (C) Rod Moffitt + others # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 # of the License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. if [ -e "/etc/bashrc" ]; then . /etc/bashrc fi # automatic setting of $DISPLAY (if not set already) # this works for linux - your mileage may vary... function get_xserver { case $TERM in xterm ) XSERVER=$(who am i | awk '{print $NF}' | tr -d ')''(' ) XSERVER=${XSERVER%%:*} ;; aterm | rxvt) # find some code that works here... ;; esac } if [ -z ${DISPLAY:=""} ]; then get_xserver if [[ -z ${XSERVER} || ${XSERVER} == $(hostname) || ${XSERVER} == "unix" ]]; then DISPLAY=":0.0" # display on local host else DISPLAY=${XSERVER}:0.0 # display on remote host fi fi export DISPLAY # some settings ulimit -S -c 0 # don't want any coredumps set -o notify set -o nounset #set -o noclobber # to prevent direction deleting files #set -o xtrace # useful for debuging # enable options shopt -s cdspell shopt -s cdable_vars shopt -s checkhash shopt -s checkwinsize shopt -s sourcepath shopt -s no_empty_cmd_completion # bash >= 2.04 only shopt -s cmdhist shopt -s histappend histreedit histverify shopt -s extglob # necessary for programmable completion # disable options shopt -u mailwarn unset MAILCHECK # disable shell warning of incoming mail export TIMEFORMAT=$'\nreal %3R\tuser %3U\tsys %3S\tpcpu %P\n' export HISTIGNORE="&:bg:fg:h" export HISTSIZE=1000 export HOSTFILE=$HOME/.hosts # put a list of remote hosts in ~/.hosts # color definitions red='\e[0;31m' RED='\e[1;31m' green='\e[0;32m' GREEN='\e[1;32m' blue='\e[0;34m' BLUE='\e[1;34m' cyan='\e[0;36m' CYAN='\e[1;36m' yellow='\e[0;33m' YELLOW='\e[1;33m' NC='\e[0m' # no color function xtitle { echo -en "\033]0;$*\007" } # file & strings related # find a file with a pattern in name: function ff { find . -type f -iname '*'$*'*' -ls ; } # find a file with pattern $1 in name and execute $2 on it: function fe { find . -type f -iname '*'$1'*' -exec "${2:-file}" {} \; ; } # find pattern in a set of files and highlight them function fstr { OPTIND=1 local case="" local usage="fstr: find string in files. Usage: fstr [-i] \"pattern\" [\"filename pattern\"] " while getopts :it opt do case "$opt" in i) case="-i " ;; *) echo "$usage"; return;; esac done shift $(( $OPTIND - 1 )) if [ "$#" -lt 1 ]; then echo "$usage" return; fi local SMSO=$(tput smso) local RMSO=$(tput rmso) find . -type f -name "${2:-*}" -print0 | xargs -0 grep -sn ${case} "$1" 2>&- | \ sed "s/$1/${SMSO}\0${RMSO}/gI" | more } # cut last n lines in file, 10 by default function cuttail { nlines=${2:-10} sed -n -e :a -e "1,${nlines}!{P;N;D;};N;ba" $1 } # crops off the end of stdin to the specified size when a +ve argument, # otherwise crops off the specified size from the start of a stdin for a # -ve argument, size is in bytes unless a sufix of k/K (kilobytes 1000), # m/M (megabytes 1000000), g/H (gigabytes 1000000000) is found - Rod function crop { local len=$1 local bs=1 case "$len" in *k|*K|"* k"|"* K") bs=1000 ;; *m|*M|"* m"|"* M") bs=1000000 ;; *g|*G|"* g"|"* G") bs=1000000000 ;; *) ;; esac len=$(echo $len | sed -e "s#[a-zA-Z]*##g") if [ $len -le 0 ]; then len=$(echo $len | sed -e "s#\-##g") dd bs=$bs skip=$len 2> /dev/null else dd bs=$bs count=$len 2> /dev/null fi } # randomly moves out files to specified directory from current directory # until specified size is met - Rod function purge { if [ "$#" -lt 2 ]; then echo "purge: " return; fi local mv=`which mv 2> /dev/null` if [ -n "$mv" ]; then local len=$1 local destdir=$2 local bs=1 case "$len" in *k|*K|"* k"|"* K") bs=1000 ;; *m|*M|"* m"|"* M") bs=1000000 ;; *g|*G|"* g"|"* G") bs=1000000000 ;; *) ;; esac bslen=$(echo $len | sed -e "s#[a-zA-Z]*##g") size=$(du --block-size=$bs -s | sed -e "s#\.##g") if [ $bslen -le $size ]; then files=$(find . | grep -v ^\.$) file2mv=$(randlist $files) if [ -n "$file2mv" ]; then echo "moving $file2mv to $destdir" $mv -i "$file2mv" "$destdir" purge "$len" "$destdir" fi fi fi } # crop a file without having to make an intermediate temp file - Rod function filecrop { local TMPFILE=tmp.$$ cat "$1" | crop "$2" > $TMPFILE mv -f $TMPFILE "$1" } # du will bork if presented with a very large number of files via the command # line, fdu gets around this by using find to gather the list of files, the first # parameter is the directory (. if omitted), any other parameters are passed to du function fdu { local where=. local opt= if [ "$#" -ge 1 ]; then where=$1 shift if [ "$#" -ge 1 ]; then opt=$* fi fi find $where -type f -exec du $opt \{\} \; } # clean up source files by: 1) dos2unix'ing 2) removing excess white-space # 3) converting tabs to 3 space - Rod function cleansrc { for filename; do local TMPFILE=tmp.$$ cat "$filename" | dos2unix | sed -e "s/\s*$//g;s/\t/ /g" > $TMPFILE mv -f $TMPFILE "$filename" done } # lowercase and change spaces to underscores in filenames, put '-num' # before the files to optionally remove leading '999_' numbers, put '-count' # before the files to optionally prefix the files with an increasing index - Rod function lowercase { local mv=`which mv 2> /dev/null` if [ -n "$mv" ]; then local nonum=""; local count=""; for filename; do case "$filename" in "-num" ) nonum="yes";; "-count" ) count=1;; * ) dir=$(dirname "$filename") if [ $dir == "." ]; then dir="" else dir="$dir/" fi nf=$(basename "$filename" | tr A-Z a-z | \ tr '[:cntrl:]\\\177-\377,:;()\-\[\]!@#\$%\^\?\*~{}=]' ' ' | \ sed -e 's/"//g' | sed -e "s/'//g" | sed -e 's/`//g' | sed -e s#\&#and#g | \ sed -e 's/[[:space:]]/_/g;s/_\+/_/g;s/^_//;s/_$//;s/\_\./\./g;s/\.\_/\_/g') if [ -n "$nonum" ]; then nf=$(echo $nf | sed -e 's#^[0-9]*_##g') fi if [ -n "$count" ]; then nf=$(printf "%03d_$nf" $count) count=$(($count + 1)) fi newname="${dir}${nf}" if [ "$filename" != "$newname" ]; then $mv -i -- "$filename" "$newname" echo "lowercase: $filename --> $newname" else echo "lowercase: $filename not changed" fi ;; esac done fi } # finds a free loop device and uses it - Rod function flosetup { if [ "$#" -lt 1 ]; then echo "missing file" return -1 fi local losetup=`which losetup 2> /dev/null` local lobase='/dev/loop'; local loopidx=0 local lofile=$1 if [ -z "$losetup" ]; then echo "can't find losetup" return -1 fi if [ ! -f "$lofile" ]; then echo "invalid file" return -1 fi while true do local lodev=$lobase/$loopidx; if [ ! -b $lodev ]; then echo "failed to find free loop device" return -1 fi $losetup $lodev $lofile 2> /dev/null if [ $? -eq 0 ]; then echo "$lodev" return 0 fi loopidx=$((loopidx+1)) done } # detaches a loop device based on the mount - Rod function closetup { if [ "$#" -lt 1 ]; then echo "missing mount" return -1 fi local losetup=`which losetup 2> /dev/null` local lomount=$1 if [ -z "$losetup" ]; then echo "can't find losetup" return -1 fi loopdev=`$losetup -a 2> /dev/null | grep $lomount | sed s/:.*//g` if [ -n "$loopdev" ]; then $losetup -d $loopdev 2> /dev/null else return -1 fi } # simple dump of alphanumeric characters, useful for mouse picking # passwords when it isn't safe to use the keyboard - Rod function chars { as_cr_letters='abcdefghijklmnopqrstuvwxyz' as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ' as_cr_Letters=$as_cr_letters$as_cr_LETTERS as_cr_digits='0123456789' as_cr_alnum=$as_cr_Letters$as_cr_digits echo $as_cr_alnum } # find all files under the current directory which grep the specified id3 # information, example 'id3find Trainspotting *' - Rod function id3find { local string=$1 shift local tempfile=/tmp/.id3find.$$ for file in $@ do id3info $file > $tempfile 2> /dev/null test=$(grep -i "$string" $tempfile) if [ -n "$test" ]; then echo $file; fi done rm -f $tempfile } # swap 2 filenames around function swap { local TMPFILE=tmp.$$ mv "$1" $TMPFILE mv "$2" "$1" mv $TMPFILE "$2" } # process/system related function my_ps { ps $@ -u $USER -o pid,%cpu,%mem,bsdtime,command ; } function pp { my_ps f | awk '!/awk/ && $0~var' var=${1:-".*"} ; } # get current host related info function ii { echo -e "\n${RED}You are logged on ${YELLOW}$HOSTNAME$NC as ${GREEN}$USER" echo -e "\n${RED}Additionnal information:$NC "; uname -a echo -e "\n${RED}Users logged on:$NC "; w -h echo -e "\n${RED}Current date:$NC "; date echo -e "\n${RED}Machine stats:$NC "; uptime echo -e "\n${RED}Memory stats:$NC "; free echo } # repeat n times command function repeat { local i max max=$1 shift for ((i=1; i <= max ; i++)); do eval "$@" done } # ask for confirmation function ask { echo -n "$@" '[y/n] ' read ans case "$ans" in y*|Y*) return 0 ;; *) return 1 ;; esac } # cool little function to prevent 'rm * .txt' when you meant 'rm *.txt', # tcsh beats bash in only this feature, now bash has it as well! - Rod function rmstar { set +f # re-enable globbing local oldargs=$@ # cache command line local rm=`which rm 2> /dev/null` local skipdel=0 if [ $# -gt 0 ]; then local rmstarfound=0 # search for a '*' until [ -z "$1" ]; do case "$1" in "*") rmstarfound=1; break;; *) ;; esac shift done # if a '*' was found prompt for confirmation if [ $rmstarfound -eq 1 ] then ask "Do you really want to delete all files?" if [ "$?" -eq 1 ] then skipdel=1 fi fi fi if [ $skipdel -eq 0 ]; then $rm $oldargs fi unset IFS } # need to temporarily disable globbing to allow re-running of 'rm' # with the string asis - Rod alias rm="IFS='^'; set -f; rmstar" # clean up a path, removing excess forward slashes - Rod function cleanpath { echo $1 | sed -e "s#//*#/#g" -e 's#/$##g' -e 's#/:#:#g' } # nice routine to manage paths, first argument is the command: # to either "insert" it at the beginning, "append" it to the end, # "remove" the entry, all operating with the second argumemt, or # any other command string to show the current path - Rod function path { dir=$(cleanpath "$2") PATH=$(cleanpath "$PATH" | sed -e "s/^/:/" -e "s/$/:/" \ -e "s#:$dir:#:#g" -e "s/^://" -e "s/:$//") case "$1" in i* ) PATH=$2:$PATH ;; a* ) PATH=$PATH:$2 ;; r* ) ;; * ) echo -e ${PATH//:/\\n} ;; esac } # echo text taken from stdin using the color specified as the argument # which must be listed under 'color definitions' above - Rod function color { eval col=\$$1 echo -ne $col cat /dev/stdin echo -ne "$NC" } # outputs data in colon-separated hex format - Rod function bin2hex { local hexdump=`which hexdump 2> /dev/null` if [ -z "$hexdump" ]; then echo "can't find hexdump" else $hexdump -ve '1/1 "%02x:"' | sed s#:\$#\\n# fi } # outputs data in hex format, optionally limits length to # specified number of hex chars - Rod function bin2nhex { local hexdump=`which hexdump 2> /dev/null` if [ -z "$hexdump" ]; then echo "can't find hexdump" else local data=$($hexdump -ve '1/1 "%02x"' | sed s#\$#\\n#) if [ "$#" -eq 1 ]; then data=$(echo $data | head -c $1) fi echo $data fi } # outputs data in C friendly char array hex format - Rod function bin2chex { local hexdump=`which hexdump 2> /dev/null` if [ -z "$hexdump" ]; then echo "can't find hexdump" else bin2hex | sed -e "s#^#const unsigned char myarray\[\] = { 0x#;s#:#, 0x#g;s#\$# };#" fi } # for every file under a directory create a single line with # an MD5 hash and the file name converted so it can be # sorted and easily compared no matter what system it is on function md5dir { local md5deep=`which md5deep 2> /dev/null` if [ -z "$md5deep" ] then echo "can't find md5deep" elif [ $# -ne 1 ]; then echo "usage: md5dir " else $md5deep -lr ${1} | sed s#${1}## | tr -d [:punct:][:blank:] | sort -df fi } # uses md5dir to provide a single hash of a directory function md5dirsum { local md5deep=`which md5deep 2> /dev/null` if [ -z "$md5deep" ] then echo "can't find md5deep" elif [ $# -ne 1 ]; then echo "usage: md5dirsum " else md5dir "${1}" | $md5deep | sed "s#-#${1}#" fi } # get a random number, between 0 and the argument-1 - Rod function rand { local uuencode=`which uuencode 2> /dev/null` if [ $# -lt 1 ]; then echo "usage: rand " elif [ ! -r "/dev/urandom" ] || [ -z "$uuencode" ]; then echo "can't find /dev/urandom and/or uuencode" elif [ $1 -gt 0 ]; then # get some real entropy RANDOM=$(head -c 20 /dev/urandom \ | $uuencode - | head -n 2 | tail -n 1 \ | sed -e "s#[^0-9]*##g" | tail -c 5) # because of integer rounding larger numbers cause overflow on results echo $(($RANDOM/(32768/$1))) else echo "invalid ceiling value" fi } # select randomly from a argument - Rod function randlist { if [ $# -gt 0 ]; then local index=$(rand $#) shift $index echo $1 fi } # outputs a specific amount of random data - Rod function randdata { if [ $# -lt 1 ]; then echo "how much random data?" elif [ $1 -gt 0 ]; then head -c $1 /dev/urandom else echo "invalid length" fi } # outputs a random password by piping /dev/urandom into uuencode, since not all # password based systems allow non-alphanumerics they are filtered out, takes a # single parameter which is the number of characters - Rod function randpw { local uuencode=`which uuencode 2> /dev/null` if [ $# -lt 1 ]; then echo "what length?" elif [ -z "$uuencode" ]; then echo "can't find uuencode" elif [ $1 -gt 0 ]; then local testlen=0 local outlen=$1 local pw="" while [ $testlen -lt $outlen ]; do # get random data 32 bytes at a time from /dev/urandom local in=$(head -c 32 $inlen /dev/urandom | $uuencode -m -) in=$(echo "$in" | head -n 2 | tail -n 1) pw=$(echo "$pw$in" | sed 's#[=+/]*##g') testlen=$(echo $pw | wc -c) done pw=$(echo "$pw" | head -c $outlen) echo "$pw" else echo "invalid length" fi } # set the shell prompt function setprompt { _getpwd() { WHEREAMI=$PWD } PROMPT_COMMAND=_getpwd case $TERM in *term | rxvt | linux ) PS1="\[${CYAN}\]\u \h:\[${GREEN}\]\$WHEREAMI\[${NC}\] ";; *screen* ) # for screen we append the window # after the username PS1="\[${CYAN}\]\u:$WINDOW \h:\[${GREEN}\]\$WHEREAMI\[${NC}\] ";; * ) PS1="\u \h:\$WHEREAMI ";; esac } # startup message, looks best on a dark background function entry { echo -e "\n${CYAN}bash ${RED}${BASH_VERSION%.*}${CYAN} - DISPLAY ${RED}$DISPLAY${NC}" date echo local fortune=`which fortune 2> /dev/null` if [ -n "$fortune" ]; then $fortune -s fi } # exit message function _exit { echo -e "${RED}exiting bash${NC}" } # programmable completion, requires bash 2.05 or later, most are # taken from the bash 2.05 documentation and from Ian McDonalds # 'Bash completion' package (http://www.caliban.org/bash/index.shtml#completion) if [ "${BASH_VERSION%.*}" \< "2.05" ]; then echo "programmable completion disbaled, version 2.05 or greater is needed" else shopt -s extglob # necessary set +o nounset # otherwise some completions will fail complete -A hostname rsh rcp ssh telnet rlogin r ftp ping disk vncviewer complete -A export printenv complete -A variable export local readonly unset complete -A enabled builtin complete -A alias alias unalias complete -A function function complete -A user su mail finger complete -A helptopic help # currently same as builtins complete -A shopt shopt complete -A stopped -P '%' bg complete -A job -P '%' fg jobs disown complete -A directory mkdir rmdir complete -A directory -o default cd complete -d -f -A hostname scp # compression complete -f -o default -X '*.+(zip|ZIP)' zip complete -f -o default -X '!*.+(zip|ZIP)' unzip complete -f -o default -X '*.+(z|Z)' compress complete -f -o default -X '!*.+(z|Z)' uncompress complete -f -o default -X '*.+(gz|GZ)' gzip complete -f -o default -X '!*.+(gz|GZ)' gunzip complete -f -o default -X '*.+(bz2|BZ2)' bzip2 complete -f -o default -X '!*.+(bz2|BZ2)' bunzip2 complete -f -o default -X '!*.+(bz2|BZ2)' bzcat # postscript, pdf, dvi... complete -f -o default -X '!*.ps' gs ghostview ps2pdf ps2ascii complete -f -o default -X '!*.dvi' dvips dvipdf xdvi dviselect dvitype complete -f -o default -X '!*.pdf' acroread pdf2ps complete -f -o default -X '!*.+(pdf|ps)' gv complete -f -o default -X '!*.texi*' makeinfo texi2dvi texi2html texi2pdf complete -f -o default -X '!*.tex' tex latex slitex complete -f -o default -X '!*.lyx' lyx complete -f -o default -X '!*.+(htm*|HTM*)' lynx html2ps # multimedia complete -f -o default -X '!*.+(jp*g|gif|xpm|png|bmp)' xv gimp complete -f -o default -X '!*.+(mp3|MP3)' mpg123 mpg321 complete -f -o default -X '!*.+(ogg|OGG)' ogg123 # programming languages complete -f -o default -X '!*.pl' perl perl5 # this is a 'universal' completion function - it works when commands have # a so-called 'long options' mode , ie: 'ls --all' instead of 'ls -a' _get_longopts() { $1 --help | sed -e '/--/!d' -e 's/.*--\([^[:space:].,]*\).*/--\1/'| \ grep ^"$2" |sort -u ; } _longopts_func() { case "${2:-*}" in -*) ;; *) return ;; esac case "$1" in \~*) eval cmd="$1" ;; *) cmd="$1" ;; esac COMPREPLY=( $(_get_longopts ${1} ${2} ) ) } complete -o default -F _longopts_func configure bash complete -o default -F _longopts_func wget id info a2ps ls recode _cvs() { local cur prev COMPREPLY=() cur=${COMP_WORDS[COMP_CWORD]} prev=${COMP_WORDS[COMP_CWORD-1]} if [ $COMP_CWORD -eq 1 ] || [ "${prev:0:1}" = "-" ]; then # in the latest version of bash this seems to no longer work: #COMPREPLY=( $( compgen -W 'add admin checkout commit diff \ #export history import log rdiff release remove rtag status \ #tag update' $cur )) # instead fall back to tried and tested sed/grep! - Rod COMPREPLY=( $( echo 'add admin checkout commit diff \ export history import log rdiff release remove rtag status \ tag update' | sed -e 's/[[:space:]]/\n/g' | grep $cur )) else COMPREPLY=( $( compgen -f $cur )) fi return 0 } complete -d -f -F _cvs cvs _killall() { local prev cur=${COMP_WORDS[COMP_CWORD]} COMPREPLY=() # get a list of processes (the first sed evaluation # takes care of swapped out processes, the second # takes care of getting the basename of the process) COMPREPLY=( $( ps -u $USER -o comm | \ sed -e '1,1d' -e 's#[]\[]##g' -e 's#^.*/##'| \ awk '{if ($0 ~ /^'$cur'/) print $0}' )) return 0 } complete -F _killall killall killps # a meta-command completion function for commands like sudo(8), which need to # first complete on a command, then complete according to that command's own # completion definition - currently not quite foolproof (e.g. mount and umount # don't work properly), but still quite useful - By Ian McDonald _my_command() { local cur func cline cspec COMPREPLY=() cur=${COMP_WORDS[COMP_CWORD]} if [ $COMP_CWORD = 1 ]; then COMPREPLY=( $( compgen -c $cur ) ) elif complete -p ${COMP_WORDS[1]} &>/dev/null; then cspec=$( complete -p ${COMP_WORDS[1]} ) if [ "${cspec%%-F *}" != "${cspec}" ]; then # complete -F # # COMP_CWORD and COMP_WORDS() are not read-only, # so we can set them before handing off to regular # completion routine # set current token number to 1 less than now COMP_CWORD=$(( $COMP_CWORD - 1 )) # get function name func=${cspec#*-F } func=${func%% *} # get current command line minus initial command cline="${COMP_LINE#$1 }" # split current command line tokens into array COMP_WORDS=( $cline ) $func $cline elif [ "${cspec#*-[abcdefgjkvu]}" != "" ]; then # complete -[abcdefgjkvu] #func=$( echo $cspec | sed -e 's/^.*\(-[abcdefgjkvu]\).*$/\1/' ) func=$( echo $cspec | sed -e 's/^complete//' -e 's/[^ ]*$//' ) COMPREPLY=( $( eval compgen $func $cur ) ) elif [ "${cspec#*-A}" != "$cspec" ]; then # complete -A func=${cspec#*-A } func=${func%% *} COMPREPLY=( $( compgen -A $func $cur ) ) fi else COMPREPLY=( $( compgen -f $cur ) ) fi } complete -o default -F _my_command nohup exec eval trace truss strace sotruss gdb complete -o default -F _my_command command type which man nice fi # show the prompt setprompt # startup message - skip on login or will mess scp, etc. if [ $SHLVL -ne "1" ]; then entry fi # exit message - same rule applies if [ $SHLVL -ne "1" ]; then trap _exit EXIT fi # tailoring 'less' lesspipepath=`which lesspipe.sh 2> /dev/null` if [ -n "$lesspipepath" ]; then export LESSOPEN="|$lesspipepath %s 2>&-" fi # works nice with a dark background export LS_COLORS='no=00:fi=00:di=01;36:ln=01;33:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=07;37:ex=01;32:*.tar=01;31:*.tgz=01;31:*.arj=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=01;35:*.jpeg=01;35:*.gif=01;35:*.bmp=01;35:*.pbm=01;35:*.pgm=01;35:*.ppm=01;35:*.tga=01;35:*.xbm=01;35:*.xpm=01;35:*.tif=01;35:*.tiff=01;35:*.png=01;35:*.mpg=01;35:*.mpeg=01;35:*.avi=01;35:*.fli=01;35:*.gl=01;35:*.dl=01;35:*.xcf=01;35:*.xwd=01;35:*.ogg=01;35:*.mp3=01;35:*.wav=01;35:'; # useful aliases alias mkdir='mkdir -p' # filter existing parent dir errors and create parent dirs as needed alias pwd='pwd -P' # make builtin pwd always show physical path alias more='less' export PAGER=less export LESSCHARSET='latin1' export LESS='-i -N -z-4 -g -e -M -X -F -R -P%t?f%f' export EDITOR='vim' alias vless='vim -u /usr/share/vim/vimcurrent/macros/less.vim' alias h='history' # yes, I am so lazy! alias j='jobs -l' alias ..='cd ..' # in case a which is installed that displays the entire path on failures # direct the stderr to /dev/null alias which='which 2> /dev/null' # the 'ls' family (this assumes you use the GNU ls) alias ls='ls --color' # add colors for filetype recognition alias ll='ls -l' alias tree='tree -Csu' # nice alternative to 'ls' alias grep='grep --color' # spelling typos alias moer='more' alias moew='more' alias Grep='grep' alias More='more' alias kk='ll' alias dc='cd' # umask for security umask 022 # gotta ~/bin? if [ -d "${HOME}/bin" ] && [ -r "${HOME}/bin" ] && [ -x "${HOME}/bin" ]; then path insert $HOME/bin fi # display a nice login banner if [ -t 0 ]; then linux_logo=`which linux_logo 2> /dev/null` if [ -n "$linux_logo" ]; then myhn=`hostname -f | tr "[a-z]" "[A-Z]"` $linux_logo -c -t $myhn -F \ "#O Version #V\nCompiled #C\nCPU: #M #X #T (#B BMIPs)\nRAM: #R\n\n#U\n#L\n\nWelcome to #E\n" fi fi # source any extra configs if [ -e "${HOME}/.bash_priv" ]; then . ${HOME}/.bash_priv fi