A configuration file for bash
# $Header: An elaborate ~/.bashrc file $ # $Author: Alexander Mikhailian$ # $Log: bash-2.05 is requred for the programmable completion to operate $ # # Source the environment variables # if [ -a $HOME/.bash_profile ] ; then source $HOME/.bash_profile fi # # Configure the command prompt # # the name of the current tty function get_tty { if [ notset.$DISPLAY == notset. ] then ttyname="$(tty | sed -e 's/.*\([0-9]\)/\1/')" fi } # truncate the $PWD function cut_pwd { newPWD="${PWD/#$HOME/~}" local pwdmaxlen=$((${COLUMNS:-80}/4)) if [ ${#newPWD} -gt $pwdmaxlen ] then newPWD=".+${newPWD: -$pwdmaxlen}" fi } # set xterm title function set_title { if [ $TERM == "xterm" ] then echo -ne "\033]0;${USER}@${HOSTNAME}:${newPWD}\007" fi } # define the content of the prompt command function prompt_command { #host_load get_tty cut_pwd set_title } # run once at atartup get_tty cut_pwd set_title # set the PROMPT_COMMAND and PS1 PROMPT_COMMAND=prompt_command PS1="\${ttyname}@\h:\${newPWD}\\$ " # # Useful file and string related functions # # find a file $1 function ff() { find . -name '*'$1'*' ; } # find a file $1 and run $2 on it function fe() { find . -name '*'$1'*' -exec $2 {} \; ; } # find a pattern $1 in files $2 function fstr() { if [ "$#" -gt 2 ] ; then echo "Usage: fstr \"pattern\" [files] " return; fi # tput works on linux but does not work e.g. on Sun OS if [ $OSTYPE == "linux-gnu" ] ; then SMSO=$(tput smso) RMSO=$(tput rmso) fi find . -type f -name "${2:-*}" -print | xargs grep -sin "$1" | \ sed "s/$1/$SMSO$1$RMSO/gI" } # # Set the aliases # # enable color support of ls and also add handy aliases eval `dircolors` alias ls='ls --color=auto ' alias ll='ls -l' # long listing alias la='ls -A' # show all files alias l='ls -CF' # file type recognition with chars alias lt='ls -ltr' # sort by date alias lk='ls -lSr' # sort by size alias lx='ls -lXB' # sort by extension alias dir='ls --color=auto --format=vertical' alias vdir='ls --color=auto --format=long' alias h='history' alias ugly='nice -n -20' alias bz='bzip2' alias wget='wget -c --tries=200' #alias man="LANG=C man" alias feh='feh -F --auto-zoom' alias mpg123='mpg123 -C -T' alias cal='cal -m' alias mplayer='mplayer -fs -zoom' # VIM for Ruby Projects alias vrp='vim +TlistOpen +"TlistAddFilesRecursive . *rb"' alias atls='atq |cut -f1|while read i; do echo -e "$i\t" `at -c $i |tail -n 2`; done|sort' # bash options # shopt -s hostcomplete # shopt -s checkwinsize # shopt -s cmdhist # Save milti-line commands on one line # - enabled by default. set -b # Report the status of terminated # background jobs immediately. shopt -s cdspell # Let shell correct minor typos. shopt -s extglob # Extended pattern matching facilities. shopt -s lithist # If cmdhist is enabled, save milti-line # commands with newlines. shopt -s histappend # Append to $HISTFILE, dont overwrite # #=- programmable completion if [ "${BASH_VERSION%.*}" \> "2.04" ]; then # uberfun debian completion if [ -r /etc/bash_completion ]; then source /etc/bash_completion fi fi