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
setting terminal tab title #5700
Comments
Any news on this? I'm experiencing it too (tested on macOS Sierra Terminal and iTerm2). |
@shiyuangu You probably need to edit your
After that you can change a tab's title with something like: |
@shiyuangu solution works, just added a method inside .zshrc like this:
then I can call the method in terminal like this: |
You can put right underneath the function precmd () {
window_title="\033]0;${PWD##*/}\007"
echo -ne "$window_title"
} That will set the tab to have the title of the current file directory and using the Better yet, you should put this code in your own custom profile to keep things neat. |
Managed to put hostname + emoji in the tab title as well (using Windows Terminal and WSL). My tab title looks like:
@cameck @saurfangg One more question though: how to further let the tab-title rename itself when I enter the command-line Vim? The terminal does not opt to display Vim's own |
On MacOS 10.14, enabling On the other hand, when I press cmd + i to open the terminal settings, if I manually set the tab and window titles to I would like to set the tab title from the command line so that the extra information is similarly omitted. Does anyone know if this is possible? Ideally I would also like the window title to omit the current directory and |
add this in
ref : stackoverflow link |
@jacobpierce1 I believe the additional information is being set by the OSX terminal application, not by zsh. You can disable some of all of it via the terminal preferences, under "Profiles." There's a "tab" section that lets you choose what information to display in the tab title. |
actually, it is a function of oh my zsh, here: Line 52 in 2eb3e9d
@llinfeng the best way to auto-change the title and same time containing your custom titles is to change this function here. so, have people release some open API for it and avoid modifying the source code ? |
I'd like to customize the title used for an idle zsh shell, but I don't want to disable the "auto title" feature. Examples of why "auto title" is nice: when I run |
@jonsmithers I've now documented the automatic title settings in the wiki, have a look. |
@mcornella oh that's amazing. Thank you! And yeah, like it says, I just have to make sure it's set after the |
I like to use this snipped of code to get everything setup on a new server. Specifically: Window title: USER@HOSTNAME To do so you can just paste this into ~/.zshrc: DISABLE_AUTO_TITLE="true"
HOSTNAME=$(hostname)
TITLE_PRE="\033]0;"
TITLE_POST="@$HOSTNAME\007"
window_title="$TITLE_PRE${PWD##*/}$TITLE_POST"
echo -ne "$window_title"
function chpwd () {
window_title="$TITLE_PRE${PWD##*/}$TITLE_POST"
echo -ne "$window_title"
}
function set-title(){
TITLE="\[\e]2;$*\a\]"
echo -e ${TITLE}
}
PROMPT="$fg[yellow]%}$USER$fg[white]%}@%{$fg[cyan]%}%m ${PROMPT}" But I find it easiest to keep this copy pasta around for a new server. It will update everything: (
sed -i '/#TITLE_PROMPT_CODE_START/,/#TITLE_PROMPT_CODE_END/d' ~/.zshrc
source ~/.zshrc
read -r -d '' TITLE_PROMPT_CODE << EOM
#TITLE_PROMPT_CODE_START
DISABLE_AUTO_TITLE="true"
HOSTNAME=$(hostname)
TITLE_PRE="\033]0;"
TITLE_POST="@$HOSTNAME\007"
window_title="$TITLE_PRE${PWD##*/}$TITLE_POST"
echo -ne "$window_title"
function chpwd () {
window_title="$TITLE_PRE${PWD##*/}$TITLE_POST"
echo -ne "$window_title"
}
function set-title(){
TITLE="\[\e]2;$*\a\]"
echo -e ${TITLE}
}
PROMPT="$fg[yellow]%}$USER$fg[white]%}@%{$fg[cyan]%}%m ${PROMPT}"
#TITLE_PROMPT_CODE_END
EOM
echo $TITLE_PROMPT_CODE >> ~/.zshrc
source ~/.zshrc
) The above code can be run multiple times shoudl you forget that you've already run it. |
Hi,
On Ubuntu 16.04(Xenial Xerius): I try to set the terminal tab title following this post:
which has actually no effect. I wonder whether this problem is caused by interference with oh-my-zsh. I notice that
lib/termsupport.zsh
does define a title() function which has no effect either:Any help/suggestion on this is appreciated.
The text was updated successfully, but these errors were encountered: