tmux-plugins / tmux-continuum

Continuous saving of tmux environment. Automatic restore when tmux is started. Automatic tmux start when computer is turned on.
MIT License
3.29k stars 149 forks source link

Not working on OSX 10.10.1 with tmux 1.9a #1

Open chiedo opened 9 years ago

chiedo commented 9 years ago

Hey man! The good news is that the following now works

~/.tmux/tmux-continuum/scripts/continuum_restore.sh

The bad news is that tmux is starting when I restart my computer but still isn't automatically doing the tmux resurrect.

On that note, I also noticed that with my autosaves didn't seem to be happening so I set my interval to 1 to confirm and no autosaves happen. That may give you a clue?

Below is my updated .tmux.conf.

# This allows copy and paste in vim, etc. to work with tmux
#if-shell "uname | grep -q Darwin" "set-option -g default-command 'reattach-to-user-namespace -l zsh'"

setw -g mode-mouse on
set -g mouse-select-pane on
set -g mouse-resize-pane on
set -g mouse-select-window on
set -g mode-keys vi

# force a reload of the config file
unbind r
bind r source-file ~/.tmux.conf

bind L resize-pane -L 5 
bind D resize-pane -D 5 
bind U resize-pane -U 5 
bind R resize-pane -R 5

#### COLOUR (Solarized 256)

# default statusbar colors
set-option -g status-bg colour235 #base02
set-option -g status-fg colour136 #yellow
set-option -g status-attr default

# default window title colors
set-window-option -g window-status-fg colour244 #base0
set-window-option -g window-status-bg default
#set-window-option -g window-status-attr dim

# active window title colors
set-window-option -g window-status-current-fg colour166 #orange
set-window-option -g window-status-current-bg default
#set-window-option -g window-status-current-attr bright

# pane border
set-option -g pane-border-fg colour235 #base02
set-option -g pane-active-border-fg colour240 #base01

# message text
set-option -g message-bg colour235 #base02
set-option -g message-fg colour166 #orange

# pane number display
set-option -g display-panes-active-colour colour33 #blue
set-option -g display-panes-colour colour166 #orange

# clock
set-window-option -g clock-mode-colour colour64 #green

# VIM COPY AND PASTE BINDINGS BELOW.
# To enter copy mode, press {prefix} esc
# Use vim keybindings in copy mode
setw -g mode-keys vi
# Setup 'v' or 'V' to begin selection as in Vim
unbind [
bind Escape copy-mode

bind -t vi-copy v begin-selection
bind -t vi-copy V rectangle-toggle # `V` changes between line- and columnwise selection

# Clear scrollback. {prefix} Cntrl K
bind -n C-k clear-history

#Allow tmux Resurrect - prefix then ctrl-s to save. prefix then ctrl-r to restore
run-shell ~/.tmux/tmux-resurrect/resurrect.tmux
# Allow tmux to select text, etc.
run-shell ~/.tmux/tmux-copycat/copycat.tmux
# tmux yank. Enable copy selected text to the clipboard. Needs the above with prefix + y.
run-shell ~/.tmux/tmux-yank/yank.tmux
# MUST BE LAST COMMAND RUN: Auto run tmux ressurect every 15 minutes and auto ressurect when opening a new window
set -g @continuum-boot 'on'
set -g @continuum-restore 'on'
set -g @continuum-save-interval '1'
run-shell ~/.tmux/tmux-continuum/continuum.tmux
#run-shell ~/.tmux/tmux-continuum/scripts/continuum_restore.sh

# Commands cheatsheet
# Within tmux
# prefix + ?: see all potential commands within tmux
# prefix + s: switch to a new session
# prefix + z: make the current pane take up the whole window. Toggleable.
# prefix + cntrl o: rotate window
# prefx + cntrl k: clear any text in the pane that is currently not visable.
# prefix + ctrl s: save all current sessions
# prefix + ctrl r: restore all current sessions from the last save point (eg. after a computer restart)
# prefix + Escape: enter copy mode
# - v: enter vim selection so you can copy.
# -- V: toggle back and fourth betmween block copy mode.
# - y: copy current selection to the clipboard.
# prefix + /: enter search mode for tmux pane
# prefix + :rename: allow you to rename the current session
# prefix + d: dettach the current session without ending it.
# prefix + x: close the current pane
# prefix + &: close the current window
# prefx + %: horizontal split
# prefix + ": vertical split
# In the terminal:
# man tmux: see all potential commands within tmux
# tmux a -t SESSIONNAMEORNUMEBR: re open that session
# tmux list-sessions: lists all the sessions available to be connected to
# tmux kill-server: kill all live sessions
chiedo commented 9 years ago

We're getting close to a fix though! :)

bruno- commented 9 years ago

Hey, oh I see you upgraded to tmux-continuum, cool.

About environment not saving.. how did you check that? Save is done un-intrusively in the background so a spinner in tmux is not shown. The way to check if "auto save" is working is to do $ ls -al ~/.tmux/resurrect. Save files are stored in that dir. Files have timestamps in the name so you can verify when the last save happened.

I was gonna write you a couple other things you can try to debug a "auto save" feature.. but what do you say we do a quick session over google hangouts (or skype) and we debug both "auto save" and "auto restore" together? I can make 15 minutes for this anytime so let me know when you're free? Also drop me an email if you wanna send e.g. a skype username.

chiedo commented 9 years ago

Hey man! Yeah, I was checking the autosaves by looking in the ~/.tmux/ressurect folder.

I think a session over Google hangouts sounds like a good call.

Just sent you an email!

chiedo commented 9 years ago

After a Skype session, we have determined that something is going wrong here

It seems like the ampersand is being ignored because the script is not running asynchronously

chiedo commented 9 years ago

Progress: I switched to tmux plugin manager and the plugin works like a charm, although, it doesn't restore my vim session. No big deal there though.

On that note, without the plugin manager, I was able to get things working by adding the following to the end of my tmux.conf file instead. The -b (background) flag seems to have had some affect. I'm not sure if that helps you at all. In either case, the plugin is mostly working with the plugin manager.

run-shell ~/.tmux/tmux-continuum/continuum.tmux
run-shell -b ~/.tmux/tmux-continuum/scripts/continuum_restore.sh
bruno- commented 9 years ago

Thank you for the time today @chiedojohn. I'll try to reproduce the issue with backgrounding on that line. I forgot to ask, what bash version you're running? Just $ bash --version.

chiedo commented 9 years ago

No prob man!

GNU bash, version 3.2.53(1)-release (x86_64-apple-darwin14)

bruno- commented 9 years ago

I've opened a question for this on stackoverflow.

chiedo commented 9 years ago

Perfect

unphased commented 9 years ago

I looked at the old tmux-resurrect-auto code and that used to work (and it uses backgrounding as well).

Well I am on 10.10.3 and it does not work here either.

But it's possible that OSX (or an Xcode CLI Tools) upgrade broke this somehow.

bruno- commented 9 years ago

We've spent a lot of time trying to debug this. I never managed to reproduce this (also OSX 10.10.3). Any hint here is appreciated.

unphased commented 9 years ago

hmm so for you the auto-resurrect just works?

probably a starting point would be having the bash subscripts write logs to files, right?

bruno- commented 9 years ago

Yea, everything works just fine for me. Both the "auto restore" and "restore after boot" features.

As for debugging auto restore, yea, the first step would be to put some debugging lines into the main script and this script and see what gets executed and what not.

IIRC when we last debugged the main issue was that the continuum_restore.sh script wasn't executing properly in the background. That background invocation is here and I couldn't figure out why that doesn't work for some users.

unphased commented 9 years ago

Haha my machine locked up again because I forgot to force the Nvidia GPU again, and this time when it booted the auto restore worked! Hopefully that means auto save will also work (I do know how to check that).

bruno- commented 9 years ago

Good to hear that things actually work for you.

You can check if auto save by checking the timestamp of ~/.tmux/resurrect/last file. Execute this command:

ls -al ~/.tmux/resurrect/last

And check the hour and minutes. Auto save saves in an interval of 15 minutes by default so if you check the file again in 15-20 minutes the timestamp should be updated.

People haven't reported many issues about auto-save, so I think that one should work (but please let us know).

andrius commented 8 years ago

Hello, I facing the same issues on OSX. tmux version 2.1

This code works, however described in the docs methods with plugin manager won't.

run-shell ~/.tmux/tmux-continuum/continuum.tmux
run-shell -b ~/.tmux/tmux-continuum/scripts/continuum_restore.sh

I am using continuum on top of https://github.com/skwp/dotfiles, plugin loading through ~/.tmux.conf.user:

run-shell '~/.tmux/plugins/tmux-resurrect/resurrect.tmux'
set -g @resurrect-strategy-vim 'session'
set -g @resurrect-strategy-nvim 'session'

run-shell '~/.tmux/plugins/tmux-continuum/continuum.tmux'
run-shell -b '~/.tmux/plugins/tmux-continuum/scripts/continuum_restore.sh'
set -g @continuum-boot 'on'
set -g @continuum-boot-options 'iterm'
set -g @continuum-restore 'on'
clx123 commented 8 years ago

I have installed tmux-resurrect and tmux-continuum-master plugin. I am having below issues.

  1. tmux-resurrect works with manual save and restore
  2. It restores the window titles and number of windows only. No command history etc. I have remote connections (ssh) which it doesn't restore. In all my windows, I see local host.

Please help if its possible to restore the ssh state as thats the only thing I want when I meant 'restore'

Another point is that, continuum doesn't save or restore sessions automatically. when I set the status in my status bar, I don't see any status (duration or on/off) . So I guess its not working?

mdkcore0 commented 8 years ago

Hi, first time using continuum (already resurrect user). After installing and adding continuum status it showed me as off. I had to set the save interval to 15 on tmux.conf to have it working.

The documentation is not very clear at this point, I though just installing it (and reloading tmux.conf) should have started the process.