Please bear with us as we work to restore functionality to dotfiles.org.
.bashrc
#
# ~/.bashrc
#
# bash options ---------------------------------------------------------
shopt -s cdable_vars # if cd arg is not valid, assumes its a var defining a dir
shopt -s cdspell # autocorrects cd misspellings
shopt -s checkwinsize # update the value of LINES and COLUMNS after each command if altered
shopt -s cmdhist # save multi-line commands in history as single line
shopt -s dotglob # include dotfiles in pathname expansion
shopt -s expand_aliases # expand aliases
shopt -s extglob # enable extended pattern-matching features
shopt -s histappend # append to (not overwrite) the history file
shopt -s hostcomplete # attempt hostname expansion when @ is at the beginning ofa word
shopt -s nocaseglob # pathname expansion will be treated as case-insensitive
# kill flow control ----------------------------------------------------
if tty -s ; then
stty -ixon
stty -ixoff
fi
# prompt ---------------------------------------------------------------
PS1='\[\e[37m\]\u\[\e[0m\]\[\e[33m\] \w\[\e[0m\] \$ '
# PS1='[\u@\h \W]\$ ' # default prompt
# PS1='$ ' # simple prompt
# if exists, add ~/scripts to path -------------------------------------
if [ -d ~/scripts ] ; then
PATH=~/scripts:$PATH
fi
# bash history ---------------------------------------------------------
export HISTFILE="$HOME/.bash_history_`hostname`" # hostname appended to bash history filename
export HISTSIZE=10000 # bash history will save N commands
export HISTFILESIZE=${HISTSIZE} # bash will remember N commands
export HISTCONTROL=ignoreboth # ingore duplicates and spaces (ignoreboth, ignoredups, ignorespace)
# env vars -------------------------------------------------------------
export OOO_FORCE_DESKTOP=gnome # openoffice preferences
# LESS man page colors--------------------------------------------------
export LESS_TERMCAP_mb=$'\E[01;31m'
export LESS_TERMCAP_md=$'\E[01;31m'
export LESS_TERMCAP_me=$'\E[0m'
export LESS_TERMCAP_se=$'\E[0m'
export LESS_TERMCAP_so=$'\E[01;44;33m'
export LESS_TERMCAP_ue=$'\E[0m'
export LESS_TERMCAP_us=$'\E[01;32m'
# sudo completion ------------------------------------------------------
complete -cf sudo
if [ -f /etc/bash_completion ]; then
. /etc/bash_completion
fi
# aliases --------------------------------------------------------------
alias ls='ls --color=auto -F'
alias ll='ls -lh'
alias la='ls -a'
alias dir='ls -1'
alias f='find | grep'
alias c='clear'
alias q='exit'
alias grep='grep --color=auto'
alias scrd='screen -RD'
alias mp="mplayer"
# pacman aliases -------------------------------------------------------
alias pacup='sudo pacman -Syu' # sync and update
alias pacin='sudo pacman -S' # install pkg
alias pacout='sudo pacman -Rns' # remove pkg and the deps it installed
alias pacs="pacman -Sl | cut -d' ' -f2 | grep " #
alias pac="pacsearch" # colorize pacman (pacs)
pacsearch ()
{
echo -e "$(pacman -Ss $@ | sed \
-e 's#core/.*#\\033[1;31m&\\033[0;37m#g' \
-e 's#extra/.*#\\033[0;32m&\\033[0;37m#g' \
-e 's#community/.*#\\033[1;35m&\\033[0;37m#g' \
-e 's#^.*/.* [0-9].*#\\033[0;36m&\\033[0;37m#g' )"
}
# functions ------------------------------------------------------------
# ex - archive extractor
# usage: ex
ex ()
{
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 ex()" ;;
esac
else
echo "'$1' is not a valid file"
fi
}
# roll - archive wrapper
# usage: roll ./foo ./bar
roll ()
{
FILE=$1
case $FILE in
*.tar.bz2) shift && tar cjf $FILE $* ;;
*.tar.gz) shift && tar czf $FILE $* ;;
*.tgz) shift && tar czf $FILE $* ;;
*.zip) shift && zip $FILE $* ;;
*.rar) shift && rar $FILE $* ;;
esac
}
# mktar - tarball wrapper
# usage: mktar
function mktar() { tar czf "${1%%/}.tar.gz" "${1%%/}/"; }
# calc - simple calculator
# usage: calc
function calc() { echo "$*" | bc; }
# define - fetch word defnition from google
# usage: define
define ()
{
lynx -dump "http://www.google.com/search?hl=en&q=define%3A+${1}&btnG=Google+Search" | grep -m 5 -w "*" | sed 's/;/ -/g' | cut -d- -f5 > /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
}
# sanitize - set file/directory owner and permissions to normal values (644/755)
# usage: sanitize
sanitize()
{
chmod -R u=rwX,go=rX "$@"
chown -R ${USER}:users "$@"
}
# screen-specific stuff for window titles ------------------------------
case $TERM in
screen*)
trap 'echo -ne "\ek${BASH_COMMAND%%\ *}\e\\"' DEBUG
PROMPT_COMMAND='echo -ne "\ek$(short_pwd 15)\e\\"'
;;
esac