Skip to content

Instantly share code, notes, and snippets.

@akkartik
Created February 17, 2017 23:17
Show Gist options
  • Save akkartik/142dbe2f2bcfc385a9443700f8b1885b to your computer and use it in GitHub Desktop.
Save akkartik/142dbe2f2bcfc385a9443700f8b1885b to your computer and use it in GitHub Desktop.
Structuring tmux usage
#!/bin/bash
#
# Use the regular 'tmux' command and '.tmux.conf' to run tmux for managing
# multiple sessions running long-running commands that you might need to
# detach from to go offline.
#
# Use this script to manage a special hard-coded session called 'ide' with
# editor and shell windows configured how you want it.
if tmux has-session -t ide >&/dev/null
then
tmux attach -t ide
else
# TODO: ideally I'd like to put just one line in this else block:
## tmux -f .tmux.conf.ide new -s ide
# However this doesn't work because 'set' can't seem to affect just the
# about-to-be-created session.
# So we have to do the following instead:
tmux new -s ide -d
# I like to turn off statusline to make my shell windows seem more seamless
# with my Vim windows. I can switch between them seamlessly using
# https://www.reddit.com/r/vim/comments/22ixkq/navigate_around_vim_and_tmux_panes_painlessly/cgnjay4
tmux set -t ide status off
# ...
# add more "IDE-specific" settings here
# ...
tmux attach -t ide
fi
# Managing multiple project-specific IDE sessions is an exercise for the
# reader.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment