Skip to content

Instantly share code, notes, and snippets.

@tasdomas
Created June 9, 2015 16:28
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 tasdomas/fe3fdecd4f4b19734496 to your computer and use it in GitHub Desktop.
Save tasdomas/fe3fdecd4f4b19734496 to your computer and use it in GitHub Desktop.
Switching go environments
#!/bin/sh
GOPATH=$(dirname $0)
GOBIN=$GOPATH"/bin"
PATH=$GOBIN:$PATH
tmux set-option -t ${SESSION} default-shell /bin/zsh
tmux set-option -t ${SESSION} history-limit 5000
tmux set-environment -t ${SESSION} JUJU_MONGOD /usr/lib/juju/bin/mongod
#tmux set-option -t ${SESSION} update-environment "GOPATH GOBIN PATH"
tmux set-environment -t ${SESSION} GOBIN $GOBIN
tmux set-environment -t ${SESSION} GOPATH $GOPATH
tmux set-environment -t ${SESSION} PATH $PATH
tmux new-window -t ${SESSION}:1 -n 'emacs' 'emacs -nw'
tmux new-window -t ${SESSION}:2 -n 'shell'
tmux kill-window -t ${SESSION}:0
tmux select-window -t ${SESSION}:2
#!/bin/bash -ex
# goenv is a tool for switching between development environments.
ENVS_DIR=$HOME"/envs/"
if [ "$#" -ne 1 ]; then
echo "Usage: $0 <env name>"
exit 1
fi
ENV=$1
echo $ENV
envdir=$ENVS_DIR$ENV
if [ ! -d "$envdir" ]; then
echo "Env not initialized."
echo "$envdir"
exit 1
fi
SESSION=$USER-$ENV
cd "$envdir"
if ! tmux has-session -t ${SESSION}; then
if tmux -2 new-session -d -s ${SESSION}; then
if [ -f "$envdir"/.cfg.sh ]; then
SESSION=${SESSION} $envdir"/.cfg.sh"
fi
fi
fi
tmux attach -t ${SESSION}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment