Last active
May 23, 2016 16:24
-
-
Save ericgj/e9ff374bb7ec4378afa94b8eaed16443 to your computer and use it in GitHub Desktop.
tmux open session/window for project
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
#!/usr/bin/env sh | |
# loosely based on http://pastebin/D8y7prYV, except with windows not sessions | |
if [ ${#} -eq 3 ]; then | |
echo "You need to provide both a session and path" 2>&1 | |
exit 1 | |
fi | |
sess=${1} | |
cd "${2}" # note with CDPATH, the passed path may be a shortcut. So we cd first. | |
name=$(basename $PWD) | |
if tmux list-windows -t "${sess}" -F "#W" | grep "^${name}\$" 2>&1 > /dev/null; then | |
tmux attach-session -d -t "${sess}" \; select-window -t "$name" | |
else | |
tmux attach-session -t "${sess}" \; new-window -c "$PWD" -n "$name" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment