Bug 436357 - Wish for custom context menu options
Summary: Wish for custom context menu options
Status: REPORTED
Alias: None
Product: konsole
Classification: Applications
Component: general (show other bugs)
Version: unspecified
Platform: Other Other
: NOR wishlist
Target Milestone: ---
Assignee: Konsole Developer
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2021-04-29 13:24 UTC by Phillip Taylor
Modified: 2021-04-30 16:09 UTC (History)
2 users (show)

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Phillip Taylor 2021-04-29 13:24:54 UTC
I used to maintain a hacked version of Konsole that gave me a way to turn certain text into automatic hyperlinks. This blog post explains what I did:

https://blog.philliptaylor.net/the-terminal-with-jira-integration-a-kde-konsole-hack/
https://github.com/PhillipTaylor/konsole/commit/0e5f9a374894a2d3057afd9dcd23478d59da5630

I would absolute adore someone, who could reimplement this in the latest Konsole and get it into master where it may always be supported. In my mind, the best "generic" solution that everyone could benefit from is a new page in the profile section called "Context Links". There would be three columns like the table below and users can add new ones at the bottom: 

 Context Links Tab
 -----------------
 
 Regex                Command                 Menu Text
 
 "http://(.*)"        "xdg-open browser $1"   Open link in browser
 "mailto:(.*)\s"      "xdg-open email $1"     Send mail from email client
 [ space to add more records, 
 
 
 
 Konsole already hardcodes regexs to open websites and email. This   
 is a reimplementation of that feature that allows people to add their own. I would
 personally benefit from adding a new row like this:
 
 "MY-JIRA-(\d+)"     "xdg-open browser http://myjira/$1"   "Visit JIRA ticket in browser"
 
 but it could suit many other people's needs.
 
 "[a-z]{8}"          "xdg-open browser http://mygit/commit/$1"  "Open git hash in my server"
 "(.*).mp3           "xdg-open audioplayer $1.mp3"              "Play MP3 in audioplayer"
 "/r/(.*)"           "xdg-open browser https://reddit.com/r/$1" "View subreddit"

The first column is the regex that triggers the underline behaviour, the third column is the
text to show in the content menu when you right-click on it. The middle column is the command
to execute when you choose the menu option.

Anyway, this is my idea, I can personally attest to using it for years that it's super useful. Thank you to all Konsole developers for all your hard work, which I have depended on for years.
Comment 1 tcanabrava 2021-04-29 17:26:29 UTC
Phillip,

I really like your idea, and I think it's great. Considering that you already have a patch for this, would you have time to implement the rest needed for a generic option?
If so, I can give you a hand to get it started. If not, I'll implement when I find the time (near future)
Comment 2 Phillip Taylor 2021-04-30 15:44:31 UTC
I'm happy to try one more time and I'll let you know if I have no success.
Comment 3 Duncan 2021-04-30 16:09:42 UTC
CCing.

I've long been using klipper's very similar functionality for X-selections and the clipboard.  But many of the selections are ultimately in konsole so it would be useful to have the functionality directly in konsole, avoiding the selection step and routing through klipper.

Which suggests that (at least ultimately) the core feature supporting code could be a framework library that both klipper and konsole (and whatever other kde apps could use the functionality) could simply wrap to implement the feature as needed in their individual contexts.

If I were a proper coder I'd be on that "yesterday", as they say.  But while I'm often able to read code (especially when pointed at it by a related git commit) and copy/tweak well enough to hack up changes I might need (and I take full advantage of that via gentoo's live-git kde packages), I'm effectively unable to do my own code (bash/lua excepted) "out of whole cloth", so something like this, certainly at better than hard-coded-hack-patch quality, remains well beyond me.