User Tools

Site Tools


bashrc

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
bashrc [2009/04/08 09:17] 212.84.235.66bashrc [2010/04/28 18:45] (current) 92.195.193.18
Line 3: Line 3:
 This is my ''.bashrc'' This is my ''.bashrc''
  
-<code bash>+<code bash bashrc>
 # Andi's .bashrc # Andi's .bashrc
  
Line 14: Line 14:
 # be sure to do to all this on interactive shells only # be sure to do to all this on interactive shells only
 if [ "$PS1" ]; then if [ "$PS1" ]; then
 +  # load system defaults
 +  if [ -f /etc/profile ]; then
 +    . /etc/profile
 +  fi
  
   # handy file conversion tools   # handy file conversion tools
Line 25: Line 29:
   alias ll='ls -l'   alias ll='ls -l'
   alias la='ls -A'   alias la='ls -A'
-  alias l='ls -la'  +  alias l='ls -la' 
 +  export GREP_OPTIONS='--color=auto'
  
   # color in man pages http://icanhaz.com/colors   # color in man pages http://icanhaz.com/colors
Line 43: Line 48:
   # cleanup firefox 3 dbs   # cleanup firefox 3 dbs
   alias ffclean='for f in ~/.mozilla/firefox/*/*.sqlite; do echo $f; sqlite3 $f "VACUUM;"; done'   alias ffclean='for f in ~/.mozilla/firefox/*/*.sqlite; do echo $f; sqlite3 $f "VACUUM;"; done'
 +
 +  # current git branch for prompt below
 +  # http://techblog.floorplanner.com/2008/12/14/working-with-git-branches/
 +  parse_git_branch() {
 +    git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/\[\1\]/'
 +  }
 +  # has current branch unrecorded changes?
 +  # http://markelikalderon.com/2009/01/16/dirty-prompts/
 +  parse_git_dirty() {
 +    git diff --quiet HEAD &>/dev/null
 +    [[ $? == 1 ]] && echo "*"
 +  }
  
   # set a fancy prompt and xterm title   # set a fancy prompt and xterm title
   shopt -s checkwinsize   shopt -s checkwinsize
-  if [ ! -"$COLORTERM" ]; then+  if [ "$COLORTERM" != "" -"$TERM" == "xterm" ]; then
     if [ "$USER" == "root" ]; then     if [ "$USER" == "root" ]; then
-      PS1="\[\033]2;\w\007\]\[\033[0;31m\]\u@\h:\w\\$\[\033[0;37m\] "+      PS1='\[\e[0;31m\]\u@\h\[\e[0;35m\]$(parse_git_branch)$(parse_git_dirty)\[\e[0;31m\]:\w\$\[\e[0m\] '
     else     else
-      PS1="\[\033]2;\w\007\]\[\033[0;32m\]\u@\h:\w\\$\[\033[0;37m\] "+      PS1='\[\e[0;32m\]\u@\h\[\e[0;35m\]$(parse_git_branch)$(parse_git_dirty)\[\e[0;32m\]:\w\$\[\e[0m\] 
     fi     fi
   else   else
Line 62: Line 80:
  
   # ssh keymanager - see http://wiki.splitbrain.org/ssh   # ssh keymanager - see http://wiki.splitbrain.org/ssh
-  if [ -e /usr/bin/keychain ]; then+  if [ -e /usr/bin/keychain -a -e ~/.ssh/id_dsa ]; then
     keychain -q ~/.ssh/id_dsa     keychain -q ~/.ssh/id_dsa
     if [ -e ~/.ssh-agent-${HOSTNAME} ]; then     if [ -e ~/.ssh-agent-${HOSTNAME} ]; then
Line 71: Line 89:
     fi     fi
   fi   fi
-  # use zssh if available 
-  if [ -e /usr/bin/zssh ]; then alias ssh='zssh'; fi 
  
   # daily temp dir   # daily temp dir
Line 85: Line 101:
   }   }
  
-  # twitter client +  # set a sane editor 
-  twitter(){ +  if [ -e /usr/bin/vim ]; then 
-    local user='myusername'; +    export EDITOR=/usr/bin/vim 
-    local pass='mypass'; +    alias vi=/usr/bin/vim 
-    local twit=`echo -n "$@"+  fi
-    if [ -z "$twit" ]; then +
-        echo 'Enter your twit and hit return' +
-        read twit +
-    fi +
-    echo -n 'wait...' +
-    curl -u"$user:$pass" -dstatus="$twit" https://twitter.com/statuses/update.xml >/dev/null 2>&1 && echo 'okay' +
-  }+
  
   # print a fortune cookie   # print a fortune cookie
-  if [ -e /usr/games/fortune ]; then +  if which fortune >/dev/null; then 
-    if [ -z "$COLORTERM" ]; then +    if [ "$COLORTERM" != "" -o "$TERM" == "xterm" ]; then
-      /usr/games/fortune -a -s +
-    else+
       echo -en "\033[0;36m"       echo -en "\033[0;36m"
-      /usr/games/fortune -a -s+      fortune -a -s
       echo -en "\033[0;37m"       echo -en "\033[0;37m"
 +    else
 +      fortune -a -s
     fi     fi
   fi   fi
bashrc.1239182261.txt.gz · Last modified: 2009/04/08 09:17 by 212.84.235.66