iTerm2 has great build in support for it. You just cmd-click and hold a file and it's as if it was sourced from any other ui app. You can even get it to work with remote files both ways, including dropping a file on an iTerm2 window during an ssh session and it can scp it over for you. (yes needs some shell collaboration, but it's trivial to setup)
Definitely have an in depth read of iTerm2's documentation (<https://iterm2.com/documentation.html>), at the very least one of the feature page (<https://iterm2.com/features.html>) - I know it sounds weird, but it's so far ahead of other terminals that it's hard to imagine, and expectations are blown. The trigger feature for example is fantastic too.
ls --hyperlink is completely broken for me, because it’s producing links of the form file://hostname/path rather than file:///path, and xdg-open says “xdg-open: file 'file://hostname/path' does not exist”.
I also get file://hostname/path urls, but opening them works fine. xdg-open 1.1.3
Ctrl-clicking opens the link, but is anything supposed to happen when I click on the link (in Gnome Terminal). I thought it might copy the link, but nope.
Perhaps Gnome Terminal is using gio open instead of xdg-open. Running `gio open file://something-else/home` opens /home, apparently just completely ignoring the authority part. Theoretically including the host name is good because you can handle remote machines, but in practice I’m not sold on it because here we have one major tool ignoring it (actively bad!) and another major tool not supporting it (less bad, but less convenient), and there’s no standard accepted way of interpreting/opening a file: URL with an authority anyway. (Windows treats it as SMB and can do something provided it actually is that, but it won’t be, so it can’t. I don’t know of any other OS having any convention at all. Just tried it in a couple of browsers under Linux, Firefox actively discards the authority part, Chromium keeps it and works if it’s localhost or 127.0.0.1 or such, but says ERR_INVALID_URL if it’s something else.)
On further investigation, I have found one authority that works in xdg-open: localhost. Not the host name, not 127.0.0.1, not ::1 or [::1], not anything else present in /etc/hosts, just localhost. I’m baffled, but not quite invested enough to delve into the source to figure out what could be going on.
Glad to see I'm not the only one that wanted this workflow!
I added this the first cut of this feature to iTerm2 about a decade ago because I often work in the terminal, but sometimes need to reference files elsewhere in my workflow. The feature was named "Semantic History" although in hindsight, it's not a very good name.
To use, hold Cmd and click+drag the path to where you want to drop it. Behind the scenes, the current working directory is stored with the position of the buffer, so it works on relative paths even when you change your working directory. On Cmd+Drag, it searches the buffer around the cursor until it finds a valid path to work with.
TIL that current working directory is stored with buffer lines. Cool idea.
I've quickly tried to drag and drop file from another directory earlier from the history to the terminal itself, but it was converted to "cd directory" command somehow.
On iPad "secure shellfish" can do this over an ssh connection. You can grab a file out of an "ls" listing and drag it to another app. (You do have to highlight the name first, so not quite as ergonomic as iTerm.)
Don’t think I’ve come a binary named open on a Linux machine. (And under Arch Linux, `pacman -F /usr/bin/open` produces nothing, so no package in the standard repositories contains it.) I’m guessing you’re thinking of `xdg-open .`.
On macos you have the 'open <path>' command, which is equivalent to double clicking that <path> object, whether it be a folder, file or application; you can also drag a folder/file to the terminal to paste it's path. No context menu <open terminal here> by default, but I think there are add one which do that.
Just yesterday i accidentally type `open .` in my Ubuntu/KDE/fish shell to open the current directory in the GUI.
I quickly thought “wait, remember that only works on macOS” and the was shocked to see KDE’s Dolphin open the directory. I dig into it and found there was an alias for ‘open’ to ‘xdg-open’
On Linux, `open` was already taken - by a command to run a program on a virtual console (aka virtual terminal; also VC or VT for short). Probably doesn't see much use anymore. I remember in the 1990s, running Slackware, I used virtual consoles all the time. Nowadays, I have an Ubuntu box sitting on my desk, and I use it a lot, but always over SSH or HTTPS from my Mac. It doesn't even have a monitor attached to it any more; back when it did, the monitor would spend months at a time turned off, and on the rare occasions I did use it, I don't remember ever leaving X11 (or maybe it was Wayland, I can't remember). PTYs still get used all the time, but virtual consoles/terminals not that much.
Hence the command had to be named `xdg-open`. Until, more recently, someone decided it was a stupid situation, so `open` was renamed `openvt`, and `open` is now an alias for `xdg-open`.
Wow, this looks awesome! I love CLI / GUI integration tools.
In case you're interested, I wrote some examples on how the system clipboard is also a great integrator for migrating data to and from the CLI: https://github.com/niedzielski/cb#examples
Is it just me, or has copy/paste from terminal to terminal, webbrowser to terminal, anything to terminal gone awry? I seem to recall being able to just copy/paste from dang near anything to my terminal in Linux. Now, it surely seems like its heads or tails, hit or miss, "works 50% of the time, all of the time" kind of deal.
Is it just me? I swear I see this on three different distros. Highlight in terminal/program X, paste to <pick any terminal>, and half the time it just does not work/gibberish/crash and burn.
I wonder if it's something about you running on Wayland, and some terminals or programs are running under XWayland? Not sure if the two actually share the primary selection clipboard or whatever properly.
I'm still under Xorg (running GNOME) for now, I'll move to Wayland when the benefits outweigh the costs, which I don't think is the case for me yet.
I do not run wayland on my distros. I am on Gentoo, Debian and Slack. AFAIK, none of them now use wayland (my Gentoo install is xorg and icewm, for example).
It's the browsers using a different clipboard and being weird. There are some clipboard daemons you can use to unify everything and get nice menus from, but otherwise you have to find out when to middle click, when to shift-insert and when to (puke) ctrl-v.
Reading this is a little wild, because I have been experiencing this for a while, but until this comment I thought I mussed have pressed the wrong keyboard buttons.
I wrote something similar for fun for macOS a while back[1], though it doesn’t have the niceness of double-clicking the filename. (And of course now I’ve noticed more things to fix or change.)
Another related tip for Mac: if you are using Yoink — and you totally should be — you can add files to to it from shell with `open -a Yoink filename`. I have a shell function called `yo` for it.
Haven’t seen a terminal that lets you drag the links but that sounds like a logical feature.
https://purpleidea.com/blog/2018/06/29/hyperlinks-in-gnome-t...
Here is a quick comparison if anyone needs: https://github.com/asdf8dfafjk/Terminal-Features/blob/main/F...
Wish some terminals would allow more "actions" on hyperlinks, maybe using right click, and even drag-drop
Ctrl-clicking opens the link, but is anything supposed to happen when I click on the link (in Gnome Terminal). I thought it might copy the link, but nope.
On further investigation, I have found one authority that works in xdg-open: localhost. Not the host name, not 127.0.0.1, not ::1 or [::1], not anything else present in /etc/hosts, just localhost. I’m baffled, but not quite invested enough to delve into the source to figure out what could be going on.
I added this the first cut of this feature to iTerm2 about a decade ago because I often work in the terminal, but sometimes need to reference files elsewhere in my workflow. The feature was named "Semantic History" although in hindsight, it's not a very good name.
To use, hold Cmd and click+drag the path to where you want to drop it. Behind the scenes, the current working directory is stored with the position of the buffer, so it works on relative paths even when you change your working directory. On Cmd+Drag, it searches the buffer around the cursor until it finds a valid path to work with.
I've quickly tried to drag and drop file from another directory earlier from the history to the terminal itself, but it was converted to "cd directory" command somehow.
https://manpages.ubuntu.com/manpages/xenial/man1/run-mailcap...
dragon is great. goes very nicely with emacs/dired!
On macos you have the 'open <path>' command, which is equivalent to double clicking that <path> object, whether it be a folder, file or application; you can also drag a folder/file to the terminal to paste it's path. No context menu <open terminal here> by default, but I think there are add one which do that.
https://linux.die.net/man/1/xdg-open
I quickly thought “wait, remember that only works on macOS” and the was shocked to see KDE’s Dolphin open the directory. I dig into it and found there was an alias for ‘open’ to ‘xdg-open’
Nice
Hence the command had to be named `xdg-open`. Until, more recently, someone decided it was a stupid situation, so `open` was renamed `openvt`, and `open` is now an alias for `xdg-open`.
In case you're interested, I wrote some examples on how the system clipboard is also a great integrator for migrating data to and from the CLI: https://github.com/niedzielski/cb#examples
It is an OK workflow IMO. I'm not sure if I can directly drag and drop from the terminal list somehow. Or better yet, a full keyboard workflow.
0: https://github.com/jarun/nnn/
1: https://github.com/jarun/nnn/tree/master/plugins
Is it just me? I swear I see this on three different distros. Highlight in terminal/program X, paste to <pick any terminal>, and half the time it just does not work/gibberish/crash and burn.
I'm still under Xorg (running GNOME) for now, I'll move to Wayland when the benefits outweigh the costs, which I don't think is the case for me yet.
[1] https://github.com/Wevah/dragterm
[1] https://eternalstorms.at/yoink/mac/tips/