dotfiles/bash_profile

90 lines
1.8 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_if_exists() {
if [ -e "$1" ] ; then
_debug "sourcing $1"
if [ -n "$DEBUG" ] ; then
time source "$1"
else
source "$1"
fi
fi
}
_source_bash_extras() {
local _bash_extras="
$HOME/.bashrc_local
$HOME/.bash_aliases
$HOME/.bash_functions
/etc/bash_completion
$HOME/.bash_completion
$HOME/.autoenv/activate.sh
"
for ext in $_bash_extras ; do
_source_if_exists "$ext"
done
}
_bash_profile_main() {
source "$HOME/.bash_vars_common"
_source_host_specific_rcfile
_source_bash_extras
get_ssh_agent
which gpg-agent && test -d ~/.gnupg && get_gpg_agent
#_source_if_exists "$HOME/.gvm/scripts/gvm"
#_source_if_exists "$HOME/.gvmrc"
#_source_if_exists "$HOME/src/gocode/src/.env"
unset _get_hostname
unset _source_host_specific_rcfile
unset _source_bash_extras
unset _bash_profile_main
}
_bash_profile_main
# added by travis gem
[[ -f ~/.travis/travis.sh ]] && source ~/.travis/travis.sh
# vim:filetype=sh