Option for escaping dropped paths for xonsh #3548
Replies: 2 comments
-
This also is true for NuShell: As a NuShell user i run into the problem that drag & drop of a file - for example from Finder - into Ghostty will result in something like This is not supported with NuShell and it would be very helpfull if such a drop action would result in I think this could be helpful in other cases too. For example when pasting into Helix I also get the same escapes. I imagine that one could define the default paste mode between "escaped" "double-quotes" "single-quotes" "raw"? Maybe it is also possible to have the mode change with different key modifiers, like "shift drop" means "quote escaped". |
Beta Was this translation helpful? Give feedback.
-
It's not the solution but just want to let you know. In xonsh with prompt-toolikit ( # ~/.xonshrc
from prompt_toolkit.keys import Keys
from prompt_toolkit.application import get_app
@events.on_ptk_create
def custom_keybindings(bindings, **kw):
@bindings.add("c-v") # Ctrl+V for pasting
def paste_preprocessed(event):
app = get_app()
clipboard = app.clipboard.get_data()
pasted_text = clipboard.text
# Convert to uppercase and paste.
processed_text = pasted_text.upper()
event.app.current_buffer.insert_text(processed_text) If you find this useful and create a solution feel free to create a xontrib using xontrib-template. |
Beta Was this translation helpful? Give feedback.
-
When dragging and dropping files into Ghostty, their paths are escaped by adding backslashes before separator characters. However, users of xonsh need a different escaping strategy since backslashes are not supported. I know of two different ways this is addressed in existing tools:
glennsmith@Glenns-MacBook-Pro ~ @ /Applications/Binary Ninja.app
Technically this forms an invalid command, but you can pretty easily muscle memory typing an open quote, dragging in the file, and typing the closing quote.glennsmith@Glenns-MacBook-Pro ~ @ '/Applications/Binary Ninja.app'
though actually iTerm's implementation only adds quotes if necessary, which makes it rather finicky when dropping files since you can never be sure if they will become a string or will just be pasted raw.So while there are tradeoffs to both solutions, it is practically necessary to implement at least one of them before ghostty is possible to use with xonsh.
Beta Was this translation helpful? Give feedback.
All reactions