~/.bashrc - Used on a Arch Linux box.
#
# ~/.bashrc
#
# ----------------------------------------------------------------------
# PROMPT
# ----------------------------------------------------------------------
# A basic prompt.
# It looks like: ' ~ > '.
#
PS1='\033[0;32m\] \w\[\033[0m\] > '
# Yet another basic prompt.
# It looks like: 'skulk ~ > '.
#
# PS1='\033[0;32m\]\u \[\033[0;33m\]\w\033[0;0m\] > '
# ----------------------------------------------------------------------
# BASH FUNCTIONS
# ----------------------------------------------------------------------
# ex - archive extractor.
# Usage: ex <file>.
#
ex ()
{
if [ -f $1 ] ; then
case $1 in
*.tar.bz2) tar xjf $1 ;;
*.tar.gz) tar xzf $1 ;;
*.bz2) bunzip2 $1 ;;
*.rar) unrar e $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
}
# clock - a little clock that appeares in the terminal window.
# Usage: clock.
#
clock ()
{
while true;do clear;echo "===========";date +"%r";echo "===========";sleep 1;done
}
# showip - show the current IP address if connected to the internet.
# Usage: showip.
#
showip ()
{
lynx -dump -hiddenlinks=ignore -nolist http://checkip.dyndns.org:8245/ | awk '{ print $4 }' | sed '/^$/d; s/^[ ]*//g; s/[ ]*$//g'
}
# ----------------------------------------------------------------------
# ALIAS DEFINITIONS
# ----------------------------------------------------------------------
# 'ls' aliases.
#
alias ls='ls --color=auto -F' # Enable colorized output and append an indicator.
alias ll='ls -lh' # List files in the long format, in a humane way.
alias lt='ls -lt' # List files in the long format, sorting by time.
alias lr='ls -lR' # Recursively list subdirectories encountered.
alias la='ls -A' # Include hidden directory entries, except for '.' and '..'.
# Various aliases.
#
alias c='clear' # Clear the screen.
alias q='exit' # Exit the current session.
alias f='find | grep' # Quick search.
alias h='history' # View the history.
alias hist='history | grep $1' # Search the history.
alias m='more' # Start 'more'.
alias mkdir='mkdir -p' # Make parent directories as needed with 'mkdir'.
alias vi='vim' # Use 'vim' instead of 'vi'.
alias scrd='screen -RD' # Reattach to a screen session, or start a new one.
alias sv='sudo vim' # Start 'vim' with super user rights.
alias sn='sudo nano' # Start 'nano' with super user rights.
alias mp='mplayer' # Run 'mplayer'.
# Pacman aliases.
#
alias pacup='sudo pacman -Syu' # Sync and update.
alias pacin='sudo pacman -S' # Install package.
alias pacout='sudo pacman -Rns' # Remove a packages and the dependencies 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' )"
}
# ----------------------------------------------------------------------
# MISCELLANEOUS
# ----------------------------------------------------------------------
# If exists, add ~/bin to $PATH.
#
if [ -d ~/bin ] ; then
PATH=~/bin:$PATH
fi
# For bash sudo completion.
#
complete -cf sudo
if [ -f /etc/bash_completion ]; then
. /etc/bash_completion
fi
# Creates window titles in the screen hardstatus line.
#
case $TERM in
screen*)
trap 'echo -ne "\ek${BASH_COMMAND%%\ *}\e\\"' DEBUG
PROMPT_COMMAND='echo -ne "\ek$(short_pwd 15)\e\\"'
;;
esac