#!/bin/bash # # .bashrc for non-login shells # # Set environment variables export EDITOR='vim' export LESS='R' export CVS_RSH='ssh' export GPG_TTY=$(tty) # Set a browser if [ -x /usr/bin/firefox -a "x$DISPLAY" != "x" ]; then export BROWSER='/usr/bin/firefox' elif [ -x /usr/bin/links ]; then export BROWSER='/usr/bin/links' fi # Various shell options #case-insensitive filename globbing shopt -s nocaseglob #ignore small errors in cd shopt -s cdspell #no duplicates in history export HISTCONTROL=erasedups:ignorespace export HISTSIZE=5000 # Enable bash completion in interactive shells if [ -z "$BASH_COMPLETION" -a -f /etc/bash_completion ]; then . /etc/bash_completion fi # Custom Prompt Setup bash_prompt() { local RED="\[\e[1;31m\]" local GREEN="\[\e[0;32m\]" local YELLOW="\[\e[0;33m\]" local BLUE="\[\e[1;34m\]" local PURPLE="\[\e[0;35m\]" local CYAN="\[\e[1;36m\]" local NONE="\[\e[0;0m\]" if [ "$TERM" != "linux" ]; then local TITLEBAR="\[\e]0;\w\a\]" else local TITLEBAR="" fi # use a different color for the host if we are SSH'ed if [ "x$SSH_TTY" != "x" ]; then local ATHOST="$NONE@$CYAN" else local ATHOST="$NONE@$BLUE" fi # if git is installed and git bash completion exists, show current branch if [ -n "$(type -p git)" -a "$(type -t __git_ps1)" = "function" ]; then local GITPS1="$PURPLE"'$(__git_ps1)' else local GITPS1='' fi export PS1="$TITLEBAR\n$RED\u$ATHOST\h $GREEN\w$GITPS1$NONE\n\$ " } bash_prompt; unset -f bash_prompt # pacman aliases- don't bother defining if pacman doesn't exist if [ -x /usr/bin/pacman ]; then alias pac='pacman' alias pacQ='pacman -Q' alias pacQs='pacman -Qs' alias pacQi='pacman -Qi' alias pacQm='pacman -Qm' alias pacS='sudo pacman -S' alias pacSy='sudo pacman -Sy' alias pacSu='sudo pacman -Su' alias pacSyu='sudo pacman -Syu' alias pacSs='/usr/bin/pacsearch' alias pacSi='pacman -Si' alias pacU='sudo pacman -U' alias pacR='sudo pacman -R' alias pacRc='sudo pacman -Rc' alias pacRs='sudo pacman -Rs' alias pacO='sudo pacman-optimize' # helpful makepkg shortcuts alias makepkgclean='rm -rf src/ pkg/ *~' fi # 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 "$@" } # psfind - shortcut for grepping a process name # Usage: psfind psfind() { ps -ef | egrep "PID|$@" } # rmbackups - remove all *~ files recursively in directory rmbackups() { find -iname '*~' -exec rm -v {} \; } # Useful aliases alias ls='ls --color=auto' alias ll='ls -lh' alias la='ls -A' alias lla='ls -lAh' alias lr='ls -R' alias c='clear' alias r='reset' # Common misspellings alias pdw='pwd' alias mroe='more' alias csv='cvs' alias snv='svn' alias gti='git' # source the local config [ -f ~/.bashrclocal ] && source ~/.bashrclocal