Page 16 of 18 FirstFirst ... 61415161718 LastLast
Results 151 to 160 of 173

Thread: Show us your .bashrc!

  1. #151
    Join Date
    Nov 2007
    Location
    Canada
    Beans
    34

    Re: Show us your .bashrc!

    Thanks everyone for sharing, I've learnt a lot from this thread.
    Here's mine, it's a cleaner version of this one: http://ayozone.org/2008/02/25/bash-f...d-improvments/ (my thanks to the author)

    It also shows git branches and a smiley that changes if the previous command errored. Colours are meant to match the 10.04 scheme.
    Code:
    ################################################################################
    # this is my new prompt based on: http://ayozone.org/2008/02/25/bash-fancy-prompt-and-improvments/
     
    
    function pre_prompt {
      newPWD="${PWD}"
      user="whoami"
      host=$(echo -n $HOSTNAME | sed -e "s/[\.].*//")
      datenow=$(date "+%a, %d %b %y")
      let promptsize=$(echo -n "   ${PWD}\!" \
                       | wc -c | tr -d " ")
    
      let fillsize=${COLUMNS}
      fill=""
      fullfill=""
    
      while [ "$fillsize" -gt "0" ] 
      do 
          fullfill="${fullfill}_"
          let fillsize=${fillsize}-1
      done
    
      let fillsize=${COLUMNS}-${promptsize}
      while [ "$fillsize" -gt "0" ] 
      do 
    #      fill="${fill}─"
          fill="${fill} "
          let fillsize=${fillsize}-1
      done
    
      if [ "$fillsize" -lt "0" ]
      then
          let cutt=3-${fillsize}
          newPWD="...$(echo -n $PWD | sed -e "s/\(^.\{$cutt\}\)\(.*\)/\2/")"
      fi
    }
    
    PROMPT_COMMAND=pre_prompt
    
    export black="\[\033[0;38;5;0m\]"
    export red="\[\033[0;38;5;1m\]"
    export orange="\[\033[0;38;5;130m\]"
    export green="\[\033[0;38;5;2m\]"
    export yellow="\[\033[0;38;5;3m\]"
    export blue="\[\033[0;38;5;4m\]"
    export bblue="\[\033[0;38;5;12m\]"
    export magenta="\[\033[0;38;5;55m\]"
    export cyan="\[\033[0;38;5;6m\]"
    export white="\[\033[0;38;5;7m\]"
    export coldblue="\[\033[0;38;5;33m\]"
    export smoothblue="\[\033[0;38;5;111m\]"
    export iceblue="\[\033[0;38;5;45m\]"
    export turqoise="\[\033[0;38;5;50m\]"
    export smoothgreen="\[\033[0;38;5;42m\]"
    
    export magentabld="\[\033[01;35m\]"
    export redbld="\[\033[01;31m\]"
    
    # script from http://progit.org/book/ch2-11.html for autocompletion with git
    source ~/.git-completion.bash
    
    GIT_PS1_SHOWDIRTYSTATE=true
    GIT_PS1_SHOWSTASHSTATE=true
    GIT_PS1_SHOWUNTRACKEDFILES=true
    
    git='`__git_ps1`'
    prev=$?
    
    case "$TERM" in
    xterm)
        PS1="$magentabld\${fullfill}\n$redbld\$newPWD $magentabld\${fill} \!
    $magentabld\`prev=\$?; __git_ps1; if [ \$prev = 0 ]; then echo \[\e[32m\] ^_^\[\e[0m\]; else echo \[\e[31m\] O_o\[\e[0m\]; fi\` $white"
        ;;
        *)
        PS1="\[\e]0;${debian_chroot:+($debian_chroot)}\u@\h: \w\a\]$PS1"
        ;;
    esac
    
    
    ################################################################################
    # welcome
    
    clear
    
    echo -ne "\033[01;35mSysinfo:";uptime
    uname -r
    cat /etc/issue 
    echo -ne "o hai thar $USER!  =^.^=";
    echo -ne "\n\n\033[0;38;5;7m";
    ls
    Last edited by Tekmoor; September 6th, 2010 at 03:28 AM.

  2. #152
    Join Date
    Feb 2010
    Location
    earth
    Beans
    256
    Distro
    Ubuntu 10.04 Lucid Lynx

    Re: Show us your .bashrc!

    mine.
    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
    # ... or force ignoredups and ignorespace
    HISTCONTROL=ignoredups:ignorespace
    
    # append to the history file, don't overwrite it
    shopt -s histappend
    
    # for setting history length see HISTSIZE and HISTFILESIZE in bash(1)
    HISTSIZE=1000
    HISTFILESIZE=2000
    
    # 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 "$(SHELL=/bin/sh lesspipe)"
    
    # 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) color_prompt=yes;;
    esac
    
    # uncomment for a colored prompt, if the terminal has the capability; turned
    # off by default to not distract the user: the focus in a terminal window
    # should be on the output of commands, not on the prompt
    #force_color_prompt=yes
    
    if [ -n "$force_color_prompt" ]; then
        if [ -x /usr/bin/tput ] && tput setaf 1 >&/dev/null; then
        # We have color support; assume it's compliant with Ecma-48
        # (ISO/IEC-6429). (Lack of such support is extremely rare, and such
        # a case would tend to support setf rather than setaf.)
        color_prompt=yes
        else
        color_prompt=
        fi
    fi
    
    if [ "$color_prompt" = yes ]; then
        PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ '
    else
        PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ '
    fi
    unset color_prompt force_color_prompt
    
    # If this is an xterm set the title to user@host:dir
    case "$TERM" in
    xterm*|rxvt*)
        PS1="\[\e]0;${debian_chroot:+($debian_chroot)}\u@\h: \w\a\]$PS1"
        ;;
    *)
        ;;
    esac
    
    # enable color support of ls and also add handy aliases
    if [ -x /usr/bin/dircolors ]; then
        test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolors -b)"
        alias ls='ls --color=auto'
        #alias dir='dir --color=auto'
        #alias vdir='vdir --color=auto'
    
        alias grep='grep --color=auto'
        alias fgrep='fgrep --color=auto'
        alias egrep='egrep --color=auto'
    fi
    
    # some more ls aliases
    alias ll='ls -alF'
    alias la='ls -A'
    alias l='ls -CF'
    
    # 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
    
    # 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 ] && ! shopt -oq posix; then
        . /etc/bash_completion
    fi
    
    echo "Hello, Austin." | cowsay -f tux

  3. #153
    Join Date
    Jan 2009
    Location
    Bucharest,Romania.
    Beans
    104
    Distro
    Ubuntu 13.04 Raring Ringtail

    Smile Re: Show us your .bashrc!

    Here's mine too:
    Code:
     MY BASHRC FILE ################################### MY BASHRC FILE
    
    
    
    ##### ORIGINAL CONTENT ----- ORIGINAL CONTENT ----- ORIGINAL CONTENT ----- ORIGINAL CONTENT ----- ORIGINAL CONTENT ----- ORIGINAL CONTENT ##### ORIGINAL
    
    
    
    # ~/.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
    # don't overwrite GNU Midnight Commander's setting of `ignorespace'.
    HISTCONTROL=$HISTCONTROL${HISTCONTROL+,}ignoredups
    # ... or force ignoredups and ignorespace
    HISTCONTROL=ignoreboth
    
    # append to the history file, don't overwrite it
    shopt -s histappend
    
    # for setting history length see HISTSIZE and HISTFILESIZE in bash(1)
    
    # 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 "$(SHELL=/bin/sh lesspipe)"
    
    # 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) color_prompt=yes;;
    esac
    
    # uncomment for a colored prompt, if the terminal has the capability; turned
    # off by default to not distract the user: the focus in a terminal window
    # should be on the output of commands, not on the prompt
    #force_color_prompt=yes
    
    if [ -n "$force_color_prompt" ]; then
        if [ -x /usr/bin/tput ] && tput setaf 1 >&/dev/null; then
        # We have color support; assume it's compliant with Ecma-48
        # (ISO/IEC-6429). (Lack of such support is extremely rare, and such
        # a case would tend to support setf rather than setaf.)
        color_prompt=yes
        else
        color_prompt=
        fi
    fi
    
    if [ "$color_prompt" = yes ]; then
        PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ '
    else
        PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ '
    fi
    unset color_prompt force_color_prompt
    
    # If this is an xterm set the title to user@host:dir
    case "$TERM" in
    xterm*|rxvt*)
        PS1="\[\e]0;${debian_chroot:+($debian_chroot)}\u@\h: \w\a\]$PS1"
        ;;
    *)
        ;;
    esac
    
    # enable color support of ls and also add handy aliases
    if [ -x /usr/bin/dircolors ]; then
        test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolors -b)"
        alias ls='ls --color=auto'
        #alias dir='dir --color=auto'
        #alias vdir='vdir --color=auto'
    
        alias grep='grep --color=auto'
        alias fgrep='fgrep --color=auto'
        alias egrep='egrep --color=auto'
    fi
    
    # some more ls aliases
    #alias ll='ls -l'
    #alias la='ls -A'
    #alias l='ls -CF'
    
    # 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
    
    # 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 ] && ! shopt -oq posix; then
        . /etc/bash_completion
    fi
    
    
    
    ##### CUSTOM STARTS HERE ----- CUSTOM STARTS HERE ----- CUSTOM STARTS HERE ----- CUSTOM STARTS HERE ----- CUSTOM STARTS HERE ##### CUSTOM STARTS HERE
    
    
    
    ### FUNCTIONS ### FUNCTIONS ### FUNCTIONS ### FUNCTIONS ### FUNCTIONS ### FUNCTIONS ### FUNCTIONS ### FUNCTIONS ### FUNCTIONS ### FUNCTIONS ### FUNCTIONS
    
    
    
    ##### Inserts a flag with the specified content
    
    # Usage: flag "comment"
    # If no comment, inserts the date.
    function flag(){
        if [ "$1" == "" ];
        then
            echo -e  "\e[0;31m[====== " `date +"%A %e %B %Y"`, `date +"%H"`h`date +"%M"` " ======]\e[0m"
        else
            echo -e  "\e[0;31m[====== " $@ " ======]\e[0m"
        fi
    }
    
    
    
    ##### Inserts a flag and executes the command
    
    # Example: flagcommand ls
    function flagcommand(){
        if [ "$1" == "" ];
        then
            return
        else
            flag $@
            $@
        fi
    }
    
    
    
    ##### Weather by us zip code - Can be called two ways # weather 50315 # weather "Des Moines"
    
    weather ()
    {
    declare -a WEATHERARRAY
    WEATHERARRAY=( `lynx -dump http://google.com/search?q=weather+$1 | grep -A 5 '^ *Weather for' | grep -v 'Add to'`)
    echo ${WEATHERARRAY[@]}
    }
    
    
    
    ##### Stock prices - can be called two ways. # stock novl  (this shows stock pricing)  #stock "novell"  (this way shows stock symbol for novell)
    
    stock ()
    {
    stockname=`lynx -dump http://finance.yahoo.com/q?s=${1} | grep -i ":${1})" | sed -e 's/Delayed.*$//'`
    stockadvise="${stockname} - delayed quote."
    declare -a STOCKINFO
    STOCKINFO=(` lynx -dump http://finance.yahoo.com/q?s=${1} | egrep -i "Last Trade:|Change:|52wk Range:"`)
    stockdata=`echo ${STOCKINFO[@]}`
       if [[ ${#stockname} != 0 ]] ;then
          echo "${stockadvise}"
          echo "${stockdata}"
             else
             stockname2=${1}
             lookupsymbol=`lynx -dump -nolist http://finance.yahoo.com/lookup?s="${1}" | grep -A 1 -m 1 "Portfolio" | grep -v "Portfolio" | sed 's/\(.*\)Add/\1 /'`
                if [[ ${#lookupsymbol} != 0 ]] ;then
                echo "${lookupsymbol}"
                   else
                   echo "Sorry $USER, I can not find ${1}."
                fi
       fi
    }
    
    
    
    ##### Translate a Word  - USAGE: translate house spanish  # See dictionary.com for available languages (there are many).
    
    translate ()
    {
    TRANSLATED=`lynx -dump "http://translate.reference.com/browse/${1}" | grep -i -m 1 -w "${2}:" | sed 's/^[ \t]*//;s/[ \t]*$//'`
    if [[ ${#TRANSLATED} != 0 ]] ;then
       echo "\"${1}\" in ${TRANSLATED}"
       else
       echo "Sorry, I can not translate \"${1}\" to ${2}"
    fi
    }
    
    
    
    ##### 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
    }
    
    
    
    ##### Myip - finds your current IP if your connected to the internet
    
    myip ()
    {
    lynx -dump -hiddenlinks=ignore -nolist http://checkip.dyndns.org:8245/ | awk '{ print $4 }' | sed '/^$/d; s/^[ ]*//g; s/[ ]*$//g'
    }
    
    
    
    ##### Clock - A bash clock that can run in your terminal window.
    
    clock ()
    {
    while true;do clear;echo "===========";date +"%r";echo "===========";sleep 1;done
    }
    
    
    
    ##### 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 "---------------------------------------------------"
    }
    
    
    
    ##### Shot - takes a screenshot of your current window
    
    shot ()
    {
    import -frame -strip -quality 75 "$HOME/$(date +%s).png"
    }
    
    
    
    ##### Bu - Back Up a file. Usage "bu filename.txt"
    
    bu () { cp $1 ${1}-`date +%Y%m%d%H%M`.backup ; }
    
    
    
    ##### Extract - extract most common compression types
    
    extract() {
      local e=0 i c
      for i; do
        if [[ -f $i && -r $i ]]; then
            c=''
            case $i in
              *.t@(gz|lz|xz|b@(2|z?(2))|a@(z|r?(.@(Z|bz?(2)|gz|lzma|xz)))))
                     c='bsdtar xvf' ;;
              *.7z)  c='7z x'       ;;
              *.Z)   c='uncompress' ;;
              *.bz2) c='bunzip2'    ;;
              *.exe) c='cabextract' ;;
              *.gz)  c='gunzip'     ;;
              *.rar) c='unrar x'    ;;
              *.xz)  c='unxz'       ;;
              *.zip) c='unzip'      ;;
              *)     echo "$0: cannot extract \`$i': Unrecognized file extension" >&2; e=1 ;;
            esac
            [[ $c ]] && command $c "$i"
        else
            echo "$0: cannot extract \`$i': File is unreadable" >&2; e=2
        fi
      done
      return $e
    }
    
    
    
    ##### :h gets you to the vim help menu or directly to :help wordname
    
    :h() {  vim --cmd ":silent help $@" --cmd "only"; }
    
    
    
    ##### Add color & formatting to CLI
    
    export PS1="\[\e[35;1m\]\u\[\e[0m\]\[\e[32m\]@\h\[\e[32m\]\w \[\e[33m\]\$ \[\e[0m\]"
    
    
    
    ##### Makes directory then moves into it
    
    function mkcdr {
        mkdir -p -v $1
        cd $1
    }
    
    
    
    ##### 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%%/}/"; }
    
    
    
    ##### To show Apt Log History
    
    function apt-history(){
          case "$1" in
            install)
                  cat /var/log/dpkg.log | grep 'install '
                  ;;
            upgrade|remove)
                  cat /var/log/dpkg.log | grep $1
                  ;;
            rollback)
                  cat /var/log/dpkg.log | grep upgrade | \
                      grep "$2" -A10000000 | \
                      grep "$3" -B10000000 | \
                      awk '{print $4"="$5}'
                  ;;
            *)
                  cat /var/log/dpkg.log
                  ;;
          esac
    }
    
    
    
    ##### Reminder for whatever whenever
    
    function remindme()
    {
    sleep $1 && zenity --info --text "$2" &
    }
    
    
    
    ##### Kill a process by name
    
    # Example: killps firefox-bin
    function killps()
    {
        local pid pname sig="-TERM" # default signal
        if [ "$#" -lt 1 ] || [ "$#" -gt 2 ]; then
            echo "Usage: killps [-SIGNAL] pattern"
            return;
        fi
        if [ $# = 2 ]; then sig=$1 ; fi
        for pid in $(myps | nawk '!/nawk/ && $0~pat { print $2 }' pat=${!#}) ; do
            pname=$(myps | nawk '$2~var { print $6 }' var=$pid )
            if ask "Kill process $pid <$pname> with signal $sig ? "
                then kill $sig $pid
            fi
        done
    }
    
    
    
    ##### Ask
    
    function ask()
    {
        echo -n "$@" '[y/n] ' ; read ans
        case "$ans" in
            y*|Y*) return 0 ;;
            *) return 1 ;;
        esac
    }
    
    
    
    ##### User friendly ps
    
    function psaux {
        [ $# == 1 ] && ps aux | grep $1
    }
    
    function my_ps() { ps $@ -u $USER -o pid,%cpu,%mem,bsdtime,command ; }
    
    function pp() { my_ps f | awk '!/awk/ && $0~var' var=${1:-".*"} ; }
    
    
    
    ##### Change directory and list files
    
    function cds(){
        # only change directory if a directory is specified
        [ -n "${1}" ] && cd $1
        lls
    }
    
    
    
    ##### Advanced ls function
    
    # Counts files, subdirectories and directory size and displays details
    # about files depending on the available space
    function lls () {
        # count files
        echo -n "<`find . -maxdepth 1 -mindepth 1 -type f | wc -l | tr -d '[:space:]'` files>"
        # count sub-directories
        echo -n " <`find . -maxdepth 1 -mindepth 1 -type d | wc -l | tr -d '[:space:]'` dirs/>"
        # count links
        echo -n " <`find . -maxdepth 1 -mindepth 1 -type l | wc -l | tr -d '[:space:]'` links@>"
        # total disk space used by this directory and all subdirectories
        echo " <~`du -sh . 2> /dev/null | cut -f1`>"
        ROWS=`stty size | cut -d' ' -f1`
        FILES=`find . -maxdepth 1 -mindepth 1 |
        wc -l | tr -d '[:space:]'`
        # if the terminal has enough lines, do a long listing
        if [ `expr "${ROWS}" - 6` -lt "${FILES}" ]; then
            ls
        else
            ls -hlAF --full-time
        fi
    }
    
    
    
    ##### Find a file with a pattern in name in the local directory
    
    function fp()
    {
        find . -type f -iname '*'$*'*' -ls ;
    }
    
    
    
    ##### Find a file with pattern $1 in name and Execute $2 on it
    
    function fe() { find . -type f -iname '*'$1'*' -exec "${2:-file}" {} \;  ; }
    
    
    
    ##### Find pattern in a set of files and highlight them
    
    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
        local SMSO=$(tput smso)
        local RMSO=$(tput rmso)
        find . -type f -name "${2:-*}" -print0 | xargs -0 grep -sn ${case} "$1" 2>&- | \
    sed "s/$1/${SMSO}\0${RMSO}/gI" | more
    }
    
    
    
    ##### Cut last n lines in file, 10 by default
    
    function cuttail()
    {
        nlines=${2:-10}
        sed -n -e :a -e "1,${nlines}!{P;N;D;};N;ba" $1
    }
    
    
    
    ##### Move filenames to lowercase
    
    function lowercase()
    {
        for file ; do
            filename=${file##*/}
            case "$filename" in
            */*) dirname==${file%/*} ;;
            *) dirname=.;;
            esac
            nf=$(echo $filename | tr A-Z a-z)
            newname="${dirname}/${nf}"
            if [ "$nf" != "$filename" ]; then
                mv "$file" "$newname"
                echo "lowercase: $file --> $newname"
            else
                echo "lowercase: $file not changed."
            fi
        done
    }
    
    
    
    ##### Creates a backup of the file passed as parameter with the date and time
    
    function bak ()
    {
      cp $1 $1_`date +%H:%M:%S_%d-%m-%Y`
    }
    
    
    
    ##### Swap 2 filenames around
    
    function swap()
    {
        local TMPFILE=tmp.$$
        mv "$1" $TMPFILE
        mv "$2" "$1"
        mv $TMPFILE "$2"
    }
    
    
    
    ##### Edit the svn log at  the given revision
    
    editsvnlog() {
        svn propedit svn:log --revprop -r$1 --editor-cmd gedit
    }
    
    
    
    ##### Remove all files created by latex
    
    function unlatex(){
    if [ "$1" == "" ]; then
    return
    fi
    i=${1%%.*}
    rm -f $i.aux $i.toc $i.lof $i.lot $i.los $i.?*~ $i.loa $i.log $i.bbl $i.blg $i.glo
    rm -f $i.odt $i.tns $i.fax $i.bm $i.out $i.nav $i.snm
    rm -f $i.mtc* $i.bmt
    mv -f $i.dvi .$i.dvi
    mv -f $i.ps .$i.ps
    mv -f $i.pdf .$i.pdf
    rm -f $i.dvi $i.ps $i.pdf
    unset i
    }
    
    
    
    ##### Display private IP
    
    function ippriv()
    {
        ifconfig eth0|grep "inet adr"|awk '{print $2}'|awk -F ':' '{print $2}'
    }
    
    
    
    ##### Repeats a command every x seconds
    
    # Usage: repeat PERIOD COMMAND
    function repeat() {
        local period
        period=$1; shift;
        while (true); do
            eval "$@";
        sleep $period;
        done
    }
    
    
    
    ##### 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
    }
    
    
    
    ##### Automatically inputs aliases here in '.bashrc'
    
    # Usage: mkalias <name> "<command>"
    # Example: mkalias rm "rm -i"
    function mkalias ()
    {
            if [[ $1 && $2 ]]
            then
            echo -e "alias $1=\"$2\"" >> ~/.bashrc
            alias $1=$2
            fi
    }
    
    
    
    ### ALIASES  ### ALIASES  ### ALIASES  ### ALIASES  ### ALIASES  ### ALIASES  ### ALIASES  ### ALIASES  ### ALIASES  ### ALIASES  ### ALIASES  ### ALIASES
    
    
    
    ##### Directory shortcuts
    
    alias home='cd ~/'
    alias backgrounds='cd ~/Pictures/Backgrounds'
    alias backups='cd ~/Backups'
    alias books='cd ~/eBooks'
    alias documents='cd ~/Documents'
    alias downloads='cd ~/Downloads'
    alias drive-c='cd ~/.wine/drive_c'
    alias images='cd ~/Images'
    alias localhost='cd /var/www'
    alias music='cd ~/Music'
    alias nautilus-scripts='cd ~/.gnome2/nautilus-scripts'
    alias packages='cd ~/Packages'
    alias pictures='cd ~/Pictures'
    alias ppc='cd ~/PPC'
    alias public='cd ~/Public'
    alias torrents='cd ~/Torrents'
    alias temp='cd ~/Temp'
    alias ubuntu-texts='cd ~/Documents/Ubuntu Texts'
    alias videos='cd ~/Videos'
    alias webdesign='cd ~/Web/Design'
    alias back='cd $OLDPWD'
    alias ..='cd ..'
    alias ...='cd ../..'
    alias ....='cd ../../..'
    alias .....='cd ../../../..'
    alias ......='cd ../../../../..'
    
    
    
    ##### Command substitution
    
    alias ff='sudo find / -name $1'
    alias df='df -h -x tmpfs -x usbfs'
    alias psg='ps -ef | grep $1'
    alias h='history | grep $1'
    alias rm='rm -i'
    alias cp='cp -i'
    alias mv='mv -i'
    alias which='type -all'
    alias path='echo -e ${PATH//:/\\n}'
    alias vi='vim'
    alias du='du -h --max-depth=1'
    alias c='clear'
    alias e='espeak'
    alias kgp='killall gnome-panel'
    alias k='kill'
    alias kn='killall nautilus'
    alias q='exit'
    alias n='nautilus & exit'
    alias nq='nautilus -q'
    alias yt='youtube-dl -t '
    alias mc='metacafe-dl -t'
    alias updatefont='fc-cache -v -f'
    alias sdi='sudo dpkg -i'
    alias ps='ps auxf'
    alias pg='ps aux | grep'* # requires an argument
    alias mountedinfo='df -hT'
    alias ping='ping -c 10'
    alias mkdir='mkdir -p -v'
    alias openports='netstat -nape --inet'
    alias ns='netstat -alnp --protocol=inet | grep -v CLOSE_WAIT | cut -c-6,21-94 | tail +2'
    alias du1='du -h --max-depth=1'
    alias packup='/bin/tar -czvf' # compress a file in tar format
    alias unpack='/bin/tar -xzvpf' # uncompress a a Tar file
    alias contents='/bin/tar -tzf' # can View the contents of a Tar file
    alias mktd='tdir=`mktemp -d` && cd $tdir' # make a temp dir, then immediately cd into it
    ### some ls aliases
    alias ls='ls -hF --color' # add colors for filetype recognition
    alias lx='ls -lXB' # sort by extension
    alias lk='ls -lSr' # sort by size
    alias la='ls -Al' # show hidden files
    alias lr='ls -lR' # recursice ls
    alias lt='ls -ltr' # sort by date
    alias lm='ls -al |more' # pipe through 'more'
    alias tree='tree -Cs' # nice alternative to 'ls'
    alias ll='ls -l' # long listing
    alias l='ls -hF --color' # quick listing
    alias lsize='ls --sort=size -lhr' # list by size
    alias l?='cat ~/technical/tips/ls'
    alias lsd='ls -l | grep "^d"' # list only directories
    alias l.='ls -d .[[:alnum:]]* 2> /dev/null || echo "No hidden file here..."' # list only hidden files
    
    
    
    ##### Miscellaneous
    
    alias edit='nano'
    alias bashrc='gedit ~/.bashrc & exit'
    alias ebrc='nano ~/.bashrc'
    alias ebrcupdate='source ~/.bashrc'
    alias repos='gksudo gedit /etc/apt/sources.list'
    alias n2r='sudo /etc/init.d/nginx stop && sleep 2 && sudo /etc/init.d/nginx start'
    alias someDBdump='sudo mysqldump someDB -uroot -p > /home/username/www/_dbs/someDB.sql'
    alias webshare='python -c "import SimpleHTTPServer; SimpleHTTPServer.test();"'
    alias wiki='wikipedia2text -p'
    alias perm='stat --printf "%a %n \n "'
    alias bbc='lynx -term=vt100 http://news.bbc.co.uk/text_only.stm'
    alias nytimes='lynx -term=vt100 http://nytimes.com'
    alias ip='curl www.whatismyip.org'
    alias restart-apache='sudo /etc/init.d/apache2 restart'
    alias svnrmallentries='find . -name .svn -print0 | xargs -0 rm -rf' # remove all .svn directories recursively
    alias svnaddall='find "$PWD" -exec svn add {} 2>/dev/null \;' # add all files recursively
    ### easy script callin'
    alias show-info='~/.bin/info.pl'
    alias show-colors='~/.bin/colors.sh'
    ### sudo fixes
    alias updatedb='sudo updatedb'
    alias ppa-purge='sudo ppa-purge'
    ### terminal notifications
    alias alert_helper='history|tail -n1|sed -e "s/^\s*[0-9]\+\s*//" -e "s/;\s*alert$//"'
    alias alert='notify-send -i gnome-terminal "Finished Terminal Job" "[$?] $(alert_helper)"'
    ### truecrypt
    alias mtrue='sudo truecrypt /media/usbdisk/me.tc ~/me'
    alias utrue='sudo truecrypt -d'
    ### rsync
    alias usbb='rsync -avz /media/usbdisk/ ~/backup/usb/'
    alias rsync-me='sudo rsync -a -v --progress --delete --modify-window=1 -s /home/me /home/rsync'
    
    
    
    ##### Chmod commands
    
    alias mx='chmod a+x'
    alias 000='chmod 000'
    alias 644='chmod 644'
    alias 755='chmod 755'
    
    
    
    ##### App-specific
    
    alias nano='nano -W -m'
    alias audio='ncmpcpp'
    alias ftp='ncftp Personal'
    alias wget='wget -c'
    alias scrot='scrot -c -d 7'
    alias tvtime-video0='tvtime-configure -d /dev/video0'
    alias tvtime-video1='tvtime-configure -d /dev/video1'
    alias tvtime-video2='tvtime-configure -d /dev/video2'
    alias tvtime-video3='tvtime-configure -d /dev/video3'
    alias tvtime-video4='tvtime-configure -d /dev/video4'
    alias tvtime-video5='tvtime-configure -d /dev/video5'
    alias ss='gnome-screensaver-command -a'
    
    
    
    ##### Xterm and Aterm
    
    alias term='xterm -bg AntiqueWhite -fg Black &'
    alias termb='xterm -bg AntiqueWhite -fg NavyBlue &'
    alias termg='xterm -bg AntiqueWhite -fg OliveDrab &'
    alias termr='xterm -bg AntiqueWhite -fg DarkRed &'
    alias aterm='xterm -ls -fg gray -bg black'
    alias xtop='xterm -fn 6x13 -bg LightSlateGray -fg black -e top &'
    alias xsu='xterm -fn 7x14 -bg DarkOrange4 -fg white -e su &'
    
    
    
    ##### Remote hosts and proxy stuff
    
    alias remote='ssh -p 1234 12.34.56.78' # access some remote host
    alias uploads='cd /some/folder' # access some folder
    alias dbdumpcp='scp -P 1234 username@12.34.56.78:/home/username/...omeSite/db.sql /home/username/Backup/data/db.sql' # copy remote db to local
    alias proxy1='ssh -p 1234 -D 5678 username@12.34.56.78' # SOCKS proxy .. these anonomise my browsing with a single word - 12.34.56.78
    alias proxy2='ssh -p 8765 -D 4321 username@87.65.43.21' # SOCKS proxy .. these anonomise my browsing with a single word - 87.65.43.21
    alias sync='java -jar ~/finchsync/finchsync.jar -nogui' # sync to PDA .. well, that'll be a sync then! - start FinchSync SVR
    alias syncoff='java -jar ~/Apps/FinchSync/finchsync.jar -stopserver' # sync to PDA .. well, that'll be a sync then! - stop FinchSync SVR
    alias finchsync='java -jar ~/finchsync/finchsync.jar' # start FinchSync Admin
    
    
    
    ##### Information
    
    alias ver='cat /etc/lsb-release' # Ubuntu version detail
    alias version='sudo apt-show-versions' # show version
    alias space='df -h' # disk space usage
    alias free='free -m' # RAM and SWAP detail in MBs
    alias hardware='sudo lshw -html > hardware.html' # overview of the hardware in the computer
    alias hgrep='history | grep --color=always' # search commands history
    alias top-commands='history | awk "{print $2}" | awk "BEGIN {FS="|"} {print $1}" |sort|uniq -c | sort -rn | head -10' # show most popular commands
    alias biggest='BLOCKSIZE=1048576; du -x | sort -nr | head -10' # show biggest directories
    alias topten='du -sk $(/bin/ls -A) | sort -rn | head -10' # displays the top ten biggest folders/files in the current directory
    alias treefind="find . | sed 's/[^/]*\//|   /g;s/| *\([^| ]\)/+--- \1/'" # displays a tree of the arborescence
    alias stamp='date "+%Y%m%d%a%H%M"' # timestamps
    alias da='date "+%Y-%m-%d %A    %T %Z"'
    alias today='date +"%A, %B %-d, %Y"'
    alias myps='/bin/ps -u "$USER" -o user,pid,ppid,pcpu,pmem,args|less' # ps
    
    
    
    ##### Personal help
    
    alias a?='cat ~/.alias.help'
    alias f?='cat ~/.function.help'
    alias dn='OPTIONS=$(\ls -F | grep /$); select s in $OPTIONS; do cd $PWD/$s; break;done'
    alias help='OPTIONS=$(\ls ~/.tips -F);select s in $OPTIONS; do less ~/.tips/$s; break;done'
    
    
    
    ##### Computer cleanup
    
    alias trash='rm -fr ~/.Trash'
    alias orphaned='sudo deborphan | xargs sudo apt-get -y remove --purge'
    alias cleanup='sudo apt-get -y autoclean && sudo apt-get -y autoremove && sudo apt-get -y clean && sudo apt-get -y remove && sudo deborphan | xargs sudo apt-get -y remove --purge'
    
    
    
    ##### Hardware Shortcuts
    
    alias cdo='eject /dev/cdrecorder'
    alias cdc='eject -t /dev/cdrecorder'
    alias dvdo='eject /dev/dvd'
    alias dvdc='eject -t /dev/dvd'
    alias scan='scanimage -L'
    alias playw='for i in *.wav; do play $i; done'
    alias playo='for i in *.ogg; do play $i; done'
    alias playm='for i in *.mp3; do play $i; done'
    alias dvdrip='vobcopy -i /dev/dvd/ -o ~/DVDs/ -l'
    
    
    
    ##### Espeak commands
    
    alias espeak-wav-file='espeak -s 150 -w voice.wav -f'
    alias espeak-wav='espeak -s 150 -w voice.wav'
    alias espeak-us='espeak -v en-us -s 150'
    alias espeak-file='espeak -s 150 -f'
    
    
    
    ##### Package making and installation
    
    alias checkinstall='sudo checkinstall -y --fstrans=no'
    alias checkinstall-noinstall='sudo checkinstall -y --fstrans=no --install=no'
    alias checkinstall-force='sudo checkinstall --dpkgflags "--force-overwrite"'
    alias debinstall='sudo dpkg -i'
    alias debinstall-force='sudo dpkg -i --force-overwrite'
    
    
    
    ##### Chown substitution (change 'me' to your username)
    
    alias chown='sudo chown -R me'
    alias chown-backgrounds='sudo chown -R me ~/Pictures/Backgrounds'
    alias chown-backups='sudo chown -R me ~/Backups'
    alias chown-desktop='sudo chown -R me ~/Desktop'
    alias chown-documents='sudo chown -R me ~/Documents'
    alias chown-music='sudo chown -R me ~/Music'
    alias chown-pictures='sudo chown -R me ~/Pictures'
    alias chown-ppc='sudo chown -R me ~/PPC'
    alias chown-public='sudo chown -R me ~/Public'
    alias chown-temp='sudo chown -R me ~/Temp'
    alias chown-videos='sudo chown -R me ~/Videos'
    
    
    
    ##### Aptitude stuff
    
    alias install='sudo aptitude install'
    alias remove='sudo aptitude remove'
    alias purge='sudo aptitude purge'
    alias hold='sudo aptitude hold'
    alias unhold='sudo aptitude unhold'
    alias markauto='sudo aptitude markauto'
    alias unmarkauto='sudo aptitude unmarkauto'
    alias forbid-version='sudo aptitude forbid-version'
    alias update='sudo aptitude update'
    alias upgrade='sudo aptitude safe-upgrade'
    alias full-upgrade='sudo aptitude full-upgrade'
    alias build-dep='sudo aptitude build-dep'
    alias forget-new='sudo aptitude forget-new'
    alias search='sudo aptitude search'
    alias show='sudo aptitude show'
    alias clean='sudo aptitude clean'
    alias autoclean='sudo aptitude autoclean'
    alias changelog='sudo aptitude changelog'
    alias download='sudo aptitude download'
    alias reinstall='sudo aptitude reinstall'
    alias why='sudo aptitude why'
    alias why-not='sudo aptitude why-not'
    alias linux-image='sudo aptitude search linux-image' # linux-image kernel update check
    
    
    
    ##### Apt-get stuff
    
    alias autoremove='sudo apt-get autoremove'
    alias source='sudo apt-get source'
    alias dist-upgrade='sudo apt-get dist-upgrade'
    alias dselect-upgrade='sudo apt-get dselect-upgrade'
    alias check='sudo apt-get check'
    
    
    
    ##### Apt-cache stuff
    
    alias aptadd='sudo apt-cache add'
    alias aptgencaches='sudo apt-cache gencaches'
    alias aptshowpkg='sudo apt-cache showpkg'
    alias aptshowsrc='sudo apt-cache showsrc'
    alias aptstats='sudo apt-cache stats'
    alias aptdump='sudo apt-cache dump'
    alias aptdumpavail='sudo apt-cache dumpavail'
    alias aptunmet='sudo apt-cache unmet'
    alias aptsearch='sudo apt-cache search'
    alias aptshow='sudo apt-cache show'
    alias aptdepends='sudo apt-cache depends'
    alias aptrdepends='sudo apt-cache rdepends'
    alias aptpkgnames='sudo apt-cache pkgnames'
    alias aptdotty='sudo apt-cache dotty'
    alias aptxvcg='sudo apt-cache xvcg'
    alias aptpolicy='sudo apt-cache policy'
    
    
    
    ##### Apt-history Stuff
    
    alias history='apt-history'
    alias historyi='apt-history install'
    alias historyu='apt-history upgrade'
    alias historyre='apt-history remove'
    alias historyro='apt-history rollback'
    
    
    
    ##### Secure-delete substitution
    
    alias srm='sudo srm -f -s -z -v'
    alias srm-m='sudo srm -f -m -z -v'
    alias smem-secure='sudo sdmem -v'
    alias smem-f='sudo sdmem -f -l -l -v'
    alias smem='sudo sdmem -l -l -v'
    alias sfill-f='sudo sfill -f -l -l -v -z'
    alias sfill='sudo sfill -l -l -v -z'
    alias sfill-usedspace='sudo sfill -i -l -l -v'
    alias sfill-freespace='sudo sfill -I -l -l -v'
    alias sswap='sudo sswap -f -l -l -v -z'
    alias sswap-sda5='sudo sswap -f -l -l -v -z /dev/sda5'
    alias swapoff='sudo swapoff /dev/sda5'
    alias swapon='sudo swapon /dev/sda5'
    
    
    
    ##### Shred substitution
    
    alias shred-sda='sudo shred -v -z -n 0 /dev/sda'
    alias shred-sdb='sudo shred -v -z -n 0 /dev/sdb'
    alias shred-sdc='sudo shred -v -z -n 0 /dev/sdc'
    alias shred-sdd='sudo shred -v -z -n 0 /dev/sdd'
    alias shred-sde='sudo shred -v -z -n 0 /dev/sde'
    alias shred-sdf='sudo shred -v -z -n 0 /dev/sdf'
    alias shred-sdg='sudo shred -v -z -n 0 /dev/sdg'
    alias shred-sda-r='sudo shred -v -z -n 1 /dev/sda'
    alias shred-sdb-r='sudo shred -v -z -n 1 /dev/sdb'
    alias shred-sdc-r='sudo shred -v -z -n 1 /dev/sdc'
    alias shred-sdd-r='sudo shred -v -z -n 1 /dev/sdd'
    alias shred-sde-r='sudo shred -v -z -n 1 /dev/sde'
    alias shred-sdf-r='sudo shred -v -z -n 1 /dev/sdf'
    alias shred-sdg-r='sudo shred -v -z -n 1 /dev/sdg'
    
    
    
    ##### DD substitution
    
    alias backup-sda='sudo dd if=/dev/hda of=/dev/sda bs=64k conv=notrunc,noerror' # to backup the existing drive to a USB drive
    alias restore-sda='sudo dd if=/dev/sda of=/dev/hda bs=64k conv=notrunc,noerror' # to restore from the USB drive to the existing drive
    alias partitioncopy='sudo dd if=/dev/sda1 of=/dev/sda2 bs=4096 conv=notrunc,noerror' # to duplicate one hard disk partition to another hard disk partition
    alias cdiso='sudo dd if=/dev/hda of=cd.iso bs=2048 conv=sync,notrunc' # to make an iso image of a CD
    alias diskcopy='sudo dd if=/dev/dvd of=/dev/cdrecorder'
    alias cdcopy='sudo dd if=/dev/cdrom of=cd.iso' # for cdrom
    alias scsicopy='sudo dd if=/dev/scd0 of=cd.iso' # if cdrom is scsi
    alias dvdcopy='sudo dd if=/dev/dvd of=dvd.iso' # for dvd
    alias floppycopy='sudo dd if=/dev/fd0 of=floppy.image' # to duplicate a floppy disk to hard drive image file
    alias dd-sda='sudo dd if=/dev/zero of=/dev/sda conv=notrunc' # to wipe hard drive with zero
    alias dd-sdb='sudo dd if=/dev/zero of=/dev/sdb conv=notrunc' # to wipe hard drive with zero
    alias dd-sdc='sudo dd if=/dev/zero of=/dev/sdc conv=notrunc' # to wipe hard drive with zero
    alias dd-sdd='sudo dd if=/dev/zero of=/dev/sdd conv=notrunc' # to wipe hard drive with zero
    alias dd-sde='sudo dd if=/dev/zero of=/dev/sde conv=notrunc' # to wipe hard drive with zero
    alias dd-sdf='sudo dd if=/dev/zero of=/dev/sdf conv=notrunc' # to wipe hard drive with zero
    alias dd-sdg='sudo dd if=/dev/zero of=/dev/sdg conv=notrunc' # to wipe hard drive with zero
    alias dd-sda-r='sudo dd if=/dev/urandom of=/dev/sda bs=102400' # to wipe hard drive with random data option (1)
    alias dd-sdb-r='sudo dd if=/dev/urandom of=/dev/sdb bs=102400' # to wipe hard drive with random data option (1)
    alias dd-sdc-r='sudo dd if=/dev/urandom of=/dev/sdc bs=102400' # to wipe hard drive with random data option (1)
    alias dd-sdd-r='sudo dd if=/dev/urandom of=/dev/sdd bs=102400' # to wipe hard drive with random data option (1)
    alias dd-sde-r='sudo dd if=/dev/urandom of=/dev/sde bs=102400' # to wipe hard drive with random data option (1)
    alias dd-sdf-r='sudo dd if=/dev/urandom of=/dev/sdf bs=102400' # to wipe hard drive with random data option (1)
    alias dd-sdg-r='sudo dd if=/dev/urandom of=/dev/sdg bs=102400' # to wipe hard drive with random data option (1)
    alias dd-sda-full='sudo dd if=/dev/urandom of=/dev/sda bs=8b conv=notrunc,noerror' # to wipe hard drive with random data option (2)
    alias dd-sdb-full='sudo dd if=/dev/urandom of=/dev/sdb bs=8b conv=notrunc,noerror' # to wipe hard drive with random data option (2)
    alias dd-sdc-full='sudo dd if=/dev/urandom of=/dev/sdc bs=8b conv=notrunc,noerror' # to wipe hard drive with random data option (2)
    alias dd-sdd-full='sudo dd if=/dev/urandom of=/dev/sdd bs=8b conv=notrunc,noerror' # to wipe hard drive with random data option (2)
    alias dd-sde-full='sudo dd if=/dev/urandom of=/dev/sde bs=8b conv=notrunc,noerror' # to wipe hard drive with random data option (2)
    alias dd-sdf-full='sudo dd if=/dev/urandom of=/dev/sdf bs=8b conv=notrunc,noerror' # to wipe hard drive with random data option (2)
    alias dd-sdg-full='sudo dd if=/dev/urandom of=/dev/sdg bs=8b conv=notrunc,noerror' # to wipe hard drive with random data option (2)
    
    extract-file () {
    if [ -f $1 ] ; then
    case $1 in
    *.tar.bz2) tar xjvf $1 ;;
    *.tar.gz) tar xzvf $1 ;;
    *.bz2) bunzip2 $1 ;;
    *.rar) rar x $1 ;;
    *.gz) gunzip $1 ;;
    *.tar) tar xf $1 ;;
    *.tbz2) tar xjvf $1 ;;
    *.tgz) tar xzvf $1 ;;
    *.zip) unzip $1 ;;
    *.Z) uncompress $1 ;;
    *.7z) 7z x $1 ;;
    *) echo "'$1' cannot be extracted via extract-file" ;;
    esac
    else
    echo "'$1' is not a valid file"
    fi
    }
    Last edited by stanca; September 7th, 2010 at 11:20 AM.

  4. #154
    Join Date
    Feb 2009
    Location
    Devon, UK
    Beans
    58
    Distro
    Ubuntu 10.04 Lucid Lynx

    Re: Show us your .bashrc!

    Dude. Use code tags, not quote tags.
    GCS d++ s: a-- C++ UL+++ P+ L++ E W+++ !N o-- K w+(---) !O M+ !VMS !PS PE Y PGP+ t 5 !X R !tv b++ DI++ D++ G++ e++>+++ h* r++ y+

  5. #155
    Join Date
    Jan 2009
    Location
    Bucharest,Romania.
    Beans
    104
    Distro
    Ubuntu 13.04 Raring Ringtail

  6. #156
    Join Date
    Apr 2006
    Location
    Montana
    Beans
    Hidden!
    Distro
    Kubuntu Development Release

    Re: Show us your .bashrc!

    Quote Originally Posted by stanca View Post
    Sorry.My mistake.
    For long files, consider using an attachment.
    There are two mistakes one can make along the road to truth...not going all the way, and not starting.
    --Prince Gautama Siddharta

    #ubuntuforums web interface

  7. #157
    Join Date
    Nov 2009
    Location
    California, US
    Beans
    23

    Re: Show us your .bashrc!

    I'll play along.

    First for the pretty:



    Now to the code:

    Code:
    [ -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 -hT'
    alias h='history'
    alias d='cd /home/mike/Desktop'
    alias open='gnome-open'
    alias chm='kchmviewer'
    alias install='sudo apt-get install'
    
    # 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/mike/weather.sh'
    
    # Music
    alias ncmpc='ncmpc -cm'
    
    # 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'
    
    # Directory navigation aliases
    alias ..='cd ..'
    alias ...='cd ../..'
    alias ....='cd ../../..'
    alias .....='cd ../../../..'
    
    # 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 whois='whois -H'
    
    # listings
    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'
    
    # scripts
    
    
    # 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'
    
    # WELCOME SCREEN
    #######################################################
    
    clear
    
    echo -ne "${LIGHTGREEN}" "Greetings, $USER. Todays date and time is, "; date
    echo -e "${RED}"; cal ;  
    echo -ne "${CYAN}";
    echo 
    echo -ne "${RED}Sysinfo:";uptime ;echo ""
    echo -ne "${LIGHTGREEN}" ; uname -sro
    
    # 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 $@; }
    
    # SPECIAL FUNCTIONS
    #######################################################
    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
    }
    
    #####################################
    # ##### ENVIRONMENT VARIABLES ##### #
    #####################################
    
    declare -x HISTFILE=~/.bash_history
    declare -x HISTCONTROL=ignoredups
    declare -x HISTFILESIZE=100000
    declare -x HISTSIZE=100000
    
    ############################## ##################################
    # ##### PROMPT SECTION ##### ####################################
    ############################## ##################################
    
    PS1="\[\][\[\]\u\[\]]\[\]\w > \[\]"
    Thinkpad X41T
    Ubuntu 10.04 32-Bit

  8. #158
    Join Date
    Sep 2009
    Beans
    Hidden!

    Re: Show us your .bashrc!

    Code:
    alias nano='nano -S -O'
    alias rm='rm -i'
    
    PS1="\[\033[1;34m\](\[\033[1;37m\]\w\[\033[1;34m\]) \[\033[1;32m\]*\[\033[1;0m\]
    PS1: (black background, white plaintext)

    (/path/to/directory) * nano

  9. #159
    Join Date
    Oct 2008
    Beans
    43

    Re: Show us your .bashrc!

    Here is mine. It's mainly a collection of commands from this tread. The only new part is the duf function:

    Code:
    # show the 10 largest files sorted and in human readable format
    function duf {
    du -sk "$@" | sort -n | while read size fname; 
    	do for unit in k M G T P E Z Y; 
    		do if [ $size -lt 1024 ]; 
    		then echo -e "${size}${unit}\t${fname}"; 
    			break; fi; size=$((size/1024)); 
    		done; 
    	done | tail -n 10 | tac
    }
    Attached Files Attached Files

  10. #160
    Zero2Nine Guest

    Re: Show us your .bashrc!

    Quote Originally Posted by Temetka View Post
    I'll play along.

    First for the pretty:

    -cut image-

    Now to the code:

    -cut-
    How do you get the terminal to display your name as [name] instead of name@computername? I tried to find that part in your script but can't see it.

Page 16 of 18 FirstFirst ... 61415161718 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
  •