Skip to content

Instantly share code, notes, and snippets.

@ChrisPenner
Last active September 4, 2015 18:58
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 ChrisPenner/83ad2665eed3dd5fff15 to your computer and use it in GitHub Desktop.
Save ChrisPenner/83ad2665eed3dd5fff15 to your computer and use it in GitHub Desktop.
Autoenv + tmux workflow
#!/bin/sh
# Echo the root folder of the current git repo.
gitroot(){
echo `git rev-parse --show-toplevel`
}
# Reconnect tmux session
tmuxproj(){
# Don't attach to tmux if already in tmux
if ! { [ "$TERM" = "screen" ] || [ -n "$TMUX" ]; } then
# Attach to project tmux session if it exists, otherwise create it.
tmux attach -t `gitroot` || tmux new -s `gitroot`
fi
}
# inside a project's .env:
tmuxproj
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment