7 ms·
Drag and Drop from Terminal
- douglee650 4y agoOn Mac, I think you can `open .` and it will open a finder window in the pwd
- sime2009 4y ago`open .` will work on most Linux systems too.
- chrismorgan 4y agoDon’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 .`.
- Symbiote 4y agoThere's also "see ."
- chrismorgan 4y agoNever heard of it, nor can I find any references to it, or Arch Linux packages containing it.
- Symbiote 4y agoSee this. I suspect it's installed by default on Ubuntu. https://manpages.ubuntu.com/manpages/xenial/man1/run-mailcap.1.html https://manpages.ubuntu.com/manpages/xenial/man1/run-mailcap...
- zxcvgm 4y agoI usually use “start .” on Windows to achieve the same.
- CGamesPlay 4y agoYou can also `open -R $filename` and it will open the directory in finder with the relevant file selected.
- _chendo_ 4y agoGlad 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.
- dunham 4y agoOn 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.)
- codesnik 4y agoTIL 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.
- niedzielski 4y agoWow, 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 https://github.com/niedzielski/cb#examples
- xk3 4y agowoah~! this is really simple but also a game changer. I like the way you think
- kretaceous 4y agoI use nnn[0] and it has a simple plugin[1] based on dragon. I can press `;d` and the dragon window pops up. 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/ https://github.com/jarun/nnn/ 1: https://github.com/jarun/nnn/tree/master/plugins https://github.com/jarun/nnn/tree/master/plugins
- Wevah 4y agoI 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.) [1] https://github.com/Wevah/dragterm https://github.com/Wevah/dragterm
- jurip 4y agoAnother 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.
- ubercow13 4y agoI use Yoink [1] on macos for a similar purpose to 'dragon' mentioned in the post. [1] https://eternalstorms.at/yoink/mac/tips/ https://eternalstorms.at/yoink/mac/tips/
- angry_octet 4y agoNice. Linux has been missing out on this. 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.
- dixie_land 4y agoFWIW xdg-open works similar to open https://linux.die.net/man/1/xdg-open https://linux.die.net/man/1/xdg-open
- leejoramo 4y agoJust 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’ Nice
- skissane 4y agoOn 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`.
- synthc 4y agoLinux has xdg-open to open files from the terminal
- hprotagonist 4y agohttps://news.ycombinator.com/item?id=33137057 https://news.ycombinator.com/item?id=33137057 dragon is great. goes very nicely with emacs/dired!
- deleted 4y ago[deleted]
- aendruk 4y agoSee also: ls --hyperlink With a compatible terminal you can then just click on results. Another nicety is making your shell prompt a link to the working directory. Haven’t seen a terminal that lets you drag the links but that sounds like a logical feature.
- puppybang 4y agoSadly not all terminals have a great support for ls --hyperlink. Here is a quick comparison if anyone needs: https://github.com/asdf8dfafjk/Terminal-Features/blob/main/Features.md 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
- sime2009 4y agoWhat other actions do you have in mind? "copy path" and "open in default app" are the most obvious ones.
- ddlsmurf 4y agoiTerm2 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)
- codesnik 4y agoWow, thank you. I didn't know about dragging, I always resorted to "open -R" to drag a file to anything GUI.
- ddlsmurf 4y agoDefinitely have an in depth read of iTerm2's documentation (<https://iterm2.com/documentation.html https://iterm2.com/documentation.html>), at the very least one of the feature page (<https://iterm2.com/features.html 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.
- flobosg 4y agoCool idea. I get some Plan 9/plumbing vibes from this.
- readingnews 4y agoIs 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.
- doubleunplussed 4y agoI 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.
- readingnews 4y agoI 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).
- glandium 4y agoDebian has been defaulting to wayland for a while, with e.g. Firefox still using X11 via xwayland.
- chrismorgan 4y agoClipboard integration works smoothly in XWayland.
- t-3 4y agoIt'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.