Avoid calling who is either of SSH_TTY or SSH2_TTY are defined

This commit is contained in:
Kovid Goyal
2022-03-04 21:40:24 +05:30
parent 0c79561977
commit e469b46ce5
2 changed files with 14 additions and 4 deletions

View File

@@ -155,7 +155,11 @@ _ksi_main() {
fi
if [[ "${_ksi_prompt[title]}" == "y" ]]; then
[[ "$(builtin command who -m 2> /dev/null)" =~ "\([a-fA-F.:0-9]+\)$" ]] && _ksi_prompt[hostname_prefix]="\h: "
if [[ -n "$SSH_TTY$SSH2_TTY" ]]; then
_ksi_prompt[hostname_prefix]="\h: ";
elif [[ -n "$(builtin command -v who)" ]]; then
[[ "$(builtin command who -m 2> /dev/null)" =~ "\([a-fA-F.:0-9]+\)$" ]] && _ksi_prompt[hostname_prefix]="\h: ";
fi
# see https://www.gnu.org/software/bash/manual/html_node/Controlling-the-Prompt.html#Controlling-the-Prompt
# we use suffix here because some distros add title setting to their bashrc files by default
_ksi_prompt[ps1_suffix]+="\[\e]2;${_ksi_prompt[hostname_prefix]}\w\a\]"