laktak / extrakto

extrakto for tmux - quickly select, copy/insert/complete text without a mouse
MIT License
878 stars 45 forks source link

Feature request: open #15

Closed oblitum closed 6 years ago

oblitum commented 7 years ago

Loving this plugin. I wish, besides providing insertion and copy, that it provided open. It would work for files, URLs etc. There could be a simple configuration for the opening command, for example, for me, simply setting up gioopen <text selection> as the command would work for most files and URLs.

laktak commented 7 years ago

Sounds like a good idea. I'll look into it ... unless you'd like to do a PR?

maximbaz commented 7 years ago

Nice idea, my only request: please don't hardcode the use of gio, use the standard wrapper xdg-open that is available everywhere - it will use gio itself if it is appropriate.

This is an inspiring comment: https://github.com/github/hub/issues/1473#issuecomment-303656214

oblitum commented 7 years ago

@maximbaz ah ok right, thanks for that comment link. I thought xdg-open had been deprecated indeed due to that message. I'm on ArchLinux and I think that message was shown just temporarily, it has been some time I didn't see it anymore, so they should have been fixed it already and it was just left in my memory, wrongly.

laktak commented 7 years ago

I've added an extrakto_custom_tool option that you can set to the tool of your choice:

set -g @extrakto_custom_tool "xdg-open"

If this works OK we can add this and open (mac) as defaults.

oblitum commented 7 years ago

ah... I was about to offer a pull request. If there's anything to use there yet, feel free to pick https://github.com/oblitum/extrakto/tree/open-functionality.

maximbaz commented 7 years ago

Awesome stuff guys!

Plain xdg-open is almost perfect, but it produces some unnecessary output in STDOUT that I don't need to see. I suggest this as a default for Linux:

set -g @extrakto_custom_tool "xdg-open >/dev/null"

UPDATE: I see @oblitum decided to do the same in his fork 😉

laktak commented 7 years ago

@oblitum sorry - so why didn't you say that you'd do a PR? I'd definitely add your defaults!

+if [ -z "$open_tool" ]; then
+  case "`uname`" in
+    'Linux') open_tool='xdg-open >/dev/null' ;;
+    'Darwin') open_tool='open' ;;
+    *) ;;
+  esac
+fi
oblitum commented 7 years ago

@laktak ¯\_(ツ)_/¯

maximbaz commented 6 years ago

@laktak why require configuration in the first place, why not just have the defaults always enabled? What @oblitum originally had with if [ -z "$open_tool" ]; made sense for me.

laktak commented 6 years ago

@maximbaz I think this could use some more testing before enabling it by default. It now appears to work with relative paths. Can you guys test on your systems?

oblitum commented 6 years ago

@laktak yes, it wasn't working when current working directory wasn't ~, it's working now (also for ../foo.txt, etc).

maximbaz commented 6 years ago

It happens that I don't have a GUI file manager installed, and thus I have no association with file paths at all on my system... so I all can say is that opening URLs works really well 😄

laktak commented 6 years ago

In that case @oblitum what are you using? I also have no gui apps besides firefox (but xdg-open opens json files there ;)

oblitum commented 6 years ago

I'm just testing with .txt files, I have GVim associated by default to open such files in the MIME database.

maximbaz commented 6 years ago

I would say that it seems to work good right now, and enabling this functionality by default will make more people using and testing this, and if something is not working correctly I'm sure we will hear about this soon :)

laktak commented 6 years ago

OK, you are probably right ;) It's now set as default.

oblitum commented 6 years ago

@laktak nice. IMO it looks a bit inconsistent to have both "" (for clip_tool) and "auto" (open_tool) to mean the same: to use internal defaults.

laktak commented 6 years ago

@oblitum fixed