tmux-plugins / tmux-resurrect Goto Github PK
View Code? Open in Web Editor NEWPersists tmux environment across system restarts.
License: MIT License
Persists tmux environment across system restarts.
License: MIT License
Firstly, thanks for your effort on this good plugin. I have tested several times, I found that the first panel I created always failed to resurrect. I have checked the saved file, I see the directory and vim file are all looks good. But the first panel always just use the default directory and do not resurrect my vim session, at the same time, other panels are all works well, do you have any idea? thanks.
I run a couple of node.js clients via tmux. I guess it's not a rare case.
Open a GitHub issue if you think some other program should be on the default list.
Done!
Hi, I tried to install this as a plugin using the TPM unfortunately that didn't work. I tried manually afterwards, cloned it and put it under plugins dir, I added the line in the instructions.
run-shell ~/.tmux/plugins/tmux-resurrect/resurrect.tmux
Then run tmux source-file ~/.tmux.conf but get this back:
'/Users/ilteris/.tmux/plugins/tmux-resurrect/resurrect.tmux' returned 127
currently,I couldn't make the plugin work for me. I am on tmux 1.9a. I would love to make this work.
You can check out my tmux.conf file here: https://github.com/ilteris/dotfiles/blob/master/tmux.conf
Thanks in advance.
I would love to see a "per session" handling instead saving the whole server.
Here is the idea:
I have a teamocil config for the bigger projects, which are spawned in the morning. When the day goes on I add new windows/panes to log some stuff or edit a special file(s) in its own place. Day ends with additional mini sessions, which have no name and only some windows ... stuff. I thought to save a clean, good working state of a session so it is easily possible to restore a clean state of this session (aka project/task). At the end of the day you just kill the server with all the mess you created. At the next morning you can spawn your saved sessions one after the other when you need them. This makes manual crafting of session files obsolete and sessions are able to evolve easily. I hope you like the idea :-)
This is how the command line prompt looks for some panes after a restore.
After any key is pressed, the prompt is normalized to this
Apart from how it looks there seems to be no other errors related to this.
Interestingly, this "garbled prompt" does not appear for all panes, only for some.
This needs some investigation as I'm not sure why it happens.
It all depends on how the new pane is started. I know that there has been changes made via #43 but, given the way I then to launch ssh/mosh connections, it fails.
I have functions set up to launch a new pane with either ssh or mosh like so:
function smosh () {
tmux neww -n $1 "/usr/bin/mosh $*"
}
function ss () {
tmux neww -n $1 "/usr/bin/ssh $*"
}
Now with the new update, the base command gets saved, it just mosh-client or ssh. If I create a new pane via tmux new-window and then start the same commands as above, saving the full command plus arguments work. My last file looks like:
pane TeSt 1 :bash 0 : 0 :/home/don 1 bash :
pane TeSt 2 :loki 0 : 0 :/home/don 1 mosh-client :
pane TeSt 3 :loki 0 : 0 :/home/don 1 mosh-client :mosh-client loki | 192.168.1.10 60004
pane TeSt 4 :loki 0 :- 0 :/home/don 1 ssh :
pane TeSt 5 :bash 1 :* 0 :/home/don 1 ssh :ssh loki
window TeSt 1 0 : 6b22,273x88,0,0,13
window TeSt 2 0 : 6b23,273x88,0,0,14
window TeSt 3 0 : 6b24,273x88,0,0,15
window TeSt 4 0 :- 6b25,273x88,0,0,16
window TeSt 5 1 :* 6b26,273x88,0,0,17
state TeSt
Where panes 2 & 4 are using my bash functions above, and panes 3 & 5 are using the new-window and then start the command method.
I have tracked the issue to the way the PID is passed to $HOME/.tmux/plugins/tmux-resurrect/save_command_strategies/ps.sh, but I am not sure where to go look to get it the correct PID of the pane.
Please let me know what other I can provide, or where I can go look to help fix this issue. This is a major road-block on my adoption of this fine plugin full time.
Thanks!
d
This plugin is awesome, and everything works perfectly fine, except for the first panel of the first window.
When I save the session with ressurrect, execute tmux detach
, execute tmux new -s work
and then reload the environment using ressurrect, the first panel of the first window keeps the same state that my raw terminal had just after tmux was detached. All the other panels, on all the other windows work just fine.
My environment:
osx 10.9.3
terminal 2.4
tmux 1.9
Let me know if you need anything any more information about this issue.
Please consider saving Bash history for each pane. This can be done relatively simply (on Bash side) by using following commands:
# save history
history -w $HISTORY_FILE
# restore
history -r $HISTORY_FILE
How to send these commands to each pane is a trickier question, but I believe tmux's send-keys
functionality can achieve this - at least when no program is running in given pane.
When I attempt to set the resurrect-restore variable to 'C-r', the binding seems to disappear. Here are the steps to reproduce this:
tmux list-keys | grep 'resurrect'
bind-key M-r run-shell ~/.tmux/plugins/tmux-resurrect/scripts/restore.sh
bind-key M-s run-shell ~/.tmux/plugins/tmux-resurrect/scripts/save.sh
set -g @resurrect-restore 'C-r'
in ~/.tmux.conf
, as mentioned by @bruno in #29.tmux list-keys | grep 'resurrect'
bind-key M-s run-shell ~/.tmux/plugins/tmux-resurrect/scripts/save.sh
Any ideas why the binding disappears? I'm also running on OS X if that information helps.
I just completed my first bash history save. Unfortunately, in one pane I'm ssh'd into a remote session. The "history -w" command is echoed to the remote session.
Perhaps one way to easily determine if a user is connected to a remote session in a particular pane would be to look for a key or pattern in the user's bash prompt? The prompt should follow a consistent pattern on the local host, so when that prompt changes it could be deduced that the user has remote connection, therefore, don't try to save the history for that pane.
Another option would be to insert a key into the prompt and just look for that.
So I just saved a session and tmux outputed session saved as it was suposed to.
Now I've just created a new session and when I hit ctrl-a ctrl-r I get a message saying 'No results!'
Any idea why?
How to reproduce:
Split panehorizontally (prefix + ")
Maximize one pane (prefix + z)
Save session (prefix + alt s)
Restart tmux
Load session (prefix + alt r)
Unmaximize pane (prefix + z)
Result:
Instead of having a horizontal split you now have a vertical split.
If you have multiple panes (in any layout) then all of them are vertically split after loading the session.
Here are two examples of four panes in the ~/.tmux/resurrect/last:
window»·0»0»0»: »·65e6,211x63,0,0{105x63,0,0,0,105x63,106,0[105x30,106,0,1,105x32,106,31{52x32,106,31,2,52x32,159,31,3}]}
window»·0»1»0»:Z»·5de1,211x63,0,0,12
As can be seen the first window has 4 panes which have a proper layout. The second window has a maximized window, but there is no information saved about the layot of the rest.
This problem happens when I have this in my .tmux.conf file: set -g @resurrect-processes 'karma'
The command I run is: karma start karma-unit.conf
When resurrecting, it says: tmux restore complete. But nothing really happened. It didn't restored karma and there are no errors in the console.
As stated in #32 this should work. I run commands with arguments, but they not saved properly it seems. Test case: I ran tail -f README.md
in the session "test", this is what was saved in 'last':
pane 0 0 :zsh 1 :* 0 :/home/hoschi 1 zsh :
pane project-context-manager_second 0 :grunt 0 :- 0 :/home/hoschi/repos/sweetp-code/services/project-context-manager 1 zsh :
pane project-context-manager_second 1 :zsh 1 :* 0 :/home/hoschi/repos/sweetp-code/services/project-context-manager 1 zsh :
pane project-context-manager_vim 0 :vim 1 :* 0 :/home/hoschi/repos/sweetp-code/services/project-context-manager 1 vim :vim
pane project-context-manager_vim 1 :git 0 :- 0 :/home/hoschi/repos/sweetp-code/services/project-context-manager 1 zsh :
pane project-context-manager_vim 2 :vim 0 : 0 :/home/hoschi/repos/sweetp-code/services/password-manager 1 vim :vim
pane project-context-manager_vim 3 :vim 0 : 0 :/home/hoschi/repos/sweetp-code/services/base-nodejs/lib 1 vim :vim
pane project-context-manager_vim 4 :vim 0 : 0 :/home/hoschi/repos/sweetp-code/services/github-issues 1 vim :vim
pane serien 0 :desktop 1 :* 0 :/home/hoschi 1 zsh :
pane serien 0 :desktop 1 :* 1 :/home/hoschi 0 zsh :
pane test 0 :git 1 :* 0 :/home/hoschi/repos/chrome-app-samples 1 tail :tail
pane tmux-conf 0 :vim 1 :* 0 :/home/hoschi 1 vim :vim
pane tmux-conf 1 :vim 0 :- 0 :/home/hoschi 1 vim :vim
pane tmux-conf 2 :man 0 : 0 :/usr/share/man 1 zsh :
pane tmux-conf 3 :zsh 0 : 0 :/home/hoschi 1 zsh :
window 0 0 1 :* d23d,151x78,0,0,0
window project-context-manager_second 0 0 :- d23e,151x78,0,0,1
window project-context-manager_second 1 1 :* d23f,151x78,0,0,2
window project-context-manager_vim 0 1 :* d240,151x78,0,0,3
window project-context-manager_vim 1 0 :- d241,151x78,0,0,4
window project-context-manager_vim 2 0 : d242,151x78,0,0,5
window project-context-manager_vim 3 0 : d243,151x78,0,0,6
window project-context-manager_vim 4 0 : d244,151x78,0,0,7
window serien 0 1 :* f619,151x78,0,0[151x48,0,0,8,151x29,0,49,9]
window test 0 1 :* 694f,151x78,0,0,10
window tmux-conf 0 1 :* 6950,151x78,0,0,11
window tmux-conf 1 0 :- 6951,151x78,0,0,12
window tmux-conf 2 0 : 6952,151x78,0,0,13
window tmux-conf 3 0 : 6953,151x78,0,0,14
state test test
Only tail got saved, not the arguments:
pane test 0 :git 1 :* 0 :/home/hoschi/repos/chrome-app-samples 1 tail :tail
Here is my config:
# Activity monitoring
#setw -g monitor-activity on
#set -g visual-activity on
# Highlight active window
#set-window-option -g window-status-current-bg red
set -g default-terminal "screen-256color"
# utf8 is on
set -g utf8 on
set -g status-utf8 on
# address vim mode switching delay (http://superuser.com/a/252717/65504)
set -s escape-time 0
# tmux messages are displayed for 4 seconds
#set -g display-time 4000
# refresh 'status-left' and 'status-right' more often
#set -g status-interval 5
# Highlight active pane
#set-option -g pane-active-border-style bold
set-option -g pane-active-border-bg blue
# use powerline as status line
source '/home/hoschi/src/powerline/powerline/bindings/tmux/powerline.conf'
# create splits by | and -
unbind %
bind | split-window -h
bind - split-window -v
unbind p
# -n is for 'now prefix' !
bind-key -n F7 previous-window
bind-key a previous-window
bind-key -n F8 next-window
bind-key e next-window
bind-key C-b last-window
# renumber window so they have always continuing numbers
set -g renumber-windows on
# use vim motion keys while in copy mode
setw -g mode-keys vi
# use mouse!
set -g mode-mouse on
set -g mouse-resize-pane on
set -g mouse-select-pane on
set -g mouse-select-window on
# scroll with mouse wheel in pane, not in terminals scrollbuffer
set -g terminal-overrides 'xterm*:smcup@:rmcup@'
# set history size
set -g history-limit 10000
##CLIPBOARD selection integration
##Requires prefix key before the command key
#Copy tmux paste buffer to CLIPBOARD
#
#
# attention: install xclip!
bind C-c run "tmux show-buffer | xclip -i -selection clipboard"
#Copy CLIPBOARD to tmux paste buffer and paste tmux paste buffer
bind C-v run "tmux set-buffer -- \"$(xclip -o -selection clipboard)\"; tmux paste-buffer"
# List of plugins
# Supports `github_username/repo` or full git URLs
#
# https://github.com/tmux-plugins/tmux-resurrect
# https://github.com/tmux-plugins/tmux-sessionist
set -g @tpm_plugins " \
tmux-plugins/tpm \
tmux-plugins/tmux-resurrect \
tmux-plugins/tmux-sessionist \
"
# Other examples:
# github_username/plugin_name \
# [email protected]/user/plugin \
# [email protected]/user/plugin \
# initializes TMUX plugin manager
run-shell ~/.tmux/plugins/tpm/tpm
# https://github.com/tmux-plugins/tmux-resurrect
set -g @resurrect-processes 'ssh "git log" grunt-wrapper tail'
I'm on Arch Linux, tmux version is 1.9a
Hi
I am starting to use this great plugin. I have created a session, but when I restore it, my panes are not in the dirs I left them at. I didn't find anything in the readme about this, do I need to do something special?
thanks
Not sure what im doing wrong, but hitting prefix+alt-s does nothing for me :(
Really excited about this project though :)
Would it be possible to set up auto save for tmux-resurrect.
Just two extra configuration settings: enable or disable autosave and autosave interval.
Hey nice useful project here.
I noticed set -g @resurrect-processes '"~node-dev"'
doesn't work, but i think set -g @resurrect-processes '"~node"'
did restore, but restored only a blank node session, not my original node-dev index.js
command.
I think node-dev
actually calls node
and the process runs as node.
What if tmux-restore detected whether a window had a process running, and you based restoring on the command that caused that program to run?
If I add node to my processes, i get a terminal that runs as if I had merely called node
by itself, and it appears not to care what initially spawned the process.
This could be possible, right, by sniffing the history? I see the list of processes as a whitelist, interested by the currently running processes during a save. If they match, then run the same command again. Right?
I'm wondering if there is a way to restore automatically from command line. Similar to tmux kill-server
except it would be something like tmux resurrect
Lets say on server start I would like to automatically restore the session so it is there for me the first time I log on. Is it possible or does one have to <ctrl>R
after opening tmux?
When saving bash history, the "history" command itself should be pruned from the saved history file. That command isn't really part of the user's history, rather it is a side-effect of saving the bash history via the tmux script.
I would like to be able to restore multiple local programs - starting with "./"
Currently there is two issues:
1 the "./" is stripped from the command
==> instead of running './my_program', it will run 'my_program' and display
my_program: command not found
2 To only start some local programs, I should be able to add to the tmux.conf
set -g @resurrect-processes './my_program'
Should run grunt using "grunt development"
I'm using this setting in .tmux.conf: set -g @resurrect-processes ':all:'
This is the output in the console when resurrecting:
grunt ARCHFLAGS=-arch i386 -arch x86_64 Apple_PubSub_Socket_Render=/tmp/launch-Ou97Qf/Render
➜ pdm git:(master) ✗ grunt ARCHFLAGS=-arch i386 -arch x86_64 Apple_PubSub_Socket_Render=/tmp/launch-Ou97Qf/Render
Warning: Task "ARCHFLAGS=-arch" not found. Use --force to continue.
Saving currently running program should be easy.
Restoring is trickier because we don't want to restore everything (think - long running jobs, servers etc). There should be a conservative list of programs that should be automatically started, and the user should be able to enhance it.
List of programs that should be restored:
I started using tmux-resurrect recently, and I really like it, but I seem to have a problem with window names.
Before I started using tmux-resurrect, window names would be updated based what was running in them at the time. When working on a resurrected session, however, the names of the resurrected windows never change: If I run vim on one of them, the name is still bash. If I quit vim on one that was already called vim (because it was running vim when I saved the session), its name keeps being vim.
First off, this is an absolutely awesome project and I'm already using it to great success.
While looking through the code I noticed that scripts/save.sh
is writing a tab-delimited file of all of the session, window, and pane settings. Later on, scripts/restore.sh
reads and parses that file, executing TMUX commands as it goes.
I think it would be much simpler to have the file that scripts/save.sh
writes be valid, parseable tmux commands. This would help with reading and debugging of the saved session files and would make scripts/restore.sh
much simpler.
I'm happy to put up a PR to refactor this, but I wanted to get your thoughts first.
irb
executes this and that fails:
$ irb RBENV_VERSION=1.9.3-p429
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.