Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(termsupport): Allow configurable terminal title patterns & cmdline truncation limits #11875

Open
trinitronx opened this issue Sep 5, 2023 · 1 comment
Assignees
Labels
Feature New feature or request

Comments

@trinitronx
Copy link
Contributor

trinitronx commented Sep 5, 2023

If the feature request is for a plugin or theme, specify it here.

No response
N/A: Code is in core / lib/termsupport.zsh

If the feature solves a problem you have, specify it here.

Context for Use-Case:

Desktop environments that use tiling window managers (e.g. i3, sway, hyprland, river, and others) depend on window title for various things such as window matching rules, tab & workspace icons, taskbar title rewriting, etc... Adding icons based on window title makes it a lot easier and faster to visually pick out a window amongst many others.

Allowing for configurable window title would be a huge usability and UI/UX improvement for these desktop environments. Given the above context, would you be willing to agree that allowing title customization would improve UI/UX for those environments?

Describe the proposed feature.

Allow for configurable ZSH_THEME_TERM_*TITLE* settings, similar to proposal in #11870

Describe alternatives you've considered

Alternative feature proposal was in #11870

Additional context

@mcornella:

Sorry for opening a new issue but GitHub would not allow me to respond in #11870 after it was closed. So I'll try to respond to your comments here instead, and Thanks for the feedback!

Doing so requires a level of hacky-ness that I don't really feel worth it or stylish, and is very coupled with the title logic.

Yeah, that's fair. While I'd agree that POSIX shell syntax isn't the most stylish of languages in general... I'm not sure I'd agree that setting a default if unset is all that "hacky" per se... Although I would agree that the "${foo:-default-here}" syntax when combined with ZSH's Prompt Expansion / truncation behaviour syntax together is rather esoteric. It's a bit unfortunate that it starts to become less readable and look more like Perl than shell scripting 😂. Perhaps another solution to make it more clear and readable might be to split it up into multiple lines?

For example:

# Allow overriding these settings, but fallback to defaults if unset
...

_default_tab_title_idle='%15<..<%~%<<' #15 char left truncated PWD
ZSH_THEME_TERM_TAB_TITLE_IDLE="${ZSH_THEME_TERM_TAB_TITLE_IDLE:-$_default_tab_title_idle}"

...  # Do the same pattern for the rest

@mcornella, @carlosala:

... I think at this stage we are not looking at getting at such a fine-grained level of customization.
...
We'll be looking in the future to revise this decision to see if we can improve this somehow.

I do hope this will be possible 😅

When I was looking at the lib/termsupport.zsh in #11868, I noticed that it seemed a bit strange for these variables being hard-coded and named ZSH_THEME_TERM_* as if the original intent was to expose them as configurable theme settings. I figured a quick fix would be to use the "set if unset" POSIX syntax, but maybe there's a better more stylish way? ¯\_(ツ)_/¯

In the meantime, you can redefine the functions yourself in your zshrc file, or disable our solution by setting DISABLE_AUTO_TITLE=true and fully customize your logic while keeping compatibility with the title function.

Unfortunately, there are already forked older versions of omz's title set behavior which are currently broken and don't actually set the title based on current running command. Overriding both OMZ's title & precmd / preexec hooks and the copied & broken versions clutters and slows down the pre-installed Zsh hooks on these distros. So far I've tried overriding both, but the result was not ideal. My current workaround was to edit the OS-supplied file to disable their broken hooks, to get stock OMZ behavior only to find that this also didn't work for my use case requirements:

  • Idle title with current working directory & longer truncation char limit
  • Running command as title when not idle

It's rather unfortunate that the title setting behavior in OMZ isn't configurable and has a 15 character limit hard-coded by default. Otherwise, this would have worked without modification to OMZ's internals.

Related Issues

@trinitronx trinitronx added the Feature New feature or request label Sep 5, 2023
@trinitronx
Copy link
Contributor Author

@mcornella, @carlosala: I should also add that I'm happy to work on this, as in #11870, but need some feedback as to what alternative implementation style would be approved.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature New feature or request
Projects
Status: Backlog
Development

No branches or pull requests

2 participants