Page 1 of 9 123 ... LastLast
Results 1 to 10 of 173

Thread: Show us your .bashrc!

Hybrid 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.

  2. #2
    Join Date
    Dec 2005
    Location
    Kingston, Ontario
    Beans
    1,919
    Distro
    Ubuntu 12.04 Precise Pangolin

    Re: Show us your .bashrc!

    That looks somewhat familiar.

    Code:
    ## LoKe's ~/.bashrc
    [ -z "$PS1" ] && return
    
    # Basic options
    export HISTCONTROL=ignoredups
    export COLORFGBG='default;default'
    
    shopt -s checkwinsize
    eval "$(dircolors -b /etc/dircolors)"
    
    # Aliases
    alias ls='ls -h --color=auto'
    alias ll='ls -l'
    alias la='ls -A'
    alias l='ls -CF'
    alias svim='sudo vim'
    alias h='cd'
    alias ..='cd ..'
    alias cd..='cd ..'
    alias ...='cd ../..'
    alias cim='vim'
    alias back='cd $OLDPWD'
    alias root='sudo su'
    alias runlevel='sudo /sbin/init'
    alias grep='grep --color=auto'
    alias dfh='df -h'
    alias gvim='gvim -geom 84x26'
    alias start='dbus-launch startx'
    
    # Prompt
    BGREEN='\[\033[1;32m\]'
    GREEN='\[\033[0;32m\]'
    BRED='\[\033[1;31m\]'
    RED='\[\033[0;31m\]'
    BBLUE='\[\033[1;34m\]'
    BLUE='\[\033[0;34m\]'
    NORMAL='\[\033[00m\]'
    PS1="${BLUE}(${RED}\w${BLUE}) ${NORMAL}\h ${RED}\$ ${NORMAL}"
    
    # Paths
    PATH=$PATH:${HOME}/bin:/usr/lib/wine/bin:/sbin:/usr/sbin
    export PATH=$PATH:/usr/local/bin
    export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/lib/wine/lib:/usr/local/lib
    export PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/usr/local/lib/pkgconfig
    
    # X Terminal titles
    case "$TERM" in
    xterm*|rxvt*)
    	PROMPT_COMMAND='echo -ne "\033]0;${USER}@${HOSTNAME}: ${PWD}\007"'
    	;;
    *)
    	;;
    esac
    
    # Functions
    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	;;
    			*)			echo "'$1' cannot be extracted via extract()" ;;
    		esac
    	else
    		echo "'$1' is not a valid file"
    	fi
    }
    ziprm () {
    	if [ -f $1 ] ; then
    		unzip $1
    		rm $1
    	else
    		echo "Need a valid zipfile"
    	fi
    }
    psgrep() {
    	if [ ! -z $1 ] ; then
    		echo "Grepping for processes matching $1..."
    		ps aux | grep $1 | grep -v grep
    	else
    		echo "!! Need name to grep for"
    	fi
    }
    grab() {
    	sudo chown -R ${USER} ${1:-.}
    }
    
    # Bash completion
    if [ -f /etc/bash_completion ]; then
    	. /etc/bash_completion
    fi
    
    # Locale and editor
    export EDITOR=nano
    export BROWSER="firefox '%s' &"
    +Solace @DeviantArt | Awesome Guide | Beginners Team Member
    Canadian Forces 2007-present

  3. #3
    Join Date
    Oct 2007
    Beans
    0

    Re: Show us your .bashrc!

    Quote Originally Posted by ~LoKe View Post
    Code:
    alias back='cd $OLDPWD'
    alias root='sudo su'
    you can also do:
    alias back='cd -'
    alias root='sudo -i'

  4. #4
    Join Date
    May 2007
    Location
    3-Dimensional Spacetime
    Beans
    Hidden!
    Distro
    Ubuntu Development Release

    Re: Show us your .bashrc!

    What does the .bashrc file do actually? What's its function?

  5. #5
    Join Date
    Jul 2006
    Location
    Germany
    Beans
    1,805

    Re: Show us your .bashrc!

    Quote Originally Posted by Ebuntor View Post
    What does the .bashrc file do actually? What's its function?
    It is a configuration file that is read every time that you open the terminal. As an example of its use, you can create an alias like
    Code:
    alias rm='rm -iv'
    Now, every time you use the command rm, bash will in reality execute rm -iv which means that you will be asked to confirm any removals. You will also get an output that tells you what has been done.
    Last edited by mali2297; January 27th, 2008 at 05:53 PM.

  6. #6
    Join Date
    Jul 2008
    Beans
    1,706

    Re: Show us your .bashrc!

    whats a .bashrc

  7. #7
    Join Date
    Aug 2007
    Beans
    2,132

    Re: Show us your .bashrc!

    Quote Originally Posted by Bruce M. View Post
    Nope ... But I'd fill /dev/null with Blue Jays

    I'm outta here...
    Bruce

    Oh wait ... can't leave yet ....
    The favorite and most used part of my "Alias" section:
    Code:
    # my aliases
    alias conke='(gedit ~/.startconky ~/Conky/conkymain ~/Conky/conkyforecast ~/Conky/conkyemail ~/Conky/fortune ~/Conky/scripts/SP_Forecast.py ~/Conky/scripts/EN_Forecast.py ~/Conky/scripts/mail/conkyEmail.py ~/Conky/scripts/myweather.template &)'
    alias cia='killall conky && ./.startconky'
    alias killc='killall conky'
    alias stc='~/.startconky'
    yea ... I'm a conky nut.

    Have a nice day
    Bruce
    I just use
    Code:
    alias conkyreset="killall -SIGUSR1 conky"
    Quote Originally Posted by jimi_hendrix View Post
    whats a .bashrc
    The file in your home directory that changes your Bash settings. Bash is the default shell in most Linux distros. I use Zsh.

  8. #8
    Join Date
    Sep 2007
    Beans
    Hidden!

    Re: Show us your .bashrc!

    Quote Originally Posted by cardinals_fan View Post
    I just use
    Code:
    alias conkyreset="killall -SIGUSR1 conky"
    Linux: 101 ways to do the same thing.

    That didn't work on my old P-III for some reason, so I came up with this workaround. Never thought to change it.

    Have a nice day.
    Bruce

  9. #9
    Join Date
    Sep 2007
    Beans
    Hidden!

    Re: Show us your .bashrc!

    Quote Originally Posted by jimi_hendrix View Post
    whats a .bashrc
    Type:
    [code]man bash[/bash]
    to see the manual (man)
    It the: Borne Again SHell

    Try this: Bash

    NOTE: Make a backup if you plan on changing anything in it.

    Have a nice day
    Bruce

  10. #10
    Join Date
    Jul 2008
    Beans
    1,706

    Re: Show us your .bashrc!

    so whats the point of messing with it?

Page 1 of 9 123 ... LastLast

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
  •