Live data from Hacker News

Show HN: Restore tmux environment after a system restart

github.com

41–48 of 48 posts

Re: Show HN: Restore tmux environment after a system restart

#43

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…

The 'tmux' plugin for oh-my-zsh (https://github.com/robbyrussell/oh-my-zsh) does this. If you want to avoid bloat you could just extract the script.

EDIT: though I believe you'd need to have that on the server side.

Re: Show HN: Restore tmux environment after a system restart

#44
post #35

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…

What is the point of this:

  "${STARTED_TMUX:-x}" = x
vs.

  -z "$STARTED_TMUX"
or

  "$STARTED_TMUX" = ""
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?

Re: Show HN: Restore tmux environment after a system restart

#45
post #38
post #9

Earlier quoted context omitted.

or Goreman. https://github.com/mattn/goreman

or Forego! https://github.com/ddollar/forego

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?

Re: Show HN: Restore tmux environment after a system restart

#46
post #4

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).

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.

1: https://github.com/remiprev/teamocil

Re: Show HN: Restore tmux environment after a system restart

#47
post #35

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…

> I also don't recall why the "sleep" command is in there.

Probably this issue? http://superuser.com/questions/629227/tmux-prints-12c-whenev...

Re: Show HN: Restore tmux environment after a system restart

#48

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 bas…

There is such a tool here https://github.com/c0rner/scripts/blob/master/tmux_save
Post reply on HN