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

$HOME link and broken promt on restore #254

Open
joerhau opened this Issue May 28, 2018 · 1 comment

Comments

Projects
None yet
2 participants
@joerhau

joerhau commented May 28, 2018

Hey,

First of all thank you very much. This is a very nice plugin!

Still I had a small issue, as I got an uncommon setup for my homefolder. It is a link to an NFS area, which is mounted elsewhere on the system ($HOME -> /nfs/mountpoint). In that case tmux records the target of the link as the #{pane_current_path}. This in result breaks the promt on restore (they will show the link target as the folder location).

I already tricked around this as follows:

------------------------------- scripts/save.sh -------------------------------
@@ -288,6 +288,14 @@ save_all() {
 	else
 		rm "$resurrect_file_path"
 	fi
+
+    #replace homefolder link target with $HOME
+    if [ -z "$HOME" ]; then
+        HOME=$(getent passwd $(whoami) | rev | cut -d ':' -f 2 | rev)
+    fi
+    HOMETARGET=$(readlink $HOME)
+    sed -i "s#$HOMETARGET#$HOME#g" $last_resurrect_file
+
 	if capture_pane_contents_option_on; then

But I'm sure there is a more clean and clever way to get this fixed.

Thanks again,
Joerg

@oyvindstegard

This comment has been minimized.

oyvindstegard commented Nov 10, 2018

I had this exact same issue when working in projects hosted on a file system outside of my $HOME-folder, but which I had symlinked from my home folder to get a more pleasant CWD path in shells.

Interestingly, I could not get the desired restore behaviour by modifying the resurrect state file, I still got shells with CWD in the physical dir of the external file system (Windows drvfs on WSL) after restore.

My take was to install a post-restore-all hook which basically did:

for pane in $(tmux list-panes -a|cut -d: -f1,2)
do
    tmux send-keys -t "$pane" 'cd "$(pwd|sed -e "s:^$EXTPATH/projects:$HOME/projects:")"' "C-j" "C-l"
done

where $EXTPATH is the physical mount point path of the other file system (with a .. too long path) and $HOME/projects is a symlink to $EXPATH/projects. This obviously doesn't work if restoring anything but shell prompts in the tmux panes (I have no advanced needs there, and little experience with fancy tmux-resurrect options).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment