Provide a friendly way to access the terminal title string
In a nutshell: terminal (tab) title provides data without a friendly way to access it neither to edit it nor copy it.
Context
I am giving a try to minimize the data encompassed in my prompt. What I mean, is that currently I only keep the time at which the prompt was spawn, and if the last command result code if it didn't finished successfully. However I still want to have access to some contextual information: Tmux gives me data about the current git repository state if there is any, and the title bar give me the current path, plus user/host names if they are different from usual_account@localhost.
This way, I still have all the data I'm used to have in the prompt accessible at a glance, but my shell session looks uncluttered and space which is taken anyway by the GNOME-terminal headerbar and the Tmux status-bar is not wasted with data I never bother to look at as they wouldn't bring more information than what was duplicated in the prompt.
The issue
So far, so good. But there are time when you want to interact with these data, either simply copying it or even edit it. On this regard, putting the git state summary in the Tmux status bar already provides an easy access to a select© feature. But having the path in the header bar or tab title means that I currently can not select and copy it from here.
Of course, it would be possible to put everything in the Tmux title bar, but would both overload this zone and waste the header bar with duplicated data.
Some suggestions
So, here is some possibilities that this situation inspire me:
- maybe we could have a headerbar more similar to the one that GNOME Web had for a time (if I recall correctly): having a purely "show" look&feel, but turning into a text box when clicked1.
- having a copy button next to the title to copy the whole title string
- having a gear button, next to the previous one, that allows to specify the title format
On this last point, it might be be a bit too much clutter for the frequency at which you would expect one to edit such a configuration. So it might be wiser to instead extend the existing entry of the configuration panel for "Initial title", so it allow to run commands, that is the default value might be echo 'Terminal'
and it would be easy to change it to "echo "USER@
HOSTNAME - $PWD". That might rise security concern however, especially if this should be periodically run into the background to make the result relevant even when the shell is currently in a SSH session. This concerned might be reduced by changing the "When terminal commands set their own titles" to "Update of the title", with options like "Always keep the initial title", "Periodically refresh title by executing this command", "Allow commands to set the terminal
I'm aware some shell enable to do it in the other way: that is, setting the terminal title from the shell rather than grabbing data from the current shell from the terminal. Thus said, while PROMPT_COMMAND='echo -ne "\033]0;${USER}@${HOSTNAME}: ${PWD}\007"'
works in Bash, it seems Fish won't be able to do the same trick through set PROMPT_COMMAND echo -ne "\033]0;$USER@$HOSTNAME: $PWD\007"
. Maybe some other Fish arcane might do the trick, but I'm not knowledgeable enough on this. Maybe there is even already something like gnome-terminal --update-current-title="Custom title"
?
Anyway, the way the title is set is actually a different one from my initial concern of being able to copy the current-title in a mouse-friendly way (I guess one can always launch some command to grab the current terminal title).
-
Or accessed through some key shortcut. In browsers I'm accustomed to using crl+l but in terminals it's usually already taken for calling
clean
.↩