# How to : ~/.bashrc

Linux @ 30 October 2010

taken from http://doctus.org/showthread.php?t=41474

a good lesson about use of bashrc. Functions and aliases a final code snippet is here.

echo -en "\033[1;36m"
echo "       /\                     _     _ _                   "
echo "      /  \      __ _ _ __ ___| |__ | (_)_ __  _   ___  __ "
echo "     /'   \    / _\` | '__/ __| '_ \| | | '_ \| | | \ \/ / "
echo "    /_- ~ -\  | (_| | | | (__| | | | | | | | | |_| |>  <  "
echo "   /        \  \__,_|_|  \___|_| |_|_|_|_| |_|\__,_/_/\_\ "
echo "  /  _- - _ '\                                            "
echo " /_-'      '-_\                                           "
echo -en "\033[0m\n"
 
# Fortune
echo
fortune 
echo
 
# Check for an interactive session
[ -z "$PS1" ] && return
 
PS1='\[\e[0;32m\]\u\[\e[m\] \[\e[1;34m\]\w\[\e[m\] \[\e[m\] '
 
#bash completion. 
if [ -f /etc/bash_completion ]; then
    . /etc/bash_completion
fi
 
# Aliases
# General Aliases
alias fontup="sudo fc-cache -v"
alias ls="ls --color=auto"
alias reboot="sudo reboot"
alias rconf="sudo nano /etc/rc.conf"
alias shutdown="sudo shutdown -h now"
alias source="source /home/wargasm/.bashrc"
alias xorgconf="sudo nano /etc/X11/xorg.conf"
 
# Pacman Aliases
alias ins="sudo pacman -S"
alias pacclean="sudo pacman -Rs $(pacman -Qtdq)"
alias pacinfo="pacman -Qi"
alias paclocs="sudo pacman -Qs"
alias pacs="pacsearch"
alias rem="sudo pacman -R"
alias syscl="sudo pacman -Scc"
alias sync="sudo pacman -Sy"
alias sysup="sudo pacman -Syu"
 
# Yaourt Aliases
alias yains="yaourt -S"
alias yarem="yaourt -R"
alias yainfo="yaourt -Qi"
alias yaup="yaourt -Syu --aur"
 
# Functions
arsivle () {
  FILE=$1
  case $FILE in
    *.tar.bz2) shift && tar cjf $FILE $* ;;
    *.tar.gz) shift && tar czf $FILE $* ;;
    *.tar.lzma) shift && tar --lzma cf $FILE $* ;;
    *.tgz) shift && tar czf $FILE $* ;;
    *.zip) shift && zip $FILE $* ;;
    *.rar) shift && rar $FILE $* ;;
  esac
}
 
ayikla () {
   if [ -f $1 ] ; then
       case $1 in
           *.tar.bz2)   tar xvjf $1    ;;
           *.tar.gz)    tar xvzf $1    ;;
           *.bz2)       bunzip2 $1     ;;
           *.rar)       unrar x -v $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 "don't know how to extract '$1'..." ;;
       esac
   else
       echo "'$1' is not a valid file!"
   fi
}
 
pacsearch () {
       echo -e "$(pacman -Ss $@ | sed \
       -e 's#core/.*#\\033[1;31m&\\033[0;37m#g' \
       -e 's#extra/.*#\\033[0;32m&\\033[0;37m#g' \
       -e 's#community/.*#\\033[1;35m&\\033[0;37m#g' \
       -e 's#^.*/.* [0-9].*#\\033[0;36m&\\033[0;37m#g' )"
}
 
twit () {
        echo "User: "
        read user
        echo "Pass: "
        read -s pass
        echo ""
        curl -u $user:$pass -d status="$1" http://twitter.com/statuses/update.xml
}

Leave a Reply

*