Results 1 to 10 of 173

Thread: Show us your .bashrc!

Threaded View

  1. #1
    Join Date
    Jul 2006
    Beans
    1,152

    Show us your .bashrc!

    I've only recently started playing with the ~/.bashrc file and want more ideas to play with. Please share your bashrc file and show all of us what cool and handy things you can do with bash.

    Here is my bashrc:

    Code:
    # ~/.bashrc: executed by bash(1) for non-login shells.
    # see /usr/share/doc/bash/examples/startup-files (in the package bash-doc)
    # for examples
    
    # If not running interactively, don't do anything
    [ -z "$PS1" ] && return
    
    # don't put duplicate lines in the history. See bash(1) for more options
    export HISTCONTROL=ignoredups
    
    # set variable identifying the chroot you work in (used in the prompt below)
    if [ -z "$debian_chroot" ] && [ -r /etc/debian_chroot ]; then
        debian_chroot=$(cat /etc/debian_chroot)
    fi
    
    # set a fancy prompt (non-color, unless we know we "want" color)
    case "$TERM" in
    xterm-color)
        PS1='[${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\h\[\033[00m\]] \[\033[01;34m\]\w\[\033[00m\]\$ '
        ;;
    *)
        PS1='[${debian_chroot:+($debian_chroot)}\h] \w\$ '
        ;;
    esac
    
    # enable color support of ls and also add handy aliases
    if [ "$TERM" != "dumb" ]; then
        eval "`dircolors -b`"
        alias ls='ls --color=auto'
    fi
    
    # enable programmable completion features (you don't need to enable
    # this, if it's already enabled in /etc/bash.bashrc and /etc/profile
    # sources /etc/bash.bashrc).
    if [ -f /etc/bash_completion ]; then
        . /etc/bash_completion
    fi
    
    extract () {
         if [ -f $1 ] ; then
             case $1 in
                 *.tar.bz2)   tar xjf $1        ;;
                 *.tar.gz)    tar xzf $1     ;;
                 *.bz2)       bunzip2 $1       ;;
                 *.rar)       rar x $1     ;;
                 *.gz)        gunzip $1     ;;
                 *.tar)       tar xf $1        ;;
                 *.tbz2)      tar xjf $1      ;;
                 *.tgz)       tar xzf $1       ;;
                 *.zip)       unzip $1     ;;
                 *.Z)         uncompress $1  ;;
                 *.7z)        7z x $1    ;;
                 *)           echo "'$1' cannot be extracted via extract()" ;;
             esac
         else
             echo "'$1' is not a valid file"
         fi
    }
    
    #netinfo - shows network information for your system
    netinfo ()
    {
    echo "--------------- Network Information ---------------"
    /sbin/ifconfig | awk /'inet addr/ {print $2}'
    /sbin/ifconfig | awk /'Bcast/ {print $3}'
    /sbin/ifconfig | awk /'inet addr/ {print $4}'
    /sbin/ifconfig | awk /'HWaddr/ {print $4,$5}'
    myip=`lynx -dump -hiddenlinks=ignore -nolist http://checkip.dyndns.org:8245/ | sed '/^$/d; s/^[ ]*//g; s/[ ]*$//g' `
    echo "${myip}"
    echo "---------------------------------------------------"
    }
    
    #dirsize - finds directory sizes and lists them for the current directory
    dirsize ()
    {
    du -shx * .[a-zA-Z0-9_]* 2> /dev/null | \
    egrep '^ *[0-9.]*[MG]' | sort -n > /tmp/list
    egrep '^ *[0-9.]*M' /tmp/list
    egrep '^ *[0-9.]*G' /tmp/list
    rm -rf /tmp/list
    }
    
    #copy and go to dir
    cpg (){
      if [ -d "$2" ];then
        cp $1 $2 && cd $2
      else
        cp $1 $2
      fi
    }
    
    #move and go to dir
    mvg (){
      if [ -d "$2" ];then
        mv $1 $2 && cd $2
      else
        mv $1 $2
      fi
    }
    
    # Directory navigation aliases
    alias ..='cd ..'
    alias ...='cd ../..'
    alias ....='cd ../../..'
    alias .....='cd ../../../..'
    
    export OOO_FORCE_DESKTOP=gnome
    Last edited by urukrama; January 27th, 2008 at 05:03 PM.

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •