Is it possible to have a clickable link, in my PS1
, that opens a pop-up menu or something similar?
My scenario
I've personalized my .bashrc
, to show my PS1
as
user@machine: path #/$
and if I'm inside a git repository, it also show my branch and a different char for the status
user@machine: path [branch !] #/$
By the way, I got the code to do this here in Ask Ubuntu.
My idea
What I wanted was to click in the branch name, and a list of the downloaded branches is shown (with or without the option to change it).
I found some "dialog" and "select/choice" options for the pop-up menu, but couldn't find anything for the clickable link.
If I had to do this, I'd pick a terminal emulator like Terminator and write a new plugin. I might have to hack how that all worked but it should be possible for Terminator to pick up the text and then, using what it knows about the shell environment, present a GTK3 menu for picking.
The only other way I can think of to thoroughly handle this is to write your own shell replacement. Something that wraps around bash (et al) and handles mouse involvement. There are things out there like PyScreen that do this but there's nothing out there that does what you want directly. Proxying terminals is also a recipe for render bugs. Even mature things in this space (eg
screen
) occasionally mess things up.More than anything, neither of these is 20 minute exercise. The plugin would take me hours, the shell would likely take days to get right. I'd probably push back on whomever was telling me to do this and say it's an uneconomical use of my time.
If I just wanted this for myself, I'd probably just write a little
br
command that listed the branches and allowed me to pick. There are examples out there but I won't present any one as the best solution. They're all a compromise on what you wanted.