From fbca62ea3ff66a221e243bbcdcb9e4f7d1348d32 Mon Sep 17 00:00:00 2001 From: Mathias Fredriksson Date: Mon, 1 Jun 2015 13:27:44 +0200 Subject: [PATCH] Close #124 PR: Show hostname in terminal title if session is over ssh. --- pure.zsh | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/pure.zsh b/pure.zsh index 6976a88..7f6f082 100644 --- a/pure.zsh +++ b/pure.zsh @@ -61,9 +61,13 @@ prompt_pure_check_git_arrows() { prompt_pure_preexec() { prompt_pure_cmd_timestamp=$EPOCHSECONDS - # shows the current dir and executed command in the title when a process is active + # tell the terminal we are setting the title print -Pn "\e]0;" - echo -nE "$PWD:t: $2" + # show hostname if connected through ssh + [[ "$SSH_CONNECTION" != '' ]] && print -Pn "(%m) " + # shows the current dir and executed command in the title when a process is active + # (use print -r to disable potential evaluation of escape characters in cmd) + print -Pnr "$PWD:t: $2" print -Pn "\a" } @@ -126,8 +130,12 @@ prompt_pure_precmd() { # check for git arrows prompt_pure_git_arrows=$(prompt_pure_check_git_arrows) + # tell the terminal we are setting the title + print -Pn "\e]0;" + # show hostname if connected through ssh + [[ "$SSH_CONNECTION" != '' ]] && print -Pn "(%m) " # shows the full path in the title - print -Pn '\e]0;%~\a' + print -Pn "%~\a" # get vcs info vcs_info