Bash settings

Occasionally I need to update my .bashrc file and every time I google for information on how to do different things. These are some more common things I end up putting into my .bashrc that I’ve found while googling.

#Common alias
alias ...='cd .. ; cd ..'
alias ..='cd ..'
alias _='cd -'
alias cls='clear'
alias fh='history | grep $1' #Requires one input
alias grep='grep --color'
alias h='history'
alias home='cd ~'
alias la='ls -allh'
alias ll='ls -allh'
alias ls='ls --color'
 
# the bash history should save 3000 commands
export HISTFILESIZE=3000
 
#Aliases for handling tarballs
alias zls='tar -tzf $1' #ls a tarball
alias ztr='tar -czvf $1 $2' #create a tarball
alias zun='tar -xzvf $1' #extract a tarball
 
#JAVA Settings
export JAVA_HOME=/usr/lib/jvm/java-1.5.0-sun-1.5.0.18/
export PATH=$JAVA_HOME/bin:$PATH
 
#GIT Settings
alias g='git'
alias ga="git add"
alias gb='git branch --verbose'
alias gc='git commit --verbose'
alias gca='git commit --verbose --all'
alias gcaa='git commit --verbose --amend --all'
alias gco="git checkout"
alias gd='git diff --ignore-space-change'
alias gdc='git diff -M -w --color-words'
alias gk='gitk &'
alias gl='git log'
alias glf='git log --pretty=format:%Cred%h\ %Cgreen%an%Cblue\ %s'
alias glp='gl --pretty=oneline'
alias gm="git merge"
alias gs='git status'
alias gst="git stash"
alias gull='git pull'
alias gush='git push'
MYNAME=''
MYEMAIL=''
export GIT_AUTHOR_NAME=$MYNAME
export GIT_AUTHOR_EMAIL=$MYEMAIL
export GIT_COMMITTER_NAME=$MYNAME
export GIT_COMMITTER_EMAIL=$MYEMAIL
 
#Use git completion if available
if [ -f ~/.git-completion.bash ]; then
source ~/.git-completion.bash
fi
 
#Prompt - with git branch
export PS1='\[\033[01;31m\]\u@\h [\d \t] \[\033[01;34m\]\W\[\033[00m\]\[\033[01;33m\]`git branch 2&> /dev/null|cut -f2 -d\* -s`\[\033[00m\]\n$ '
 
#Indent functions
#using Kernighan Richie style (user space code)
function indent_check_single_file()
{
echo "Running indent on: $PWD$(echo $* |cut -b 1 --complement)"
indent -kr -di24 --no-tabs $* -o /tmp/indent.tmp
diff $* /tmp/indent.tmp
rm /tmp/indent.tmp
}
 
function indent_check_recursive()
{
for k in $(find -name \*.c -o -name \*.h);do
   indent_check_single_file $k
done;
}
This entry was posted in Software and tagged , . Bookmark the permalink.