tmux-resurrect
tmux-resurrect copied to clipboard
New windows are always created with the first window's path
Hi!
I started using your nice convenient plugin just today and already encountered an issue.
After I saved the session, stopped the server, started a new server and restored the saved sesion, every new window has a path that window 0
had when I was saving the session. I tried closing winow 0
before saving the session. The path from window 1
is used, which is not a surprise.
Changing current directory in that window after restoring a session doesn't affect anything. I tried restarting tmux server several times and starting the completely new session from scratch, but the issue remains.
I create new windows with a key binding, but entering [prefix]
:new-window
gives me the same result.
Hey, we've had this issue reported a couple times already. See for example #50. It turns out the issues so far were 1) zsh plugins 2) user shell (mis)configuration (eg .bashrc).
It might be something else this time so let's investigate. Can you please;
- link the content of
~/.tmux/resurrect/last
file - what does the command
tmux new-window -c '/tmp'
do? What is the directory of new window? - what does this command do
tmux new-window -c '/tmp' 'pwd; sleep 1000'
? It will open a new window with a path in it - what path is it?
We've had this issue reported a couple times already
Then why it is not in your FAQ yet? :)
zsh
I use bash.
tmux new-window -c '/tmp'
It opens a new window.
$ pwd
/tmp
tmux new-window -c '/tmp' 'pwd; sleep 1000'
/tmp
I tried moving .bashrc
and .bash_profile
so they are not loaded (I don't have .profile
), but the problem remains. Removing everything from tmux.conf
except the tpm part doesn't help too.
I also figured out that this happens only with particular session configuration. That session has windows, panes, different paths and vim
s running in some of them, also, the session has a name instead of a number, and all windows have their names too. The issue is not present in a simple session (three windows with different paths, everything else is default).
Good point about putting this to the FAQ, we'll have to do that. The command output looks good, no issues there.
I also figured out that this happens only with particular session configuration. That session has windows, panes, different paths and vims running in some of them, also, the session has a name instead of a number, and all windows have their names too. The issue is not present in a simple session (three windows with different paths, everything else is default).
None of this should be a problem really. Just to check, do directory names have spaces in them by any chance?
Wanna paste the content of ~/.tmux/plugins/last
in a gist so I can check how things are saved? If you are ok with pasting this content - what is the name of the problematic session?
Here are the session files, as simplified as possible. You replied faster than I prepared them. :)
tmux_resurrect_2windows_state1.txt: the problem is present.
tmux_resurrect_2windows_state0.txt: the problem is not present. This file is same as above, except the session 0
is selected. Switching to session 1
gives the same effect as using the first file.
tmux_resurrect_1window_state1.txt: the problem is present.
First I thought it's because my session has a custom name, but, as you can see, that's not a real reason.
Just to check, do directory names have spaces in them by any chance?
Nope.
I also figured out that this happens only with particular session configuration.
I was wrong. :)
What is the name of the problematic session?
The name was OP
.
I seem to have this issue too, when I restore the session some panes forget the start directory and change to /
, this also affects new panes and windows.
@bruno- those steps, like ~/.tmux/resurrect/last
should I do after a save or a restore?
I'm having this issue and I think its an interaction with my change to my tmux config that new panes in a session inherit the working directory of the pane they were opened from. The problem is tmux-resurrect uses the built in tmux option (maybe?) to open a new pane, thereby corrupting the working directory where it is trying to restore processes from as it goes.
This only seems to happen in certain sessions/panes, not all of them, but I also don't reboot very often.
State |Pane 1 | Pane 2 | Pane 3 | Pane 4 Before path | /home/myuser | /home | /projects | /home/myuser/projects Before proc | vim myfile | vim myuser/myfile | vim anotherfile | vim anotherfile After path | /home/myuser | /home/myuser | /home/myuser | /home/myuser After proc | vim myfile (works) | vim myuser/myfile (fails/empty) | vim anotherfile (fails/empty) | vim anotherfile (fails/empty)
I am encountering this problem with tmux 2.3, and to the best of my knowledge, I have not turned on the "inherit working directory" setting.
The issue started appearing when I actually gave my single session a name, instead of relying on the default number of 0.
Hi, thanks for this awesome plugin. @bruno- did this get fixed or are there any workarounds available?
@JakubPetriska Hi! I think this issue still persists. I tried all sorts of options and finally this works fine for me:
# Create a new window preserving the path of the current pane using the default keybind (prefix+c)
bind-key c run-shell 'MyCWD="#{pane_current_path}"; tmux new-window -c "$MyCWD"'