fanglingsu / vimb

Vimb - the vim like browser is a webkit based web browser that behaves like the vimperator plugin for the firefox and usage paradigms from the great editor vim. The goal of vimb is to build a completely keyboard-driven, efficient and pleasurable browsing-experience.
https://fanglingsu.github.io/vimb/
GNU General Public License v3.0
1.34k stars 100 forks source link

How to bind ;[a-z] to hint, yank to clipboard then actiave a shellscript? #657

Closed ghost closed 3 years ago

ghost commented 3 years ago

I have two scripts youtube-dl.sh, and mpv.sh. One will pipe clipboard into youtube-dl and the second one will pipe the clipboard into mpv.

How would I bind these two scripts to ;v , ;m (which activate hint mode and yank to clipboard then activate :shellcmd! youtube-dl.sh immediately after a hint is chose) and ;m (which do the same as above but instead activate mpv.sh script).

Normally I would use the method below

Use ;y first to hint and yank an URL to clipboard, then type this into inputbox : sh! mpv.sh, to actiave my script.

However this take extra step, I could have combine both and bind it to one command such ;v or ;m

I have tried to map :nn ;v ;y :sh! youtube-dl.sh<CR>. The hint does work however it doesn't seem to activate the shellcmd after hint is yanked to clipboard.

fanglingsu commented 3 years ago

@mrhieu059 You closed the question - did you find a solution? For a single script you could use the x-hint-command which is a command to be run after a hint ist fired that was started by ;x. So you could use :set x-hint-command=:sh! youtube-dl.sh <C-R>;<CR> - the <C-R>; pasted the yanked link target. And than start the hinting by ;x or via :nnoremap ;v ;x.

For two script you have to change the x-hint-command direct before triggering the ;x hints. :nnoremap ;v ::set x-hint-command=:sh! youtube-dl.sh <C-R>;<CR>;x (the :: before set disables recording of the set command in command history) :nnoremap ;m ::set x-hint-command=:sh! mpv.sh <C-R>;<CR>;x

That's not a direct solution but should work.