Skip to content

Instantly share code, notes, and snippets.

@mtak
Created March 13, 2012 15:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mtak/2029318 to your computer and use it in GitHub Desktop.
Save mtak/2029318 to your computer and use it in GitHub Desktop.
Bash configuration file
# Terminal options
shopt -s histappend
shopt -s cdspell
#PROMPT_COMMAND='history -a'
HISTFILESIZE=5000
HISTCONTROL=ignoredups
TERM=xterm
export PROMPT_COMMAND HISTFILESIZE HISTCONTROL TERM
# Aliases
alias sl=ls
alias ps="ps -efZ"
alias grpe="grep"
# Shell functions
init () {
hostname=`hostname`
zoneadm list -vic | grep global >/dev/null;
globalToggle=$?;
echo "Are you sure you want to do init $* on machine ${hostname}?"
if [ $globalToggle -eq 0 ]; then
echo "THIS IS A GLOBAL MACHINE"
fi
read -p "Enter to continue or CTRL+C to abort..."
/sbin/init $*
}
# Convert bytes to gigabytes and vice versa
b2g () { echo $(($1/(1024*1024*1024))); }
g2b () { echo $(($1*(1024*1024*1024))); }
mailme () {
uuencode $1 $1 | mailx -s "$1" user@example.com
}
# Coloured grep
if [ -x "`which ggrep`" ]; then
export GREP_COLOR='1;32'
alias grep="`which ggrep` --color=auto"
fi
# Settings for local host
if [ `hostname` = "thor" ]; then
/usr/openwin/bin/xset b 0
if [ `/usr/bin/id -u` = 101 ]; then
/home/mtak/bin/ssh-agent_start_stop
export SSH_AUTH_SOCK=`cat ~/.ssh_auth_sock`
export SSH_AGENT_PID=`cat ~/.ssh_agent_pid`
sshLines=`/usr/bin/ssh-add -l | grep -v "agent has no identities" | wc -l`
if [ ${sshLines} = "0" ]; then
echo "SSH key caching expired, please reenter your credentials"
/usr/bin/ssh-add -t 30600
fi
fi
else
# Other systems don't deal well with rxvt
export TERM=xterm
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment