Skip to content

Instantly share code, notes, and snippets.

@elasticdog
Last active September 28, 2015 15:58
Show Gist options
  • Save elasticdog/1462391 to your computer and use it in GitHub Desktop.
Save elasticdog/1462391 to your computer and use it in GitHub Desktop.
tmux wrapper script
#!/bin/bash
# attach to an existing tmux session, or create one if none exist
# also set up access to the system clipboard from within tmux when possible
if [[ $OSTYPE == darwin* && -x $(command -v reattach-to-user-namespace) ]]; then
# on OS X force tmux's default command to spawn a shell in the user's namespace
# https://github.com/ChrisJohnsen/tmux-MacOSX-pasteboard
tweaked_config=$(cat $HOME/.tmux.conf <(echo 'set-option -g default-command "reattach-to-user-namespace -l $SHELL"'))
tmux attach || tmux -f <(echo "$tweaked_config") new-session
else
tmux attach || tmux new-session
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment