0

I am using zsh 5.3 . I saw https://wiki.archlinux.org/index.php/Zsh#xterm_title and decided to use it -

~/.zshrc

autoload -Uz add-zsh-hook

function xterm_title_precmd () {
    print -Pn '\e]2;%n@%m %1~\a'
}

function xterm_title_preexec () {
    print -Pn '\e]2;%n@%m %1~ %# '
    print -n "${(q)1}\a"
}

if [[ "$TERM" == (screen*|xterm*|rxvt*) ]]; then
    add-zsh-hook -Uz precmd xterm_title_precmd
    add-zsh-hook -Uz preexec xterm_title_preexec
fi

while it works and worked beautifully, it didn't do it wholly. For instance it shows -

shirish@think-debian prompts

instead of

shirish@thnk-debian /usr/share/zsh/functions/Prompts

which would be the full path. While I do understand that is beneficial esp. if you are on a laptop or some smaller screen-sized device, on desktops this should show the full path.

Does anybody know how I can do this ?

I do know that what needs to be changed is in within the Print but what ?

function xterm_title_precmd () {
        print -Pn '\e]2;%n@%m %1~\a'
    }

    function xterm_title_preexec () {
        print -Pn '\e]2;%n@%m %1~ %# '
        print -n "${(q)1}\a"
    } 
2

From the documentation %~ is expanded to the directory name, but using ~ in place of $HOME. %1~ says just to use the last 1 component of the name.

So just remove the 1 in '\e]2;%n@%m %1~\a'

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.