Skip to content

Characters in vim after restore #119

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
aka-tpayne opened this issue Nov 13, 2015 · 11 comments
Open

Characters in vim after restore #119

aka-tpayne opened this issue Nov 13, 2015 · 11 comments

Comments

@aka-tpayne
Copy link

When my panes are being restored and should open vim, every single time I end up in Insert mode with "m" on the first line and the cursor below it on the next line.

Here is the contents of my "last" file.

pane    0   1   :bash   1   :*  0   :/Users/tpayne  1   bash    :
pane    prov    1   :vim    1   :*  0   :/private/var/www/projects/prov.2011.drupal 1   vim :vim
pane    prov    2   :ruby   0   :   0   :/private/var/www/projects/prov.2011.drupal 1   bash    :
pane    prov    3   :git    0   :   0   :/private/var/www/projects/prov.2011.drupal 1   bash    :
pane    prov    4   :ssh    0   :   0   :/Users/tpayne/Documents/Proven Winners 1   bash    :
pane    prov    5   :bash   0   :   0   :/private/var/www/projects/prov.2011.drupal 1   bash    :
pane    prov    6   :bash   0   :-  0   :/private/var/www/projects/prov.2011.drupal 1   bash    :
pane    prov-rpt    1   :vim    1   :*  0   :/private/var/www/projects/prov.2013.reports.drupal 1   vim :vim
pane    prov-rpt    2   :bash   0   :   0   :/private/var/www/projects/prov.2013.reports.drupal 1   bash    :
pane    prov-rpt    3   :ssh    0   :-  0   :/private/var/www/projects/prov.2013.reports.drupal 1   bash    :
pane    reap    1   :vim    1   :*  0   :/private/var/www/projects/2015.searchforpublishers.drupal7 1   vim :vim
pane    reap    2   :vim    0   :   0   :/private/var/www/projects/2015.searchforpublishers.drupal  1   vim :vim
pane    reap    3   :sass   0   :   0   :/private/var/www/projects/2015.searchforpublishers.drupal7/sites/all/themes/searchforpublishers    1   ruby    :/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/bin/ruby /usr/bin/scss -t compressed --watch sass/searchforpublishers.scss:css/searchforpublishers.css
pane    reap    4   :bash   0   :   0   :/private/var/www/projects/2015.searchforpublishers.drupal7 1   bash    :
pane    reap    5   :ssh    0   :-  0   :/private/var/www/projects/2015.searchforpublishers.drupal7 1   ssh :ssh searchforpublishers.com
pane    spark   1   :vim    1   :*  0   :/private/var/www/projects/spark-project    1   bash    :
pane    spark   2   :tail   0   :   0   :/private/var/www/projects/spark-project    1   tail    :tail -f /var/log/apache2/error_log
pane    spark   3   :bash   0   :   0   :/Users/tpayne  1   bash    :
pane    spark   4   :vim    0   :-  0   :/private/var/www/projects/prov.2011.drupal 1   vim :vim
pane    tension 1   :bash   1   :*  0   :/private/var/www/projects/2014.drupal.tension.com/sites/all/modules    1   bash    :
window  0   1   1   :*  b100,181x41,0,0,3
window  prov    1   1   :*  b103,181x41,0,0,6
window  prov    2   0   :   b106,181x41,0,0,9
window  prov    3   0   :   58b1,181x41,0,0,12
window  prov    4   0   :   58b4,181x41,0,0,15
window  prov    5   0   :   58b7,181x41,0,0,18
window  prov    6   0   :-  d8b0,181x41,0,0,21
window  prov-rpt    1   1   :*  d8b3,181x41,0,0,24
window  prov-rpt    2   0   :   d8b6,181x41,0,0,27
window  prov-rpt    3   0   :-  58b0,181x41,0,0,30
window  reap    1   1   :*  69e3,272x59,0,0,33
window  reap    2   0   :   69e6,272x59,0,0,36
window  reap    3   0   :   e9e1,272x59,0,0,41
window  reap    4   0   :   e9e4,272x59,0,0,44
window  reap    5   0   :-  e9e9,272x59,0,0,49
window  spark   1   1   :*  58b3,181x41,0,0,52
window  spark   2   0   :   58b6,181x41,0,0,55
window  spark   3   0   :   58b9,181x41,0,0,58
window  spark   4   0   :-  58ba,181x41,0,0,59
window  tension 1   1   :*  d8b1,181x41,0,0,60
state   reap    spark
@bruno-
Copy link
Member

bruno- commented Nov 15, 2015

Hey,
thanks for reporting. The "last" file looks ok.

I'm not sure what could be causing this.

  • are you using tools other than tmux-resurrect like tmuxinator?
  • are you restoring vim sessions with tmux-resurrect as described here?
  • could it be due to some vim shenanigans? (wild guess)

@aka-tpayne
Copy link
Author

Nope, only plugins I'm using is tmux-resurrect and tmux-continuum.
I'm not currently setup to restore vim session

@bruno-
Copy link
Member

bruno- commented Nov 16, 2015

I tried testing this and still can't reproduce.

Based on what you said in the first post it seems tmux-resurrect sends additional characters to the pane after vim is started. That would explain why you end up in insert mode with "m" typed in.. but it's not clear why those characters are sent..

@aleprovencio
Copy link

I also have issues with vim. Using the below attached last file, the window which belongs to the wiki session happens something like what the OP describes, where i get vim resurrected in insert mode (but without C-m). The other vim instance on code session won't even start although panes are created correctly.

pane    0       0       :bash   1       :*      0       :/home/aleprovencio     1       bash  :
pane    code    0       :bash   0       :-      0       :/home/aleprovencio/src/django-royalnew0       bash    :
pane    code    0       :bash   0       :-      1       :/home/aleprovencio/src/django-royalnew1       bash    :
pane    code    1       :vim    1       :*      0       :/home/aleprovencio/src/django-royalnew1       vim     :vim
pane    main    0       :bash   1       :*      0       :/home/aleprovencio/.tmux/resurrect   1bash    :
pane    wiki    0       :vim    1       :*      0       :/home/aleprovencio/usr/wiki    1     vim      :vim
window  0       0       1       :*      b33e,191x51,0,0,1
window  code    0       0       :-      9543,191x52,0,0[191x25,0,0,2,191x26,0,26,3]
window  code    1       1       :*      b321,95x52,0,0,4
window  main    0       1       :*      b322,95x52,0,0,5
window  wiki    0       1       :*      b743,191x52,0,0,6
state   main

@aleprovencio
Copy link

Just found out this is an issue with @continuum-boot

@bruno-
Copy link
Member

bruno- commented Feb 20, 2016

Just found out this is an issue with @continuum-boot

Any idea how it's related to it? Which platform are you running tmux: OSX, Linux?

@aleprovencio
Copy link

This is tmux 2.1 on Arch.

It's something related to the current start command new-session -d because starting tmux this way after a tmux kill-server the mess is there with a full reboot not beeing necessary.

I have a shortcut set on my system that starts a terminal and issues a tmux new-session -A -s main so thats the way I usually start tmux, even before using resurrect/continuum. It works gracefully with @continuum-restore 'on', but it does not with @continuum-boot.

I've also tryied playing without success wih @continuum-systemd-start-cmd, maybe you can give a me a hint on this.

@aleprovencio
Copy link

aleprovencio commented Aug 25, 2016

@bruno- ,
I could manage to make @continuum-boot to work, IF @continuum-restore is NOT on, so this is a matter of choosing either one of the options to have them working. When both are 'on', tmux service will not start (output below), but if @continuum-restore is 'off' I still have a chance to manually restore. I've seen issues alike on tmux-continuum like tmux-plugins/tmux-continuum#23 and tmux-plugins/tmux-continuum#1 , should I open a new one?

● tmux.service - tmux default session (detached)
   Loaded: loaded (/home/aleprovencio/.config/systemd/user/tmux.service; enabled; vendor preset: enabled)
   Active: failed (Result: exit-code) since qui 2016-08-25 11:41:22 BRT; 58s ago
     Docs: man:tmux(1)
  Process: 21681 ExecStop=/home/aleprovencio/.tmux/plugins/tmux-resurrect/scripts/save.sh (code=exited, status=1/FAILURE)
  Process: 20914 ExecStart=/usr/bin/tmux new-session -d (code=exited, status=0/SUCCESS)
 Main PID: 16194

ago 25 11:41:22 xps save.sh[21681]: no server running on /tmp/tmux-1000/default
ago 25 11:41:22 xps save.sh[21681]: no server running on /tmp/tmux-1000/default
ago 25 11:41:22 xps save.sh[21681]: no server running on /tmp/tmux-1000/default
ago 25 11:41:22 xps save.sh[21681]: no server running on /tmp/tmux-1000/default
ago 25 11:41:22 xps save.sh[21681]: no server running on /tmp/tmux-1000/default
ago 25 11:41:22 xps save.sh[21681]: no server running on /tmp/tmux-1000/default
ago 25 11:41:22 xps save.sh[21681]: no server running on /tmp/tmux-1000/default
ago 25 11:41:22 xps systemd[743]: tmux.service: Control process exited, code=exited status=1
ago 25 11:41:22 xps systemd[743]: tmux.service: Unit entered failed state.
ago 25 11:41:22 xps systemd[743]: tmux.service: Failed with result 'exit-code'.

@mdeguzis
Copy link
Contributor

I'm not sure if this i 100% related, but I had to put in a hack to fix my vim stuff. When Python runs, it seems the options shown via ps cause issues. Not sure if this a byproduct of how ps stores the command set? I noticed if I quote the set commands it work:

# Does not work, opens files with the options for set/cmd instead
$ vim --cmd set pythonthreehome=/apollo/env/envImprovement/python3.8 /home/deguzim/.tmux.conf 

"pythonthreehome=/apollo/env/envImprovement/python3.8"
"pythonthreehome=/apollo/env/envImprovement/python3.8" E212: Can't open file for writing
Press ENTER or type command to continue

# What it needs to be:
vim --cmd "set pythonthreehome=/apollo/env/envImprovement/python3.8" /home/deguzim/.tmux.conf 

Script

#!/bin/bash
# Description: Patches some output from `ps` that tmux resurrect
#              Uses to restore what you are doing

old_file=$(readlink -f ${HOME}/.tmux/resurrect/last)
new_file="/tmp/tmux-resurrect-ps-swap.txt"

while IFS= read -r line; do
        # Fix 1: Patch vim commands. The arguments to `--cmd` need to be quoted
        # in order for them to work right.
        if [[ "${line}" =~ "vim" ]]; then
                old_text=$(echo $line | awk -F'vim :' '{print $2}')
                new_text=$(echo "${old_text}" | awk '{print $1" "$2" \""$3" "$4"\" "$5}')
                line=$(echo "${line}" | sed "s|$old_text|$new_text|g")
        fi
        echo ${line}

done < "${old_file}" > "${new_file}"

# Replace file
mv "${new_file}" "${old_file}"

I use TPM to load tmux-resurrect, so I patch it after install with:

echo "$HOME/src/DeGuzim-Config/configuration/scripts/tmux-resurrect-ps.sh" >> ~/.tmux/plugins/tmux-resurrect/scripts/save.sh

It seems to say after " + I"

@mdeguzis
Copy link
Contributor

Anyway, shouldn't tmux-resurrect be capturing /proc/$pid/cmdline instead of ps output???

@mdeguzis
Copy link
Contributor

Going to use https://github.com/tmux-python/tmuxp/ for now, even though it lacks full command + args restore.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants