From 72c99d53541e63563c17154a4b982755c72e8eb1 Mon Sep 17 00:00:00 2001 From: Mike Beattie Date: Sun, 27 May 2018 19:57:30 +1200 Subject: ZSH: make more variables local to zshrc Signed-off-by: Mike Beattie --- .zshrc | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/.zshrc b/.zshrc index 0643860..e99308e 100644 --- a/.zshrc +++ b/.zshrc @@ -1,7 +1,7 @@ ########################################################## # Prompt -setprompt () { +function () { setopt prompt_subst @@ -18,6 +18,7 @@ setprompt () { local nocolor="%{$terminfo[sgr0]%}" # Base prompt. + local pr_baseprompt pr_baseprompt="%(!.${red}%U%n%u.${green}%n)" # Username.. red underlining if uid 0 (root) pr_baseprompt+="${magenta}@${green}%m" # "@" pr_baseprompt+="${yellow}:${green}%30<...<%~%<<%" # truncated path @@ -25,8 +26,8 @@ setprompt () { pr_baseprompt+="${yellow}>${nocolor} " # Finally, add a yellow "> " # Info for title bar/screen title - pr_titleinfo='%(!.[ROOT] | .)%l) %n@%m:%30<...<%~%<<' - pr_windowtitle='' + local pr_titleinfo='%(!.[ROOT] | .)%l) %n@%m:%30<...<%~%<<' + local pr_windowtitle='' pr_wt_in='' pr_wt_out='' case ${TERM} in @@ -62,7 +63,6 @@ setprompt () { } -setprompt ########################################################## # Misc @@ -108,9 +108,11 @@ LOGCHECK=120 # check every 2 min for login/logout activity autoload -U compinit compinit if [ -e ~/.ssh/known_hosts ]; then - # Use .ssh/known_hosts for hostnames. - hosts=(${${(f)"$(<~/.ssh/known_hosts)"//,/ }%%\ *}) - zstyle ':completion:*:hosts' hosts $hosts + # Use .ssh/known_hosts for hostnames. + function () { + local hosts=(${${(f)"$(<~/.ssh/known_hosts)"//,/ }%%\ *}) + zstyle ':completion:*:hosts' hosts $hosts + } fi ########################################################## -- cgit v1.2.3