4

I have been playing around with the settings in the kitty docs.

I am using tab_title_template to change the title of a tab.

The {title} variable includes the file name and the path. Is there any way to take out the path and only have the file name?

my current kitty.conf looks like this:

tab_title_template "{index}: {title}"  
Vinn
  • 165
  • 1
  • 6

3 Answers3

4

I am playing with kitty today as well, and I come upon the same question as you. This is the way I figure out myself just then. Hope to give you some inspiration!

tab_title_template "{index}: {title[title.rfind('/')+1:]}"  
yhcmv5
  • 56
  • 2
  • 1
    In those comment out descriptions in kitty.conf it mentions that "formatting is done by Python's string formatting machinery" , this is why I use the python function r.find() to find the index of the last '/' in the title string. – yhcmv5 Apr 05 '22 at 07:43
  • 1
    Good solution. One may want to do that for `active_tab_title_template` as well. – Fernando Basso Nov 06 '22 at 10:37
0

I am using this in my kitty.conf

tab_title_template "{index}: {title.split('/')[-1]}"
0

Maybe kind of late for you all, but the "title" value kitty is using in the template there comes from your title set in your shell.

So like in zsh you can put something like this in your zsh config to change it to whatever you want:

DISABLE_AUTO_TITLE="true" to disable the automatic titling based on the defaults and then

function stitle() { echo -en "\e]2;$@\a" } you can put in this function and change it to whatever you want. In this example it prints only the path and not the "username@host" which I like, but you can change it to not include the path.