zsh-tab-title icon indicating copy to clipboard operation
zsh-tab-title copied to clipboard

Disable prefix not working

Open sillen102 opened this issue 4 years ago • 24 comments

Hi.

I have set the ZSH_TAB_TITLE_DEFAULT_DISABLE_PREFIX=true in my .zshrc but the user and computer name separated by '@' is still showing in the title.

Using v.2.2.0

sillen102 avatar Aug 03 '21 09:08 sillen102

Hi @sillen102,

Did you exported the setting ?

You should add like this in the .zshrc file:

export ZSH_TAB_TITLE_DEFAULT_DISABLE_PREFIX=true

Please let me know if this fix the issue.

trystan2k avatar Aug 03 '21 09:08 trystan2k

No it doesn't. The variable is exported. I can even test it in the command line like so:

❯ echo $ZSH_TAB_TITLE_DEFAULT_DISABLE_PREFIX
true

What I have done now i simply this:

if [[ "$ZSH_TAB_TITLE_DEFAULT_DISABLE_PREFIX" == true ]]; then
  ZSH_TAB_TITLE_PREFIX=""
elif [[ -z "$ZSH_TAB_TITLE_PREFIX" ]]; then
  #ZSH_TAB_TITLE_PREFIX="%n@%m:"
  ZSH_TAB_TITLE_PREFIX=""
fi

But this only works for me personally since I'm not interested in having any prefix. So something isn't working right.

sillen102 avatar Aug 04 '21 14:08 sillen102

I've also seen that ZSH_TAB_TITLE_ONLY_FOLDER also dosent work right for me. It is displaying the whole path still even though it's set.

I have these set in my .zshrc:

export ZSH_TAB_TITLE_CONCAT_FOLDER_PROCESS=true
export ZSH_TAB_TITLE_ONLY_FOLDER=true
export ZSH_TAB_TITLE_ENABLE_FULL_COMMAND=true
export ZSH_TAB_TITLE_DEFAULT_DISABLE_PREFIX=true

sillen102 avatar Aug 04 '21 14:08 sillen102

Hi @sillen102,

Strange. I have tested it before send the previous reply, and it worked for me.

What terminal and OS are you using ?

Because I am using Hyper.js and indeed in this terminal I do not see the prefix (it only shows me the current directory I am in) with the setting setup or not, but using Mac OS Terminal.app, the setting works fine.

trystan2k avatar Aug 04 '21 14:08 trystan2k

I'm running Debian 11 Bullseye and using GNOME-Terminal

sillen102 avatar Aug 04 '21 14:08 sillen102

Ok. I will install it in a virtual machine and try to reproduce it, because as I said, in Mac OS Termina.app is working fine.

I will let you know when I have some news on this.

trystan2k avatar Aug 04 '21 14:08 trystan2k

The strange part is that I am running oh-my-zsh and installing it didn't work. It couldn't find the plugin until I changed the name of the folder from zsh-tab-title to simply title. I guess it's because the name of the zsh-file is title.plugin.zsh?

So far from what I can see the only thing working for me is export ZSH_TAB_TITLE_CONCAT_FOLDER_PROCESS=true because it actually does show the folder and the command when I run something.

sillen102 avatar Aug 04 '21 14:08 sillen102

I'm on my working machine now (with Debian). But I will try it on my MacBook later tonight as well.

sillen102 avatar Aug 04 '21 14:08 sillen102

I just tried something that might have fixed it. I reinstalled and didn't move the folder from .oh-my-zsh/custom/plugins/zsh-tab-title to .oh-my-zsh/custom/plugins/title. Instead I renamed the file from title.plugin.zsh to zsh-tab-title.plugin.zsh (to fix the plugin not found error). And now it works!

However I am still confused about the ZSH_TAB_TITLE_ONLY_FOLDER becase it is till showing the whole path and not just the last folder.

sillen102 avatar Aug 04 '21 14:08 sillen102

Great. I think I didn't test with oh-my-zsh. I will take a look and update the documentation, if needed.

About the ZSH_TAB_TITLE_ONLY_FOLDER , still see it works for me in Terminal.app at Mac OS the only strange thing is that it show the folder 2 times, one complete and one just the folder.

If you execute this command in terminal ${PWD##*/} does it show the folder name (only the folder name, not complete path) ?

trystan2k avatar Aug 04 '21 15:08 trystan2k

It does. It does show just the folder name when I run the command. Like so:

/etc/systemd/system🔒 
❯ echo ${PWD##*/}
system

However the title still shows the full path.

image

sillen102 avatar Aug 05 '21 06:08 sillen102

I even tried editing the part with the ZSH_TAB_TITLE_ONLY_FOLDER like so:

  if [[ "$ZSH_TAB_TITLE_ONLY_FOLDER" == true ]]; then
    #ZSH_THEME_TERM_TAB_TITLE_IDLE=${PWD##*/}
    ZSH_THEME_TERM_TAB_TITLE_IDLE="SOME TEXT"
  fi

  ZSH_THEME_TERM_TAB_TITLE_IDLE="SOME TEXT"

It still shows the full path. It's as if it's being overridden by something. I wonder if it's something inside ./oh-my-zsh/oh-my-zsh.sh that is being sourced. I have not altered this file at all though so it's the one from the oh-my-zsh repo.

The variable is set and as you can see I also tried setting ZSH_THEME_TERM_TAB_TITLE_IDLE outside of the if-statemen but even that didn't work.

❯ echo $ZSH_TAB_TITLE_ONLY_FOLDER         
true

sillen102 avatar Aug 05 '21 07:08 sillen102

Ok, I think I found what is going on.

Seems like gnome-terminal does not let to set different texts to terminal title and tabs, and the zsh-tab-title use this functionality in other terminals.

For example, ZSH_TAB_TITLE_ONLY_FOLDER only works to show the folder in tab title (while in window it still show the full folder): image

That is why it is 'not working' for you, because you are seeing is the window title, always.

The solution for these case could be to check if it is the gnome-terminal and if so, set both information (which we would set to window and tab) into one string (concatenating it) and set as window title. That way all settings will work as expected, and you will see correctly the data.

I will see if I get some time over the weekend and do this change in a branch and let you know, so you can test and see what do you think and if it is all good, I can release a new version.

What do you think ?

trystan2k avatar Aug 05 '21 10:08 trystan2k

Sure I'd be willing to try it out!

sillen102 avatar Aug 05 '21 13:08 sillen102

Hi @sillen102,

I made a initial attempt to fix this for gnome_terminal, could you please test and see if it works as expected for you ?

You can copy the code from here: https://github.com/trystan2k/zsh-tab-title/blob/feature/gnome_adjusts/zsh-tab-title.plugin.zsh and paste it into your installed plugin file.

Please let me know if you have any question and how it goes!

trystan2k avatar Aug 09 '21 06:08 trystan2k

Hi. Great, thanks. I will test it. I am on vacation at the moment though and don't have access to my work computer. I will do it next week and get back to you.

sillen102 avatar Aug 12 '21 20:08 sillen102

Don't worry, enjoy your vacations and when you are back and able to test, just let me know the results!

trystan2k avatar Aug 13 '21 05:08 trystan2k

Hi @sillen102,

Did you get a chance to test if the change solve your case ?

Thanks !

trystan2k avatar Sep 12 '21 16:09 trystan2k

Hi.

I just tested it and it does not work.

sillen102 avatar Sep 13 '21 14:09 sillen102

Hey @trystan2k,

Unfortunately I ran into the same issue. I've used your plugin for a while, but have to report that disabling the prefix indeed does not work like expected.

I'm running zsh in kitty. Initially I loaded your plugin using zgenom, but to make sure I am able to reproduce the issue, I did the following:

  • Launch terminal emulator kitty Terminal tab is set to "zsh" ZSH_TAB_TITLE_PREFIX is unset
  • Source the plugin manually by running source .../zsh-tab-title.plugin.zsh Terminal tab is set to "USER@HOST: FULL_PATH" ZSH_TAB_TITLE_PREFIX got set to "%n@%m:" by plugin
  • Run export ZSH_TAB_TITLE_DEFAULT_DISABLE_PREFIX=true Terminal tab title does not change
  • Run export ZSH_TAB_TITLE_ONLY_FOLDER=true Terminal tab title does not change

Running export ZSH_TAB_TITLE_CONCAT_FOLDER_PROCESS=true or export ZSH_TAB_TITLE_ENABLE_FULL_COMMAND=true both work and result in the expected tab title when running a command.

I can disable the prefix if I launch it like this:

ZSH_TAB_TITLE_DEFAULT_DISABLE_PREFIX=true source ~/.zgenom/sources/trystan2k/zsh-tab-title/___/zsh-tab-title.plugin.zsh
# or
export ZSH_TAB_TITLE_DEFAULT_DISABLE_PREFIX=true && source ~/.zgenom/sources/trystan2k/zsh-tab-title/___/zsh-tab-title.plugin.zsh

For whatever reason this does not work for ZSH_TAB_TITLE_ONLY_FOLDER...

If I echo the value of variable tabTitle used in the title function, by inserting echo $1 on line 18 in the plugin, I can observe whether the assignment works correctly.

  • Trying to set it like this assigns the variable correctly:
    export ZSH_TAB_TITLE_ONLY_FOLDER=true && source ~/.zgenom/sources/trystan2k/zsh-tab-title/___/zsh-tab-title.plugin.zsh
    
    It prints only the folder of the cwd like expected. However, the tab title still does not get set to it. This might be a bug in kitty though....perhaps @sillen102 or someone else could try it in a different terminal emulator.
  • Trying to set it like this does not:
    ZSH_TAB_TITLE_ONLY_FOLDER=true source ~/.zgenom/sources/trystan2k/zsh-tab-title/___/zsh-tab-title.plugin.zsh
    
    It prints "%20<..<%~%<<"

totoroot avatar Oct 12 '23 10:10 totoroot

Hey @trystan2k,

Unfortunately I ran into the same issue. I've used your plugin for a while, but have to report that disabling the prefix indeed does not work like expected.

I'm running zsh in kitty. Initially I loaded your plugin using zgenom, but to make sure I am able to reproduce the issue, I did the following:

  • Launch terminal emulator kitty Terminal tab is set to "zsh" ZSH_TAB_TITLE_PREFIX is unset
  • Source the plugin manually by running source .../zsh-tab-title.plugin.zsh Terminal tab is set to "USER@HOST: FULL_PATH" ZSH_TAB_TITLE_PREFIX got set to "%n@%m:" by plugin
  • Run export ZSH_TAB_TITLE_DEFAULT_DISABLE_PREFIX=true Terminal tab title does not change
  • Run export ZSH_TAB_TITLE_ONLY_FOLDER=true Terminal tab title does not change

Running export ZSH_TAB_TITLE_CONCAT_FOLDER_PROCESS=true or export ZSH_TAB_TITLE_ENABLE_FULL_COMMAND=true both work and result in the expected tab title when running a command.

I can disable the prefix if I launch it like this:

ZSH_TAB_TITLE_DEFAULT_DISABLE_PREFIX=true source ~/.zgenom/sources/trystan2k/zsh-tab-title/___/zsh-tab-title.plugin.zsh
# or
export ZSH_TAB_TITLE_DEFAULT_DISABLE_PREFIX=true && source ~/.zgenom/sources/trystan2k/zsh-tab-title/___/zsh-tab-title.plugin.zsh

For whatever reason this does not work for ZSH_TAB_TITLE_ONLY_FOLDER...

If I echo the value of variable tabTitle used in the title function, by inserting echo $1 on line 18 in the plugin, I can observe whether the assignment works correctly.

  • Trying to set it like this assigns the variable correctly:

    export ZSH_TAB_TITLE_ONLY_FOLDER=true && source ~/.zgenom/sources/trystan2k/zsh-tab-title/___/zsh-tab-title.plugin.zsh
    

    It prints only the folder of the cwd like expected. However, the tab title still does not get set to it. This might be a bug in kitty though....perhaps @sillen102 or someone else could try it in a different terminal emulator.

  • Trying to set it like this does not:

    ZSH_TAB_TITLE_ONLY_FOLDER=true source ~/.zgenom/sources/trystan2k/zsh-tab-title/___/zsh-tab-title.plugin.zsh
    

    It prints "%20<..<%~%<<"

Hi @totoroot ,

Thanks for such detailed report !

I will try to look into it in the next days and get back to you if I find the solution to this problem.

One question though, are you using which OS ? Linux, Mac, Windows ... ?

trystan2k avatar Oct 13 '23 03:10 trystan2k

No worries, I still get good use out of your plugin, so no need to hurry. I tried to find the issue myself, but couldn't and thought you might know better what could be the reason.

I'm using NixOS, so Linux. If it helps, I could check if I encounter the same issue on macOS. As far as I remember it was just the same with zsh in kitty.

Thanks for looking into it!

totoroot avatar Oct 15 '23 17:10 totoroot

https://github.com/trystan2k/zsh-tab-title/blob/feature/gnome_adjusts/zsh-tab-title.plugin.zsh

Hi @totoroot ,

I think I found the issue.

The main problem was that some of the environment variables were only been take into account when you open a new terminal. If you export a env variable after that, it does not read it again so it does not take effect.

I have changed that so it will take check all variables when the title is about to change back to idle state.

Could you please test the code I pushed to this branch and let me know if it now works ? https://github.com/trystan2k/zsh-tab-title/tree/feature/fix-env-load

Let me know if it works and if so, I do a release with this fix.

Thanks

trystan2k avatar Oct 22 '23 12:10 trystan2k

It could also fix your problems @sillen102 , if you still use the plugin and could take a look.

trystan2k avatar Oct 22 '23 12:10 trystan2k