You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It would be awesome to support the drag&drop of files/folders as is it aleady
supported for path paste.
The idea is to send a command to the terminal in the case of a Drag&Drop event
. It would be nice to detect which program is currently running on the terminal
and send the appropriate command that can be registred in .minttyrc
For instance we could have this configuration
# <program>,<file/folder>,<wildcard>,<command>
DropAction=vim,file,*,'<esc>:e $0<cr>'
DropAction=bash,file,'*.m,octave -i --persist $0<cr>'
DropAction=bash,folder,,'cd $0<cr>'
Original issue reported on code.google.com by [email protected] on 30 Jan 2015 at 8:42
The current feature just drops any dragged text into mintty as input, to whatever application is running.
It is not possible in a reliable way to direct that input to a specific application (in which case application-specific additions could be inserted).
The reason is that there is no way to determine which application is currently handling terminal input. From a process point of view, there is a tree of processes (often beginning with a shell) running inside the terminal. It can have multiple leaves and it is not even sure whether it's one of the leaves accepting input (imagine an editor having started some filter processes). It is even possible that multiple processes are trying to capture input from the terminal.
How about generalizing the 'program-name' part, and call it 'scheme-name'? Some control sequences can then be added to tell mintty which drag&drop-encoding scheme to use (much like the \e]0 thing), or potentially just to pass a line of 'anonymous' scheme. Users will then be able to use shell functionalities like PROMPT_COMMAND and trap foo_func DEBUG to manipulate it.
Naturally after saything this people will think about applying appropriate escapes automatically by mintty, and I guess people will be asking for sed-like replacing functionalities soon (just kidding)
Hmm, nice idea at first glance.
I do see some security issues here, however: an escape sequence could simply switch mintty into a mode that issues actions (like commands) in a situation it shouldn't. How could that be dealt with?
In general, any such sequences that trigger action from the terminal are considered security-relevant, that's why most other terminals (see xterm) meanwhile disable them by default.
There are more issues: how to configure it? And where's the convincing use case that would justify the implementation effort...?
I could imagine a variant of "bracketed paste mode":
If "bracketed drop mode" is activated, the dropped text would be embedded in escape sequences.
This would enable a cooperating program to detect the leading escape sequence and handle the drop text accordingly.
It would still not facilitate the injection of arbitrary commands, and that's on purpose.
Comments welcome.
For the records, I have to revise the previous statement about identifying the terminal handling process; it is apparently possible to determine the terminal foreground process, so an application-specific mapping would in theory be possible.
This does not mean I consider it useful now; security concerns still apply. I'll probably implement a bracketed drop mode. Not sure yet, whether it should automatically be enabled with bracketed paste mode or be an explicit mode, and whether the sequence sent should be the same as for bracketed paste or it's useful to distinguish the two. Comments welcome.
In bracketed paste mode, drag-and-drop now embeds the file/folder like other pasted contents.
Should anyone think it's useful to distinguish drag-and-drop from other pasting, or to distinguishing drag-and-drop file/folder from other text (e.g. URL), specific modes can be provided for that, likely using the same escape sequence with an additional parameter.
Do you want to distinguish different kinds of contents or just drag-and-drop from other pasting? Any need to distinguish mouse pasting from keyboard shortcut pasting (hopefully not)?
The current paste embedding sequence is ESC[200~. A drag-and-drop embedding sequence could be like ESC[200;2~.
The sequence to set/reset bracketed paste mode is ESC[?2004h/l.
A sequence to enable drag-and-drop specific bracketed paste mode could be ESC[?2004;2h.
Sorry, it is hard for me to understand these commands. I get it sends ESC but the rest of the command I don't understand. If you can direct me to some link where they are explained it would be great
Do you want to distinguish different kinds of contents or just drag-and-drop from other pasting?
just drag-and-drop from other pasting
Here is what I am looking for:
I use vim within mintty terminal. I would like to be able to drag and drop a file into vim (within mintty) and that the file opens in a new tab or just opens. At the moment, if I want to drag&drop a file into vim, I need to write ':e' or ':tabe' in vim and then drag and drop the file. It would be great that when I drag and drop a file in mintty/vim it adds ':e' or ':tabe' before the file path and 'CR' at the end so the file just opens pretty much like with any other text editor. other paste commands from mouse or keyboard should work as usual.
For the current solution (that could be extended to distinguish drag-and-drop), the application would need to cooperate and detect the escape sequences.
The idea of issuing application-specific commands, on the other hand, was discussed before and not pursued for security concerns, sorry.
Activity
mintty commentedon Sep 4, 2015
The current feature just drops any dragged text into mintty as input, to whatever application is running.
It is not possible in a reliable way to direct that input to a specific application (in which case application-specific additions could be inserted).
The reason is that there is no way to determine which application is currently handling terminal input. From a process point of view, there is a tree of processes (often beginning with a shell) running inside the terminal. It can have multiple leaves and it is not even sure whether it's one of the leaves accepting input (imagine an editor having started some filter processes). It is even possible that multiple processes are trying to capture input from the terminal.
Intending to close the issue.
Artoria2e5 commentedon Mar 1, 2016
How about generalizing the 'program-name' part, and call it 'scheme-name'? Some control sequences can then be added to tell mintty which drag&drop-encoding scheme to use (much like the
\e]0thing), or potentially just to pass a line of 'anonymous' scheme. Users will then be able to use shell functionalities likePROMPT_COMMANDandtrap foo_func DEBUGto manipulate it.Naturally after saything this people will think about applying appropriate escapes automatically by mintty, and I guess people will be asking for
sed-like replacing functionalities soon (just kidding)mintty commentedon Mar 1, 2016
Hmm, nice idea at first glance.
I do see some security issues here, however: an escape sequence could simply switch mintty into a mode that issues actions (like commands) in a situation it shouldn't. How could that be dealt with?
In general, any such sequences that trigger action from the terminal are considered security-relevant, that's why most other terminals (see xterm) meanwhile disable them by default.
There are more issues: how to configure it? And where's the convincing use case that would justify the implementation effort...?
mintty commentedon Mar 24, 2016
I could imagine a variant of "bracketed paste mode":
If "bracketed drop mode" is activated, the dropped text would be embedded in escape sequences.
This would enable a cooperating program to detect the leading escape sequence and handle the drop text accordingly.
It would still not facilitate the injection of arbitrary commands, and that's on purpose.
Comments welcome.
mintty commentedon May 4, 2016
For the records, I have to revise the previous statement about identifying the terminal handling process; it is apparently possible to determine the terminal foreground process, so an application-specific mapping would in theory be possible.
This does not mean I consider it useful now; security concerns still apply. I'll probably implement a bracketed drop mode. Not sure yet, whether it should automatically be enabled with bracketed paste mode or be an explicit mode, and whether the sequence sent should be the same as for bracketed paste or it's useful to distinguish the two. Comments welcome.
[-]Drag on Drop files or folders[/-][+]Drag and Drop files or folders[/+]fix drag-and-drop file/folder to also honour bracketed paste mode (#440)
mintty commentedon May 6, 2016
In bracketed paste mode, drag-and-drop now embeds the file/folder like other pasted contents.
Should anyone think it's useful to distinguish drag-and-drop from other pasting, or to distinguishing drag-and-drop file/folder from other text (e.g. URL), specific modes can be provided for that, likely using the same escape sequence with an additional parameter.
mintty commentedon May 22, 2016
Released bracketed-paste-mode embedding of drag-and-drop contents in 2.3.7.
jordiFrei commentedon Jun 7, 2016
I would really love the proposed feature.How does it work, how can we specify the specific brackets
Thanks for your efforts
mintty commentedon Jun 7, 2016
Do you want to distinguish different kinds of contents or just drag-and-drop from other pasting? Any need to distinguish mouse pasting from keyboard shortcut pasting (hopefully not)?
The current paste embedding sequence is
ESC[200~. A drag-and-drop embedding sequence could be likeESC[200;2~.The sequence to set/reset bracketed paste mode is
ESC[?2004h/l.A sequence to enable drag-and-drop specific bracketed paste mode could be
ESC[?2004;2h.jordiFrei commentedon Jun 7, 2016
Sorry, it is hard for me to understand these commands. I get it sends ESC but the rest of the command I don't understand. If you can direct me to some link where they are explained it would be great
just drag-and-drop from other pasting
Here is what I am looking for:
I use vim within mintty terminal. I would like to be able to drag and drop a file into vim (within mintty) and that the file opens in a new tab or just opens. At the moment, if I want to drag&drop a file into vim, I need to write ':e' or ':tabe' in vim and then drag and drop the file. It would be great that when I drag and drop a file in mintty/vim it adds ':e' or ':tabe' before the file path and 'CR' at the end so the file just opens pretty much like with any other text editor. other paste commands from mouse or keyboard should work as usual.
Thank you very much
mintty commentedon Jun 9, 2016
For the current solution (that could be extended to distinguish drag-and-drop), the application would need to cooperate and detect the escape sequences.
The idea of issuing application-specific commands, on the other hand, was discussed before and not pursued for security concerns, sorry.
new drag-and-drop paste configuration DropCommands (#440)
mintty commentedon Mar 11, 2017
Foreground-application-specific drop patterns release with 2.7.5.
new drag-and-drop paste configuration DropCommands (mintty#440)