9 ms·
Tmux Resurrect – Persists tmux environment across system restarts
- avolcano 11y agoI've been using this for a few months, since for some reason my work Macbook really likes to crash when it goes into sleep mode (have a feeling it's related to our Vagrant/VMWare setup, but haven't had a chance to investigate). It works better than any similar tmux plugin I've tried, and is dead-simple to use. I particularly like that there's a "whitelist" of which running commands it will restore, so I can e.g. restore both VIM sessions and my Webpack watchers when I restore my session.
- lobster_johnson 11y agoIf you're on OS X Yosemite, the "sleep wake failure" problem is a well-known issue that is (probably) not hardware-related. I have it, my colleagues (some of whom have brand new machines) have it, and it's probably what you are affected by. The symptom is that the machine will frequently reboot instead of coming out of sleep. From the looks of things, it's related to the 70-minute sleep-to-standby setting (where the machine will turn itself off), which can be changed with "pmset".
- Galanwe 11y agoIs it also able to restore ssh session? Like, host and working directory at least?
- icebraining 11y agoI doubt it, since the TCP connection will probably have timed out. Try using mosh: https://mosh.mit.edu/ https://mosh.mit.edu/
- Galanwe 11y agomosh is nice, but I don't feel like installing a not well established ssh server replacement on hosts at work.
- qznc 11y agoWhy? Technically, it is not a replacement, since it requires a ssh server for authentication.
- baldfat 11y ago> Mosh is a replacement for SSH. (https://mosh.mit.edu https://mosh.mit.edu) First sentence in second paragraph.
- semiquaver 11y agoIt's a matter of semantics. Parent is correct that mosh requires SSH to function. From the same page you linked: > Mosh doesn't listen on network ports or authenticate users. The mosh client logs in to the server via SSH, and users present the same credentials (e.g., password, public key) as before. Then Mosh runs the mosh-server remotely and connects to it over UDP.
- baldfat 11y ago"Technically Speaking" = Political Double Talk I know I will continue to be down voted BUT you need to get into politics. Because you are arguing the whole sentence "MOSH is a replacement for SSH." Means It is NOT a replacement? Argument is it has SSH as a requirement so "technically" it isn't replacing SSH, even though based on precise facts it actually does kill SSH and replace it when it is used? The authors of MUSH clearly make a one sentence statement of purpose to "replace SSH." Your statement "It isn't a replacement for SSH." is more correct? It does have SSH required but it uses it for a limited authorization and than SSH on TCP is abandoned once the connection established and the connection is handed over (Replaced) to a MOSH UDP with encryption that is totally independent from SSH. Makes me crazy that "technically" always means I will say the EXACT opposite of the statement and say that my opposite is more accurate than the stated statement. This statement is technically true based on facts and declaration of the authors. MOSH is a mobile shell that replaces SSH connections. It doesn't matter that SSH is there the SSH connection is replaced with a UDP MOSH connection. Does it in literal sense in its actions.
- fphilipe 11y agoBy default it only restores a program that is whitelisted, such as vim, man, etc. You could, I guess, tell it to also restore ssh sessions. Here's a guide on how to do that: https://github.com/tmux-plugins/tmux-resurrect/blob/master/docs/restoring_programs.md https://github.com/tmux-plugins/tmux-resurrect/blob/master/d...
- Galanwe 11y agoWill have a look, thanks. I was dreaming of something that could restore tmux sessions, along with its ssh connections, and the vim inside the ssh :D seems like christmas is not for today.
- icebraining 11y agoYou could use a bastion host to run the tmux. If your client machine were to disconnect/reboot, the bastion host would keep the sessions open. You'd just need to login to it and re-attach tmux.
- rjaco31 11y agoYou don't need anything beside regular tmux for that, since if your computer crashes but not the remote host, and if you were using tmux on the remote host, the tmux session will still be open, just ssh again and "tmux -a" and you'll jump back into the tmux session exactly where you left it.
- OJFord 11y agoConsidering that I recently ran home with a rapidly flattening battery - precisely so that I would not lost my session - I am very pleased to find this here :D
- iso8859-1 11y agowhy not hibernate?
- aargh_aargh 11y agohttp://www.sickenger.com/2013/02/hibernate-just-stop-it/ http://www.sickenger.com/2013/02/hibernate-just-stop-it/ <jk>
- OJFord 11y agoMac. Does sleep when battery flat, rather than "die" completely - but how long do you trust it for? Knowing Sod's Law, I opted for the run.
- mikeash 11y agoNewer Macs will save the memory to nonvolatile storage so they can withstand total power loss. The question of trustworthiness remains, though.
- rcthompson 11y agoMy experience with my Macbook is that around 20% battery, it just dies. No sleep, no hibernate, it just goes completely dark and when I plug it back in it has to boot from scratch.
- mikeash 11y agoSounds like you have a bad battery or something like that, which is causing the battery meter to be inaccurate and is thus interfering with the rest of the process. To safely sleep/hibernate your machine the system has to have a pretty good idea of just how much energy is left in the battery, since it has to initiate the process before the battery goes completely flat. On a properly working machine, you should get all the way down to 0%, and then it will forcibly sleep if you don't do it yourself. Have you tried an SMC reset? That's the low-level whatnot that controls the battery, and sometimes it can get confused.
- manish_gill 11y agoI love this plugin. Usually, my mac stays online for days and even weeks, but any time I go down (or for some certain software updates when I have to restart it), it really sucks to lose all your environmental setup. I combine it with a few lines of code in my ~/.zshrc to automatically enter the virtualenv for the current directory. Works out really nice! :)
- baby 11y agothere's a oh-my-zsh plugin for that
- abledon 11y agoHas anyone here ported from Tmuxinator to Tmux Resurrect? Was it a Success?
- brunosutic 11y agoJust in case you missed it, there's a guide how to migrate from tmuxinator to tmux-resurrect: https://github.com/tmux-plugins/tmux-resurrect/blob/master/docs/migrating_from_tmuxinator.md https://github.com/tmux-plugins/tmux-resurrect/blob/master/d...
- flyingyeti 11y agoI read that, but as a rather heavy user of tmuxinator, I wouldn't really want to have all my projects running in the background at all times. I like that with tmuxinator, I can just start up the project(s) I'm currently working on, and leave the rest idle. I am going to try out tmux-resurrect, but it's value to me would be mostly for ad-hoc tmux sessions; I think I'll still set up dedicated tmuxinator configs for each of my longer term projects.
- mzs 11y agoThanks for this! I've done something horrible in the past when I knew about coming rolling power outages - snapshoting virtual box. It worked but was sort of annoying.
- davvolun 11y agoBeen using tmux resurrect for awhile now and I love it...one thing occurs to me though: does anyone have a hack to automatically save my tmux session on disconnect? Edit: ahha, not exactly what I asked for, but linked on the tmux-resurrect page is tmux-continuum, automatic saving of tmux sessions. Perfect for me.
- pdexter 11y agoWait... what? That's the whole point of tmux. As far as I know there's no such thing as 'saving'. They're automatically saved. Unless you're on a shared computer? If so... here's a solution I wrote up a while ago: --- title: Tmux on a shared server --- Normally, tmux stores its session sockets in the /tmp directory. This is bad news when trying to run tmux on a shared computer (e.g. shared compute nodes) since the tmp directory is probably cleared on every login. To get around this tmux offers a way to store session sockets in alternative locations. How to use this isn't entirely clear in the man page though, so I'll outline it here. First, I'll create a directory to store the socket with ``mkdir ~/.tmux.socket'`{.bash}. Tmux stores new session sockets in the tmp directory so we must change that when we start tmux: TMPDIR=~/.tmux.socket tmux and to attach to this socket we use the `-S`{.bash} option and glob to the socket (defaulted to be named `default`{.bash}) tmux -S ~/.tmux.socket/*/default attach Here are some aliases to put into your shell config file to help: alias tmux-start="TMPDIR=~/.tmux.socket tmux" alias tmux-attach="tmux -S ~/.tmux.socket/*/default attach"
- farresito 11y agoHe probably means saving on computer shutdown or reboot.
- pcl 11y agoI wrote a far more basic zsh config script that integrates with OSX's Terminal.app window restoration to restore the current working directory in each tab after quit / relaunch. Between that and browser tab restoration on reboot, I don't mind the occasional restart any more. https://gist.github.com/pcl/f2c6a6f6f193400eeaa6 https://gist.github.com/pcl/f2c6a6f6f193400eeaa6
- deleted 11y ago[deleted]
- baby 11y agoWhat I don't like is that you have to manually save/restore every time.
- brunosutic 11y agoThere is tmux-continuum that works with resurrect to automate saving/restoring. https://github.com/tmux-plugins/tmux-continuum https://github.com/tmux-plugins/tmux-continuum
- TomAnthony 11y agoI gave up on tmux on my Mac, as I mainly used it with teamocil to have saved layouts of panes and commands, but I never disconnected from it. I found quite a few people use it this way. I wrote iTermocil[2] to replicate the functionality of teamocil natively in iTerm2, so I could have all the upsides (from my POV) but keep native UI elements etc. [1] https://github.com/TomAnthony/itermocil https://github.com/TomAnthony/itermocil
- graffitici 11y agoI didn't know about Teamocil, I use Tmuxinator for the same purpose. The latter seems to have more stars on GH, any reason why prefer the former?
- TomAnthony 11y agoSimple because I came across teamocil first, as someone recommended it to me. It is actually teamocil that led me to tmux! I have since come across tmuxinator, which is almost identical, but from my reading of tmuxinators docs it seems it is more flexible in how you can configure it. I'm adding tmuxinator support to iTermocil. :)
- graffitici 11y agoBrilliant, looking forward!
- MoSal 11y agoThis is the greatest thing since ... tmux. If only @resurrect-save-zsh-history was implemented.