post your .bashrc

Discussion in 'all things UNIX' started by iceni60, Nov 29, 2010.

Thread Status:
Not open for further replies.
  1. iceni60

    iceni60 ( ^o^)

    Joined:
    Jun 29, 2004
    Posts:
    5,116
    i'm still not very good at backups, i need a knew external HDD so here's a backup of my .bashrc lol

    Code:
    # There are 3 different types of shells in bash: the login shell, normal shell
    # and interactive shell. Login shells read ~/.profile and interactive shells
    # read ~/.bashrc; in our setup, /etc/profile sources ~/.bashrc - thus all
    # settings made here will also take effect in a login shell.
    #
    # NOTE: It is recommended to make language settings in ~/.profile rather than
    # here, since multilingual X sessions would not work properly if LANG is over-
    # ridden in every subshell.
    
    # Some applications read the EDITOR variable to determine your favourite text
    # editor. So uncomment the line below and enter the editor of your choice :-)
    #export EDITOR=/usr/bin/vim
    #export EDITOR=/usr/bin/mcedit
    export EDITOR=/opt/gnome/bin/gedit
    #test -s ~/.alias && . ~/.alias || true
    
    #############################################################################################
    ######################  STUFF I ADDED BELOW  ##################################################
    #############################################################################################
    
    [ -z "$PS1" ] && return
    
    # Bash completion
    if [ -f /etc/bash_completion ]; then
    	. /etc/bash_completion
    fi
    
    # Define a few Colours
    BLACK='\e[0;30m'
    BLUE='\e[0;34m'
    GREEN='\e[0;32m'
    CYAN='\e[0;36m'
    RED='\e[0;31m'
    PURPLE='\e[0;35m'
    BROWN='\e[0;33m'
    LIGHTGRAY='\e[0;37m'
    DARKGRAY='\e[1;30m'
    LIGHTBLUE='\e[1;34m'
    LIGHTGREEN='\e[1;32m'
    LIGHTCYAN='\e[1;36m'
    LIGHTRED='\e[1;31m'
    LIGHTPURPLE='\e[1;35m'
    YELLOW='\e[1;33m'
    WHITE='\e[1;37m'
    NC='\e[0m'              # No Color
    
    # check the window size after each command and, if necessary,
    # update the values of LINES and COLUMNS.
    shopt -s checkwinsize
    
    # make less more friendly for non-text input files, see lesspipe(1)
    [ -x /usr/bin/lesspipe ] && eval "$(lesspipe)"
    
    ###############
    ### aliases ###
    ###############
    
    # General
    alias df='df -h'
    alias h='history'
    alias d='cd /home/iceni60/Desktop'
    alias duck='du -skc * | sort -rn'
    alias open='gnome-open'
    alias chm='kchmviewer'
    alias which='type -all'
    alias nb='nano ~/.bashrc'
    alias update_time='sudo /usr/sbin/ntpdate pool.ntp.org'
    alias xterm="xterm -bg black -fg white -ls -j -s -sl 10000 -sb -fa DejaVu-11 -fs 11"
    
    # scanners
    alias rootkit_scan='~/scripts/rkhunter_scan.sh'
    
    # screenshots
    alias screenshot='import -window root ~/Desktop/`date +%Y%m%d%H%M`.png'
    
    # System info
    alias cpuu="ps -e -o pcpu,cpu,nice,state,cputime,args --sort pcpu | sed '/^ 0.0 /d'"
    alias memu='ps -e -o rss=,args= | sort -b -k1,1n | pr -TW$COLUMNS'
    alias pg='ps aux | grep'  #requires an argument
    
    # weather
    #alias weather='/home/iceni60/scripts/conky_scripts/weather.sh UKXX0085'
    
    ##### Weather by us zip code - Can be called two ways # weather 50315 # weather "Des Moines"
    
    weather ()
    {
    declare -a WEATHERARRAY
    WEATHERARRAY=( `lynx -dump http://google.co.uk/search?q=weather+London | grep -A 5 '^ *Weather for' | grep -v 'Add to'`)
    echo ${WEATHERARRAY[@]}
    }
    
    
    # Media
    alias ncmpc='ncmpc -cm'
    alias mplay='mplayer -idx'
    alias soma='bash /home/iceni60/bin/opera-widget-soma-fm-opera-widget'
    
    # apt
    #alias search='apt-cache search'
    #alias agi='sudo apt-get install'
    #alias agr='sudo apt-get remove'
    #alias agu='sudo apt-get update'
    #alias agg='sudo apt-get upgrade'
    #alias sources='gksudo gedit /etc/apt/sources.list'
    
    # interactive
    alias cp='cp -vi'
    alias mv='mv -vi'
    alias rm='mv --target-directory=$HOME/.Trash/'
    
    # Directory navigation aliases
    alias ..='cd ..'
    alias ...='cd ../..'
    alias ....='cd ../../..'
    alias .....='cd ../../../..'
    
    # display facts of the day
    alias today='grep -h -d skip `date +%m/%d` /home/iceni60/Ubuntu/usr/share/calendar/*'
    
    # network
    alias net1='watch --interval=2 "sudo netstat -apn -l -A inet"'
    alias net2='watch --interval=2 "sudo netstat -anp --inet --inet6"'  
    alias net3='sudo lsof -i'
    alias net4='watch --interval=2 "sudo netstat -p -e --inet --numeric-hosts"'
    alias net5='watch --interval=2 "sudo netstat -tulpan"'
    alias net6='sudo netstat -tulpan'
    alias net7='watch --interval=2 "sudo netstat -utapen"'
    alias net8='watch --interval=2 "sudo netstat -ano -l -A inet"'
    alias netl='sudo nmap -sT -O localhost' # more here http://www.redhat.com/docs/manuals/linux/RHL-9-Manual/security-guide/s1-server-ports.html
    alias ping='ping -c 10'
    alias currports='wine /home/iceni60/Desktop/Desktop_Folder/Network_Tools/currports/cports.exe'
    alias winwhois='wine /home/iceni60/Desktop/Desktop_Folder/Network_Tools/win32whois_0_9_13/win32whois.exe'
    alias xnews='wine /home/iceni60/Desktop/Desktop_Folder/Network_Tools/XNews/XNEWS.EXE'
    alias whois='whois -H'
    
    # listings
    alias ll='ls -lh'
    alias ls='ls --color=auto'
    alias lh='ls -lah'                # human readable (sizes) long and all ;-)
    alias lls='ls -l -h -g -F --color=auto'
    alias lc='ls -aCF'
    alias lsam='ls -am'               # List files horizontally.
    alias lr='ls -lR'                 # recursive.
    alias lsx='ls -ax'                # sort right to left rather then in columns.
    alias lss='ls -shAxSr'            # sort by size.
    alias lt='ls -lAtrh'              # sort by date and human readable.
    alias lm='ls -al |more'           # pipe through 'more'.
    alias lx='ls -X'                  # sort by file type.
    alias lu='ls -ul'                 # Sort files according to file-access time.
    
    # scripts
    alias calc='sh /home/iceni60/scripts/calc.sh'
    alias whatsmyip='/home/iceni60/scripts/whatsmyip.sh'
    alias unpack='/home/iceni60/scripts/unpack2dir.sh'
    alias thumbs_from_video='/home/iceni60/scripts/video_thumb_generator.sh'
    alias thumbs_jpg='/home/iceni60/scripts/generate_jpg_thumbs.sh'
    alias thumbs_png='/home/iceni60/scripts/generate_png_thumbs.sh'
    
    # chmod and permissions commands
    alias mx='chmod a+x'
    alias 000='chmod 000'
    alias 644='chmod 644'
    alias 755='chmod 755'
    alias perm='stat --printf "%a %n \n "' # requires a file name e.g. perm file
    
    # lynx web browser
    alias bbc='lynx http://news.bbc.co.uk/text_only.stm'
    alias nytimes='lynx http://nytimes.com'
    alias dmregister='lynx http://desmoinesregister.com'
    alias google='lynx http://google.co.uk'
    
    # these, below, are without colour
    #alias bbc='lynx -term=vt100 http://news.bbc.co.uk/text_only.stm'
    #alias nytimes='lynx -term=vt100 http://nytimes.com'
    #alias dmregister='lynx -term=vt100 http://desmoinesregister.com'
    #alias google='lynx -term=vt100 http://google.co.uk'
    
    # grep
    alias grep='grep --color=auto'
    alias fgrep='fgrep --color=auto'
    alias egrep='egrep --color=auto'
    
    #Extract things. Thanks to urukrama, Ubuntuforums.org	
    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
    }
    
    # WELCOME SCREEN
    #######################################################
    
    clear
    
    echo -ne "${LIGHTGREEN}" "Hello, $USER. today is, "; date
    echo -e "${WHITE}"; cal ;  
    echo -ne "${CYAN}";
    echo -ne "${LIGHTPURPLE}Sysinfo:";uptime ;echo ""
    
    
    # NOTES
    #######################################################
    
    # To temporarily bypass an alias, we preceed the command with a \  
    # EG:  the ls command is aliased, but to use the normal ls command you would 
    # type \ls 
    
    #################
    ### FUNCTIONS ###
    #################
    
    function    ff               { find . -name $@ -print; }
    
    function    rmd              { rm -fr $@; }
    
    function    osr              { shutdown -r now; }
    function    osh              { shutdown -h now; }
    
    function    mfloppy          { mount /dev/fd0 /mnt/floppy; }
    function    umfloppy         { umount /mnt/floppy; }
    
    function    mdvd             { mount -t iso9660 -o ro /dev/dvd /mnt/dvd; }
    function    umdvd            { umount /mnt/dvd; }
    
    function    mcdrom           { mount -t iso9660 -o ro /dev/cdrom /mnt/cdrom; }
    function    umcdrom          { umount /mnt/cdrom; }
    
    function    psa              { ps aux $@; }
    function    psu              { ps  ux $@; }
    
    function    dub              { du -sclb $@; }
    function    duk              { du -sclk $@; }
    function    dum              { du -sclm $@; }
    
    function    dfk              { df -PTak $@; }
    function    dfm              { df -PTam $@; }
    function    dfh              { df -PTah $@; }
    function    dfi              { df -PTai $@; }
    
    ##### Bu - Back Up a file. Usage "bu filename.txt"
    
    bu () { cp $1 ${1}-`date +%Y%m%d%H%M`.backup ; }
    
    ##### Creates an archive from given directory
    
    mktar() { tar cvf  "${1%%/}.tar"     "${1%%/}/"; }
    mktgz() { tar cvzf "${1%%/}.tar.gz"  "${1%%/}/"; }
    mktbz() { tar cvjf "${1%%/}.tar.bz2" "${1%%/}/"; }
    
    ##### Reminder for whatever whenever add a sleep option time for the popup to work
    
    function remindme()
    {
    sleep $1 && zenity --info --text "$2" &
    }
    
    ##### Find a file with a pattern in name in the local directory
    
    function my_find()
    {
        find . -type f -iname '*'$*'*' -ls ;
        }
        
    ##### Size of directories in MB
    
    function ds()
    {
        echo "size of directories in MB"
            if [ $# -lt 1 ] || [ $# -gt 2 ]; then
                    echo "you did not specify a directy, using pwd"
                            DIR=$(pwd)
                                    find $DIR -maxdepth 1 -type d -exec du -sm \{\} \; | sort -nr
                                        else
                                                find $1 -maxdepth 1 -type d -exec du -sm \{\} \; | sort -nr
                                                    fi
                                                    }
                                                    
    
    # SPECIAL FUNCTIONS
    #######################################################
    
    # clock - A bash clock that can run in your terminal window. 
    clock () 
    { 
    while true;do clear;echo "===========";date +"%r";echo "===========";sleep 1;done 
    }
    
    netinfo ()
    {
    echo "--------------- Network Information ---------------"
    /sbin/ifconfig | awk /'inet addr/ {print $2}'
    echo ""
    /sbin/ifconfig | awk /'Bcast/ {print $3}'
    echo ""
    /sbin/ifconfig | awk /'inet addr/ {print $4}'
    
    # /sbin/ifconfig | awk /'HWaddr/ {print $4,$5}'
    echo "---------------------------------------------------"
    }
    
    # Define a word - USAGE: define dog
    define ()
    {
    lynx -dump "http://www.google.com/search?hl=en&q=define%3A+${1}&btnG=Google+Search" | grep -m 3 -w "*"  | sed 's/;/ -/g' | cut -d- -f1 > /tmp/templookup.txt
    			if [[ -s  /tmp/templookup.txt ]] ;then	
    				until ! read response
    					do
    					echo "${response}"
    					done < /tmp/templookup.txt
    				else
    					echo "Sorry $USER, I can't find the term \"${1} \""				
    			fi	
    \rm -f /tmp/templookup.txt
    }
    
    
    ##### 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 /tmp/list
    }
    
    #####################################
    # ##### ENVIRONMENT VARIABLES ##### #
    #####################################
    
    declare -x HISTFILE=~/.bash_history
    declare -x HISTCONTROL=ignoredups
    declare -x HISTFILESIZE=500000
    declare -x HISTSIZE=100000
    
    
    
    
    ############################## ##################################
    # ##### PROMPT SECTION ##### ####################################
    ############################## ##################################
    
    ##PS1="\[\]\u:\w > \[\]"
    ##PS1="\[\][\[\]\u\[\]]\[\]\w > \[\]"
    #PS1="\[\][\[\]\u\[\]]\[\]\w > \[\]"
    #PS1="\[\][\[\]\[\]\u\[\]\[\]]\[\]\w > \[\]"
    ##PS1="\[\][\[\]\u\[\]]\[\]\w > \[\]"
    #PS1="\[\]\u \[\]\$\[\] \w \[\]"
    
    ###################### the above is a separate prompt which can be used instead of below. NOTE: only ONE line at a time should be uncommented. so there are 6 different prompts above!!!!!
    
    # color_name='\[\033[ color_code m\]'
    
    rgb_restore='\[\033[00m\]'
    rgb_black='\[\033[00;30m\]'
    rgb_firebrick='\[\033[00;31m\]'
    rgb_red='\[\033[01;31m\]'
    rgb_forest='\[\033[00;32m\]'
    rgb_green='\[\033[01;32m\]'
    rgb_brown='\[\033[00;33m\]'
    rgb_yellow='\[\033[01;33m\]'
    rgb_navy='\[\033[00;34m\]'
    rgb_blue='\[\033[01;34m\]'
    rgb_purple='\[\033[00;35m\]'
    rgb_magenta='\[\033[01;35m\]'
    rgb_cadet='\[\033[00;36m\]'
    rgb_cyan='\[\033[01;36m\]'
    rgb_gray='\[\033[00;37m\]'
    rgb_white='\[\033[01;37m\]'
    
    rgb_std="${rgb_white}"
    
    if [ `id -u` -eq 0 ]
    then
        rgb_usr="${rgb_red}"
    else
        rgb_usr="${rgb_green}"
    fi
    
    [ -n "$PS1" ] && PS1="${rgb_usr}`whoami`${rgb_std} \W ${rgb_usr}\\\$${rgb_restore} "
    
    unset   rgb_restore   \
            rgb_black     \
            rgb_firebrick \
            rgb_red       \
            rgb_forest    \
            rgb_green     \
            rgb_brown     \
            rgb_yellow    \
            rgb_navy      \
            rgb_blue      \
            rgb_purple    \
            rgb_magenta   \
            rgb_cadet     \
            rgb_cyan      \
            rgb_gray      \
            rgb_white     \
            rgb_std       \
            rgb_usr
    
    it would be great to add some new things if anyone has some cool stuff :cool:

    i'm going to change the reminder function to this -
    Code:
    function remindme()
    {
    sleep $1 && zenity --warning --title="REMINDER" --text="IT'S TIME!" &
    }
    atm it has two buttons though! - "OK" and "Cancel". does anyone know how to make it have just the OK button o_O thanks :)

    EDIT: just in case - to get it to work you have to add the time after you type 'remindme' i.e. 'remindme +2'
     
    Last edited: Nov 29, 2010
  2. GlobalForce

    GlobalForce Regular Poster

    Joined:
    Jun 30, 2004
    Posts:
    3,581
    Location:
    Garden State, USA
    Ice - anything here strike your fancy? Mine's :ouch: too pathetic to post. Hey, this if you've got a laptop.
     
  3. katio

    katio Guest

    The thing with aliases is, you get so used to them you can't use any system without them :p
     
  4. lotuseclat79

    lotuseclat79 Registered Member

    Joined:
    Jun 16, 2005
    Posts:
    5,390
    I keep my bash aliases in a file named appropriately, .bash_aliases which gets invoked by the following in the .bashrc file:
    Code:
    # Alias definitions.
    # You may want to put all your additions into a separate file like
    # ~/.bash_aliases, instead of adding them here directly.
    # See /usr/share/doc/bash-doc/examples in the bash-doc package.
    
    if [ -f ~/.bash_aliases ]; then
        . ~/.bash_aliases
    fi
    
    -- Tom
     
  5. Mrkvonic

    Mrkvonic Linux Systems Expert

    Joined:
    May 9, 2005
    Posts:
    10,224
    As default as it gets.
    Mrk
     
Thread Status:
Not open for further replies.
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.