Set terminal tab title using fish shell
Approach #1: setting the title by hand
When there are many terminal tabs opened, it is really useful to give them meaninful names.
Fish shell allows setting the current tab’s title creating a
If we want to name our tab
FOO, we could just write this in the terminal:
function fish_title echo "FOO" end
After entering the code, the function will be exported and the new title will be used.
The problem with this way is that writing the function each time is tedious.
There is an easy way to overcome this problem.
Approach #2: using a helper function
We could write a helper which export the
fish_title function for us.
I call this helper
set_title, but other name could be used as well.
First we need to write the helper function:
function set_title set -l title $argv function fish_title --inherit-variable title echo "$title" end end
Now we can test it, eg. to name our tab
BAR we could call it this way:
Finally, to save the function persistently, we execute this:
How does it work?
Each time we execute
set_title, it will re-export the
We need to make the title variable available inside
The trick is using the
--inherit-variable option, which will solve this for us.