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 99 forks source link

How to yank the current page Title + URL into a buffer? #686

Closed philiprhoades closed 2 years ago

philiprhoades commented 2 years ago

People,

I have been using VimB for quite a while but only for quick jobs - I now want to replace some of my Chrome / Brave / FF use with it so I just cloned from scratch and spent a fair time installing -devel RPMs and symlinking dirs and .h files but finally got a Fedora 34 (Wayland instead of Xorg) binary working - thanks for a great app!

For a long time I have been using Chrome / Brave and FF extensions to grab the Title and URL of a page in a format like:

Title | URL

or

Title URL

into the system clipboard - is there some way I can do the same thing with VimB ?

Phil.

Sadoon-AlBader commented 2 years ago

This shouldn't be too difficult actually. The URI is already in an enviromen variable $VIMB_URI And the page title is displayed as the window title. I'll have a look at the code and see if I find an easy solution

philiprhoades commented 2 years ago

Wow! - that was a fast response!

That would be great if you could work that out somehow

Thanks!

Sadoon-AlBader commented 2 years ago

You are most welcome :)

So $VIMB_URI stores the current URI and $VIMB_TITLE stores the page title Now you can try to do this

echo $VIMB_TITLE "|" $VIMB_URI | xclip -i -selection clipboard

But this won't work because vimb doesn't seem to respect pipe characters.

I've found the only solution is to create a script (in ~/.local/bin perhaps) and call it from within vimb.

echo $VIMB_TITLE "|" $VIMB_URI | xsel -ib

Then you would call that script using

:shellcmd xselvimb (if you named it that)

And to assign it to key Y for example:

nmap Y :shellcmd xselvimb <CR>

I've used xsel because xclip seems to crash vimb altogether for some reason :P

philiprhoades commented 2 years ago

@Sadoon-AlBader ,

OK! - I will give that a shot now - I have now switched over to using vimb as the browser from NewsBoat - a text-based, vim-like channel concentrator for keeping up with my YT videos and it is working pretty well so far - although I have some hot-keys to learn and a little bit of setting up like for your script.

The other thing I should say is that some time ago, saving browser bookmarks in the browsers themselves was driving me insane because of the poor flexibilty - so I finally gave up, exported all my bookmarks to a text file and now manage that file with Vim and a Vim plugin, VOom - which is SO much nicer and more powerful.

So I am gradully moving to a situation where all my browsing will be done with Vim-like applications!

Thanks for the script! - I will report back with how it goes . .

Sadoon-AlBader commented 2 years ago

OK! - I will give that a shot now - I have now switched over to using vimb as the browser from NewsBoat - a text-based, vim-like channel concentrator for keeping up with my YT videos and it is working pretty well so far - although I have some hot-keys to learn and a little bit of setting up like for your script.

Somewhat off-topic I guess but you might want to check out one of the invidious instances, which provide you with a way to track your youtube subscriptions in a much easier fashion than an RSS feed, works very well with vimb, and requires no javascript or a google account whatsoever.

philiprhoades commented 2 years ago

I made some progress - because I am using Wayland now instead of Xorg, I had to use this in the script:

' echo $VIMB_TITLE "|" $VIMB_URI | wl-copy`

I will have a look at the invidious stuff - thanks!

philiprhoades commented 2 years ago

which actually works and I can then paste from the system buffer alright but the action causes the vimb window to become unresponsive . .

Any idea why this might happening? Any idea about how to debug it?

Update #1:

In Wayland the way to quit the current window is to use: Win-Shift-Q but I thought this wasn't working because nothing happened immediately - but as I kept doing other things - that window eventually disappeared ! - which is even weirder I think . .

Update #2:

Ah - I went to kill one of the blocked vimbs and saw this:

phr 1062320 0.0 0.0 0 0 pts/18 Z+ 23:09 0:00 [wlcp_vimb.sh] <defunct>

a little while after I killed the blocked vimb, this defunct process disappeared too . .

fanglingsu commented 2 years ago

@philiprhoades I'm not sure how you call it, but I think you should use :sh! .... The ! causes vimb to run the call in background, so the UI does not need to wait for shell return. I assume the the wl-copy is not terminated so that vimb waits for the return of it.

Not sure what you make with the Title and URI in a single string, but the pipe char is not good separator, because it might appear in the title, so you do not know where the URI starts. I think you should use either an other separator or put the URI first, where pipes are really rare.

philiprhoades commented 2 years ago

@fanglingsu ,

I think you should use :sh! ....

Ah yes - great - thanks . . I will try that . .

the pipe char is not good separator

Yes, if that is a problem, I could use something else and replace it after pasting into the Bookmarks.txt file - but "|" is nicer for things in columns . .

I will let you know how it goes . . making progress!

Update:

Yes, the addition of the bang to the shellcmd fixed the problem! - thanks! Also, the pipe is quoted and works fine so that saves me a few key strokes!

fanglingsu commented 2 years ago

@philiprhoades If it works for you now, I'll close this.

philiprhoades commented 2 years ago

Yes, no worries - been using it for a while now! - and I am gradually replacing some of the Chrome / FF / Brave stuff I do with vimb!