From bc0fc62b2f48900db8cda7b4a787f8d25365a4e9 Mon Sep 17 00:00:00 2001 From: Dan Buch Date: Sat, 19 Jan 2013 23:42:37 -0500 Subject: [PATCH] Adding some Go bits, correcting some warts plus getting to the bottom of shell startup slowness, which appears to be almost entirely due to rbenv. --- bash_aliases | 17 +++++++++------- bash_profile | 57 ++++++++++++++++++++++++++++++++++------------------ 2 files changed, 47 insertions(+), 27 deletions(-) diff --git a/bash_aliases b/bash_aliases index 53ccba3..c20f490 100644 --- a/bash_aliases +++ b/bash_aliases @@ -1,3 +1,5 @@ +#!/bin/bash + alias .bp="source $HOME/.bash_profile" alias .sa="source $HOME/.ssh/agent.out" alias be='bundle exec' @@ -15,12 +17,13 @@ alias sS='TERM=xterm screen -Rd -S ' alias scr='TERM=xterm screen -Rd' alias sl="screen -ls" -if [[ "$(uname)" -eq "Linux" ]] -then - alias l='ls -F --color=auto' -else - # for darwin in particular - alias l='ls -GF' -fi +case "$(uname | tr '[:upper:]' '[:lower:]')" in + darwin) + alias l='ls -GF' + ;; + *) + alias l='ls -F --color=auto' + ;; +esac # vim:filetype=sh diff --git a/bash_profile b/bash_profile index 92609ee..9b9464e 100644 --- a/bash_profile +++ b/bash_profile @@ -5,7 +5,7 @@ _debug(){ } -_get_hostname(){ +_get_hostname() { local hn="$(hostname -a 2>/dev/null || hostname)" local ha="" for host in $hn ; do @@ -21,7 +21,7 @@ _get_hostname(){ } -_source_host_specific_rcfile(){ +_source_host_specific_rcfile() { local _host_alias="`_get_hostname`" if [[ ! -n "$_host_alias" ]] ; then _host_alias="`hostname`" @@ -35,35 +35,52 @@ _source_host_specific_rcfile(){ } -_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 - if [ -e "$ext" ] ; then - _debug "sourcing $ext" - source $ext +_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() -{ +_bash_profile_main() { source "$HOME/.bash_vars_common" _source_host_specific_rcfile _source_bash_extras + get_ssh_agent get_gpg_agent - eval "$(rbenv init -)" - test -f "$HOME/.gvm/scripts/gvm" && source "$HOME/.gvm/scripts/gvm" + if [ -n "$DEBUG" ] ; then + export RBENV_DEBUG=1 + time eval "$(rbenv init -)" + unset RBENV_DEBUG + else + eval "$(rbenv init -)" + fi + + _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