dotfiles/bash_profile
Dan Buch a8cd5a2fe9 Attempting to carve out a sensible chunk of stuff for a dotfiles repo.
Sure hope I didn't miss any super secret crap :-P
2012-02-26 14:38:01 -05:00

75 lines
1.4 KiB
Bash

_debug(){
if [ -n "$DEBUG" ] ; then
echo $*
fi
}
_get_hostname(){
local hn="$(hostname -a 2>/dev/null || hostname)"
local ha=""
for host in $hn ; do
if [[ "$(echo $host | grep "\." | grep -v "localhost")" != "" ]] ; then
ha="$host"
fi
done
if [ -n "$ha" ] ; then
echo "$ha"
else
echo ""
fi
}
_source_host_specific_rcfile(){
local _host_alias="`_get_hostname`"
if [[ ! -n "$_host_alias" ]] ; then
_host_alias="`hostname`"
fi
local _host_specific_rcfile="$HOME/.bash_vars.$_host_alias"
if [[ -e "$_host_specific_rcfile" ]] ; then
debug "sourcing $_host_specific_rcfile"
source $_host_specific_rcfile
fi
}
_source_bash_extras()
{
local _BASH_EXTRAS="
$HOME/.bash_aliases
$HOME/.bash_functions
/etc/bash_completion
$HOME/.bash_completion
"
for ext in $_BASH_EXTRAS ; do
if [ -e "$ext" ] ; then
_debug "sourcing $ext"
source $ext
fi
done
}
_bash_profile_main()
{
source "$HOME/.bash_vars_common"
_source_host_specific_rcfile
_source_bash_extras
get_ssh_agent
get_gpg_agent
eval "$(rbenv init -)"
unset _get_hostname
unset _source_host_specific_rcfile
unset _source_bash_extras
unset _bash_profile_main
}
_bash_profile_main
# vim:filetype=sh