Git Product home page Git Product logo

Comments (10)

AeliusSaionji avatar AeliusSaionji commented on May 19, 2024 1

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.

cdown avatar cdown commented on May 19, 2024

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.

kaihendry avatar kaihendry commented on May 19, 2024

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.

cdown avatar cdown commented on May 19, 2024

Sounds reasonable enough.

from clipmenu.

AeliusSaionji avatar AeliusSaionji commented on May 19, 2024

@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.

kaihendry avatar kaihendry commented on May 19, 2024

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.

kaihendry avatar kaihendry commented on May 19, 2024

Weird, xsel -co doesn't output anything for me on Arch.

from clipmenu.

AeliusSaionji avatar AeliusSaionji commented on May 19, 2024

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.

kaihendry avatar kaihendry commented on May 19, 2024

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.

cdown avatar cdown commented on May 19, 2024

Easy enough now that we have locking support, see db05c51 :-)

from clipmenu.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.