Bug 339155

Summary: Drag and dropping of files doesn't take into account directory location when using tmux
Product: [Applications] konsole Reporter: Adam Hunt <voxadam>
Component: generalAssignee: Konsole Developer <konsole-devel>
Status: CONFIRMED ---    
Severity: normal CC: cpigat242, kde, peter
Priority: NOR    
Version: 2.14   
Target Milestone: ---   
Platform: Debian unstable   
OS: All   
Latest Commit: Version Fixed In:
Sentry Crash Report:

Description Adam Hunt 2014-09-17 20:56:43 UTC
I love that it's possible to drag and drop files into a Konsole window and have them copied, moved, or linked to at the location that I at in my directory structure, This can be an oddly useful feature.

Unfortunately, when using tmux, which is always these days as my rc scripts load it by default, DnD doesn't take into account tmux. This means that files end up in the location where Konsole was when tmux was launched (for me this is always ~).

Reproducible: Always

Steps to Reproduce:
1. Launch Konsole
2. Note the current directory
3. Start a tmux session
4. Change to any other directory (e.g.
5. Drag a file onto Konsole
6. Select "Copy Here" (Move Here and Link Here produce similar results)
7. Check the current directory for the file
8. Check the directory where tmux was started for the file

Actual Results:  
The file is copied, moved to, or linked to in the directory where tmux was started.

Expected Results:  
The file should be copied, moved to, or linked to the directory where the user is in their tmux session.

I assume that this occurs in GNU Screen as well but I have not tested it.

I imagine resolving this issue would be substantially more complex if one were to take into account a tmux session with split panes all in different portions of the file system. I would recommend that if it is not reasonable to determine which pane a file is dropped onto to assume the tmux pane which is currently active/focused to be the intended location.
Comment 1 Kurt Hindenburg 2014-09-27 02:46:28 UTC
Yes,  Konsole is using the shell path - not tmux
Comment 2 Vadim A. Misbakh-Soloviov (mva) 2014-11-04 17:21:52 UTC
Moreover, tmux stays it's cwd in same directory it was opened. So, I guess, it is pretty impossible to manage that without a hard and dirty hacking
Comment 3 Vadim A. Misbakh-Soloviov (mva) 2017-03-11 13:51:09 UTC
Btw, I talked with tmux developers and they tell me to ask you (konsole developers) if there is some escape sequence (that console would understand) to set the current working directory?

If there is an escape sequence, tmux could use it, so then Konsole would know the current cwd, so files would be saved in right place.

// tmux dev said it is somethin similar already implemented for iTerm2...
Comment 4 Vadim A. Misbakh-Soloviov (mva) 2017-03-11 13:57:31 UTC
And also, it seems, this issue appears not only with tmux, but with any "cascaded" applications. If you run you shell, then cd into some directory, then run another copy of the shell (or another shell) and then cd to another place, file will be copied to the place where you was in first level shell.

I'd think that it looks like KonsolePart just gets cwd by looking on /proc/PID/cwd of the process that run in the tab, but how it gets the pid of child process then?


Anyway, as tmux developers said, it can be made with escape sequence
Comment 5 sevens 2023-01-08 10:19:49 UTC
Same issue happens with other actions, e.g. "Open File Manager", "Open Folder With" when using right-mouse on a Konsole window running tmux.

Would love to be able to fix this as well (e.g. with escape sequence as suggested before).