Skip to content

Set Window title and Tab title separately #2692

Closed

Description

@eugenesvk

In zsh I am able to set tab and window titles separately in iTerm2, e.g. I have

  1. Tab title: current folder only to easily differentiate tabs by which folder they're open at. In path ~ replaces username (echo -ne "\033]1;{$PWD1/#username/~}\007", where PWD1={$PWD##*/}
  2. Win title: full path with ~ instead of /users/username (echo -ne "\033]2;{$PWD/#"$HOME"/~}\007")

As I understand from #47, fish just sets both windows and tab titles with the same fish_title function.
Is it possible to separate those two, maybe have a separate tab_title function or something so that users who are not using it continue to get both windows and tab title within the old function?
Also, in zsh I am able to add a bell char (\007) to the titles. How do I do that in fish?
Thanks!

P.S.
My system is OS X 10.11.2, iTerm2 2.9.20160113 and fish 2.2.0-542-g4b2495f

Activity

  1. floam commented on Feb 21, 2016

    @floam
    Member

    I am able to add a bell char (\007) to the titles. How do I do that in fish?
    Thanks!

    For me in both iTerm2 and Terminal.app with fish, zsh, and bash on 10.11.4 (and I remember earlier) I will often see a bell glyph printed on the correct tab bar if I cause a BEL (\a or \007) while a tab/window is inactive or not getting any input. It goes away when I focus it.

    screenshot 2016-02-21 at 3 20 02 am

    Your report does remind me that I kind of am disappointed that fish itself almost under no circumstances will ring a BEL. Considering the general lack of richness that goes along with a terminal emulator I'm surprised there are zero situations where we'd like to take advantage of a very well supported feature that can convey information without a font: the bell can flash the window visually or ring a quick alert sound (depending on how it's configured. I prefer visual bells.) for free!

    It's a very nice way to quickly indicate that an action is having no effect or something is having trouble. Also, the only way for an ignored session in the background that requires some attention to ping me with that bell character and/or dock icon bouncing.

    As for titles I actually have found that, as fish does a good job of reporting the accurate CWD, and also most terminals I use are able to figure out the active process on their own... the most preferable thing to do with my title bars is to turn off a custom title in the shell, disabling the function. I simply pick and choose the things I'd like to see in each space directly in my terminal emulator preferences, for the tab and title bar separately: current directory. full path. activity indicators. active program, open document... and it's a more easy, pleasant, and rich experience I'm having than I ever had trying to shove a carefully planned string up there in the past.

    Given how basically this is a standard feature with terminals now, though, it does seems to reason that Fish could do a better job of providing relevant information for both the tab titles & (which is space constrained, but visible at the same time as) window titles.

    Just sending the same exact thing over two times doesn't make any sense: there is nobody out there who can render tab titles but has a terminal that can't interpret the terminal title OSC.

  2. eugenesvk commented on Feb 21, 2016

    @eugenesvk
    Author
  3. floam commented on Feb 21, 2016

    @floam
  4. eugenesvk commented on Feb 21, 2016

    @eugenesvk
    Author
  5. faho commented on Feb 21, 2016

    @faho
    Member

    Is there anything left to do here or does iterm's integration solve the issue?

  6. eugenesvk commented on Feb 21, 2016

    @eugenesvk
    Author

    @faho Yes, the main issue remains — allowing two different settings for window title and tab title
    iTerm's integration didn't solve the bell issue, I still get bell->progress circle->pencil in fish (but not in bash) in iTerm.

  7. eugenesvk commented on Feb 21, 2016

    @eugenesvk
    Author
  8. floam commented on Feb 22, 2016

    @floam
  9. eugenesvk commented on Feb 22, 2016

    @eugenesvk
    Author
  10. floam commented on Feb 23, 2016

    @floam
  11. krader1961 commented on Feb 23, 2016

    @krader1961
  12. floam commented on Feb 23, 2016

    @floam
  13. eugenesvk commented on Feb 23, 2016

    @eugenesvk
    Author
  14. krader1961 commented on Feb 24, 2016

    @krader1961
  15. eugenesvk commented on Feb 24, 2016

    @eugenesvk
    Author
  16. 10 remaining items

  17. floam commented on Apr 6, 2019

    @floam
    Member

    I'm trying to think of a way to allow users to tailor the behavior without creating new functions, and keeping it such that those who don't care about the distinction don't need to for the current behavior to stay the way it is.

    My current idea is a bit of magic, which is fish internally determining if the fish_title function was defined with named arguments, specifically one called type. This will tell fish the title function has opted into getting called twice each time the title is updated instead of just once. It will get called once with a first argument of window, and a second time with a first argument of tab, or whatever the most appropriate cross-terminal way of describing this is. It would be used like this:

    function fish_title -a type
        switch $type
            case tab
                echo stuff for the tab
            case window
                echo stuff for the window
        end
    end
  18. faho commented on Apr 6, 2019

    @faho
    Member

    My current idea is a bit of magic, which is fish internally determining if the fish_title function was defined with named arguments, specifically one called type.

    Why the named argument? Just pass it an argument, call it twice, find out who's naughty or nice and use the output? fish_title is usually quite simple and fast, so it shouldn't take too long.

    Alternatively:

    I'm trying to think of a way to allow users to tailor the behavior without creating new functions

    Why not allow specifying fish_tab_title and use that for the tab title if it exists, fish_title otherwise?

  19. floam commented on Apr 6, 2019

    @floam
    Member

    Why the named argument? Just pass it an argument, call it twice, find out who's naughty or nice and use the output? fish_title is usually quite simple and fast, so it shouldn't take too long.

    The idea was to avoid executing it twice.

  20. floam commented on Apr 6, 2019

    @floam
    Member

    Oh, and because we need a way to flag to fish whether this is output to be used for \e]1, \e]2, or \e]0. If we just ran it twice, it looks to us like stuff to be sent \e]1 and then again with \e]2, not \e]0 which is the current behavior.

  21. floam commented on Apr 6, 2019

    @floam
    Member

    Here's what the parameters are, by the way:

    2: Set window title
    1: Sets tab title
    0: Sets both window title and tab title (fish_title today)

  22. floam commented on Apr 7, 2019

    @floam
    Member

    Just doing a function may be a better idea, yeah.

  23. floam commented on Apr 7, 2019

    @floam
    Member

    Today I learned:

    The first argument to fish_title will contain the most recently executed foreground command as a string, starting with fish 2.2.

    fish_title already gets an argument! Had no idea. edit: and... it does not appear to actually do that in practice.

  24. hisnawi commented on Mar 31, 2020

    @hisnawi
  25. faho commented on Mar 31, 2020

    @faho
  26. hisnawi commented on Mar 31, 2020

    @hisnawi
  27. AdamMomen commented on Nov 24, 2021

    @AdamMomen
  28. added a commit that references this issue on Nov 6, 2025
    d6ed5f8
  29. modified the milestones: fish-future, fish 4.2 on Nov 12, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions