romkatv / zsh4humans

A turnkey configuration for Zsh
MIT License
1.62k stars 103 forks source link

Konsole Tab Titles not showing remote host name #147

Closed FuzzyMistborn closed 2 years ago

FuzzyMistborn commented 2 years ago

Apologize if this is a dumb question. I'm really enjoying zsh4humans so far and it's exactly what I was looking for in an ZSH customizer. However, one issue I'm running into involves the path/host in the bottom of my Konsole terminal. I like to keep a lot of terminal tabs open and I'm often connected to various remote hosts. On bash when I would connect to a remote host the bottom bar would update/display the name of the remote host so I could easily figure out which tab had what SSH session open. I'm not seeing similar behavior now with zsh.

I also noticed that the path does not get updated when I change it in the terminal. IE it always just shows ~

image

I'm SSH'd into a remote host (dominion) here and it still says I'm connected to my desktop (kelsier). Is there a setting I've missed that would fix this? Any help would be appreciated!

romkatv commented 2 years ago

Not a dumb question at all.

Open Konsole, click Settings → Edit Current Profile → Tabs, and set Tab title format and Remote tab title format to %w.

image

FuzzyMistborn commented 2 years ago

D'oh. Swear I'd tried that! That solves the remote part and directory. Any way to make it so when I'm just on the desktop I get more than ~? Not a huge deal, just curious if that's at all customizable. I try to add something to tab title format and it repeats when I remote connect which isn't ideal.

romkatv commented 2 years ago

Any way to make it so when I'm just on the desktop I get more than ~?

Your prompt and the terminal title show ~ when your current directory is ~. Try running cd ~ and you'll see ~ in there.

Does it make sense? What do you want to see in prompt and the title when your current directory is ~?

I try to add something to tab title format and it repeats when I remote connect which isn't ideal.

If something doesn't work as expected, please provide specific instructions that would allow me to reproduce this. Mention what you expect to happen when you follow your own instructions and what actually happens.

FuzzyMistborn commented 2 years ago

Does it make sense? What do you want to see in prompt and the title when your current directory is ~?

Yes it does. What I was after was something like when I'm connected via SSH. So when I'm connected via SSH, I see "Fuzzy@Dominion : currentdir" and when i'm local it's just "~". I'd like to see "kelsier : currentdir" (kelsier is my local host). Not a huge deal, I'm just curious.

romkatv commented 2 years ago

Thanks for clarifying.

This is intentional. Most of the time you are on a local machine, so there is no point in showing its hostname. It's just clatter. It's the same reason why on a local machine powerlevel10k doesn't show hostname in prompt but when you are connected via SSH it does. All of this is customizable of course. Here's how you can make terminal title be the same when you are working locally as when you are working over SSH:

zstyle ':z4h:term-title:*' preexec '%n@%m: ${1//\%/%%}'
zstyle ':z4h:term-title:*' precmd  '%n@%m: %~'

For the reference, the default is this:

zstyle ':z4h:term-title:ssh'   preexec '%n@%m: ${1//\%/%%}'
zstyle ':z4h:term-title:ssh'   precmd  '%n@%m: %~'
zstyle ':z4h:term-title:local' preexec '${1//\%/%%}'
zstyle ':z4h:term-title:local' precmd  '%~'

You can see that the default sets different title templates for ssh and local.

If you want prompt to always show username@host, see https://github.com/romkatv/powerlevel10k#how-do-i-add-username-andor-hostname-to-prompt

FuzzyMistborn commented 2 years ago

Perfect! Thank you VERY much, exactly what I was looking for!

romkatv commented 2 years ago

Thanks for the confirmation.