Comments (10)
Sure. To accomplish that, I would combine your approach and mine.
Something like
#!/bin/bash
LC_COLLATE=C
if url=$(xsel -co > /tmp/sel && grep --only-matching --perl-regexp "http(s?):\/\/[^ \"\(\)\<\>\]]*" "/tmp/sel")
then
xdg-open $url
else
files=(/tmp/clipmenu/*)
for (( i=${#files[@]}-1; i>=0; i-- )); do
file=${files[$i]}
if url=$(grep --only-matching --perl-regexp "http(s?):\/\/[^ \"\(\)\<\>\]]*" "$file")
then
xdg-open $url
break
fi
done
fi
I have not tested this, you might have to make some adjustments.
from clipmenu.
Can you show me clipmenu-url
? I didn't find it in your dotfiles.
Your solution doesn't make much sense. It doesn't sound like you want a function, it sounds like you want a oneshot mode.
from clipmenu.
https://github.com/kaihendry/clipmenu/blob/url-shortcut/clipmenu-url
Yes, oneshot "request the clipboard manager to take over the ownership of the clipboard" as put on http://askubuntu.com/a/61328/676
from clipmenu.
Sounds reasonable enough.
from clipmenu.
@kaihendry do I understand correctly that you are trying to launch your browser from the selected text? You're trying to take a very roundabout approach to this. The better way is to use a more direct approach with xsel
.
xsel -co | xargs -r xdg-open
This prints the currently selected text to stdout, which we pipe to xargs
so that xdg-open
can receive it as an argument.
Replace your clipmenu-url with this single line of code :)
from clipmenu.
This is a very good suggestion, thank you! The only drawback is that I may want to use the script on the last URL after making another non-URL selection, if that makes sense?
from clipmenu.
Weird, xsel -co
doesn't output anything for me on Arch.
from clipmenu.
For the past week or so, clipmenud has not worked for me, and actively prevents me from copying anything. I've been meaning to make an issue but haven't found the time to dig into what caused this. Does xsel -co
work for you if clipmenud is not running?
from clipmenu.
xsel -co
is not working at all.
Reverted to using xclip
again with
if url=$(xclip -o | grep --only-matching --perl-regexp "http(s?):\/\/[^ \"\(\)\<\>\]]*")
from clipmenu.
Easy enough now that we have locking support, see db05c51 :-)
from clipmenu.
Related Issues (20)
- Status always showing 'enabled' HOT 2
- Pasting large images HOT 8
- Add option to disable copy on select HOT 2
- Unable to copy images to clipboard with Spectacle HOT 4
- Support customizing launcher args HOT 1
- No longer working on select (rofi) HOT 7
- Clean shutdown HOT 3
- Use clipnotify loop mode HOT 1
- Add image support HOT 3
- Option to not store passwords HOT 2
- Put new strings in clipboard from clipmenu HOT 2
- Save Image to a File - no menu entry nor toolbar button HOT 1
- keepassxc vs. clipmenu HOT 6
- Cannot get `$CM_IGNORE_WINDOW` to work HOT 1
- Add man pages HOT 1
- Why might one want to enable CM_OWN_CLIPBOARD=1? HOT 2
- I can't control it via environmental variables HOT 3
- Unrelated question. Insert unicode in terminal. HOT 1
- Choosing selection no longer works HOT 2
- Notifications about clipboard access HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from clipmenu.