Saturday, 10 September 2011

.bashrc settings

In the unlikely event of me losing my custom .bashrc settings, I shall post a copy here as a backup :-)
I tend to use whatever settings come with the distro that I'm using and bung this on the end.

NNTPSERVER='localhost' && export NNTPSERVER
#home server
ORAC='my.home.server.fqdn' && export ORAC

#BAD TYPING KLAXON.
alias suod='sudo'
alias yums='yum search'
alias yumi='sudo yum install'
alias yumsync='sudo yum distro-sync'
alias yumu='sudo yum upgrade'
alias apti='sudo apt-get install'
alias aptu='sudo apt-get upgrade'
alias sshh='gnome-terminal --profile=ssh --title="ssh home" -e "ssh $ORAC"'

alias pacu='sudo pacman -Syu'
alias paci='sudo pacman -S'


#-------------------------------------------------------------
# File functions:
#-------------------------------------------------------------


# Find a file with a pattern in file name
function ff() { find . -type f -iname '*'$*'*' -ls ; }


# Find a file with pattern $1 & Execute $2 on it:
function fe()
{ find . -type f -iname '*'${1:-}'*' -exec ${2:-file} {} \;  ; }


# Find a pattern in a set of files
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
    find . -type f -name "${2:-*}" -print0 | \
    xargs -0 egrep --color=always -sn ${case} "$1" 2>&- | more 


}
# Useful?  You bet.
function extract()
{
     if [ -f $1 ] ; then
         case $1 in
             *.tar.bz2)   tar xvjf $1     ;;
             *.tar.gz)    tar xvzf $1     ;;
             *.bz2)       bunzip2 $1      ;;
             *.rar)       unrar x $1      ;;
             *.gz)        gunzip $1       ;;
             *.tar)       tar xvf $1      ;;
             *.tbz2)      tar xvjf $1     ;;
             *.tgz)       tar xvzf $1     ;;
             *.zip)       unzip $1        ;;
             *.Z)         uncompress $1   ;;
             *.7z)        7z x $1         ;;
             *)           echo "'$1' cannot be extracted." ;;
         esac
     else
         echo "'$1' is not a valid file"
     fi
}

1 comment: