Created
June 9, 2015 16:28
-
-
Save tasdomas/fe3fdecd4f4b19734496 to your computer and use it in GitHub Desktop.
Switching go environments
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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