I also really love tmuxp, which lets you save tmux sessions as json files and save/reload them later. Great for setting up tmux sessions for different workflows.
Holy. Wow. This is the most exciting thing that I've seen this weekend. I've created hacks on hacks to get around this problem. I'm SO happy about this! Thank you!
Great! Now can someone tell me how to configure tmux so that I can have two connected term emulators use multiple virtual consoles in one session? Screen allows you to do this and I've been searching for a way to get tmux to behave the same way.
(In fact, I've had a real problem getting tmux to behave well at all when multiple term emulators are connected to the same session. I've had weird window resizing problems.)
The one problem with this approach is that each session created this way (i.e. one that "attaches" to an existing session) actually creates a new "mirror" (?) session that will eventually clutter up your list of existing sessions.
My workaround is to create an initial named session (tmux new-session -s name), then attach to that named session. I never use "tmux ls" :p
You may also want to add "set-window-option -g aggressive-resize on" to your .tmux.conf (or prepend with "tmux" and run it in an existing session). To quote the manpage: "will resize the window to the size of the smallest session for which it is the current window, rather than the smallest session to which it is attached".
BTW do people use tmux/screen to start multiple apps for development?
I'm looking for a way to start nginx/sass watcher/js builder/web app in a split screen, and also stop them all with one command (which would send ctrl-c to all windows). Now I just use tabs (OSX).
Check out tmuxinator: https://github.com/tmuxinator/tmuxinator. You can create configurations for your projects that specify windows, panes, which apps to run, etc. It's great for starting all the servers/shells/workers required for a project.
After using Goreman for a few days, I miss a way to restart a single process. Maybe just typing that process number should restart it... do you know if any of the solution do this?
I find teamocil[1] for this use case, usually with one window opening a vimsplit of TODO, README, CHANGELOG etc, one window to launch a vagrant machine (which then runs all the daemons), another for guard/rspec output, and other windows for key files currently being worked on.
I just installed it and played around with it for a bit - it's a really nice - but what I would kill for is something that would restore tmux server state - including the various scroll-back-buffers.
One of the few reasons I still drop out of tmux, and switch over to Terminal.app (iTerm2 might do this as well natively) - is when you have a system crash or Kernel Panic (which happens all to often with OS X -weekly basis, or daily if I'm plugging/unplugging the USB -> Serial adapters), and OS X reboots - Terminal.app restores all of my history buffers - so I don't lose any of the work in my screens.
Yes, I know script is a good way of doing this - but When you are opening a dozen or so windows, it's nice to be able to just scroll back in your history to see what you are working on.
Even if I could just do this prior to doing something dangerous (like unplugging a USB cable), that would be great.
I just noticed, that both of these plugins are by the same developer, brunosutic, - so perhaps we'll see this feature in the future. If so, super excited! :-)
I thought session restore for tmux was awesome, and then I got to know that tmux has a plugin manager and fuzzy history search! brunosutic, you made my day.
Tangentially, anyone know how to run tmux (or screen) so that SSH sessions automatically attach?
Ie., I want every interactive connection to automatically attach to a session on the server if one exists, otherwise create one, so that when I disconnect or quit, my shell stays.
I tried to hack a solution using .zshrc a while ago, but it just didn't work properly and/or didn't handle all the edge cases, I forget exactly.
I have this in my .kshrc, can't recall where I found it.
if [ "$PS1" != "" -a "${STARTED_TMUX:-x}" = x -a "${SSH_TTY:-x}" != x ]
then
STARTED_TMUX=1; export STARTED_TMUX
sleep 1
( (tmux has-session -t remote && tmux attach-session -t remote) || (tmux new-session -s remote) ) && exit 0
echo "tmux failed to start"
fi
I also don't recall why the "sleep" command is in there.
Edit: to clarify, this is in the .kshrc of my work machine. When I start xterms on that machine, they just get a normal shell because $SSH_TTY is not set. When I ssh into my work machine from elsewhere, I get attached to the tmux session (if any) or one is started.
It's always seemed like a legacy method of testing to empty string from a time when "" wouldn't be parsed as an argument. Is there any real reason to still do that today?
This looks like a cool project, although I personally prefer separate tmux sessions for each project.
Also, am I missing something, or does this really execute the last command for each pane/window which had a process other than shell running? I can imagine a few potentially dangerous situations if this is how it works.
Some terminal emulators are pretty weird about sending the Alt key. If you open vim, in insert mode, and type <C-v><Alt-s>, it'll show you what is keys are actually being sent. If it's not what you expect, try remapping it to something other than <Alt-s>.
http://tmuxp.readthedocs.org/