Skip to content

Instantly share code, notes, and snippets.

@AlexRogalskiy
Forked from stephengfriend/tmux.sh
Created April 21, 2022 08:30
Show Gist options
  • Save AlexRogalskiy/7efd302d2f6f330b6cbf62481997469f to your computer and use it in GitHub Desktop.
Save AlexRogalskiy/7efd302d2f6f330b6cbf62481997469f to your computer and use it in GitHub Desktop.
Visual Studio Code + tmux session integration
# Auto Start Tmux (must be last)
if [[ -z "$TMUX" ]] then
tmux_session='default'
terminal_slug="`echo $TERM_PROGRAM | iconv -t ascii//TRANSLIT | sed -E 's/[^a-zA-Z0-9-]+/-/g' | sed -E 's/^-+|-+$//g' | tr A-Z a-z | head -c 7`"
if [[ $TERM_PROGRAM == 'vscode' ]]; then
tmux_session="$terminal_slug-`pwd | sha1sum | head -c 8`"
fi
tmux new-session -A -d -s "$tmux_session"
# Disable the destruction of the new, unattached session.
tmux set-option -t "$tmux_session" destroy-unattached off &> /dev/null
exec tmux attach-session -t "$tmux_session"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment