From 5f3d90e411d63d6381148c88a21897bb9a2205d1 Mon Sep 17 00:00:00 2001 From: pagedown Date: Mon, 7 Mar 2022 12:39:49 +0800 Subject: [PATCH] ... --- shell-integration/bash/kitty.bash | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/shell-integration/bash/kitty.bash b/shell-integration/bash/kitty.bash index 4e4deb2a8..b50e48c25 100644 --- a/shell-integration/bash/kitty.bash +++ b/shell-integration/bash/kitty.bash @@ -155,17 +155,19 @@ _ksi_main() { fi if [[ "${_ksi_prompt[title]}" == "y" ]]; then - if [[ -n "$KITTY_PID" ]]; then - # kitty running locally - elif [[ -n "$SSH_TTY" || -n "$SSH2_TTY$KITTY_WINDOW_ID" ]]; then - # connected to most SSH servers - # or use ssh kitten to connected to some SSH servers that do not set SSH_TTY - _ksi_prompt[hostname_prefix]="\h: "; - elif [[ -n "$(builtin command -v who)" ]]; then - # the shell integration script is installed manually on the remote system - # the environment variables are cleared after sudo - # OpenSSH's sshd creates entries in utmp for every login so use those - [[ "$(builtin command who -m 2> /dev/null)" =~ "\([a-fA-F.:0-9]+\)$" ]] && _ksi_prompt[hostname_prefix]="\h: "; + if [[ -z "$KITTY_PID" ]]; then + if [[ -n "$SSH_TTY" || -n "$SSH2_TTY$KITTY_WINDOW_ID" ]]; then + # connected to most SSH servers + # or use ssh kitten to connected to some SSH servers that do not set SSH_TTY + _ksi_prompt[hostname_prefix]="\h: "; + else + if [[ -n "$(builtin command -v who)" && "$(builtin command who -m 2> /dev/null)" =~ "\([a-fA-F.:0-9]+\)$" ]]; then + # the shell integration script is installed manually on the remote system + # the environment variables are cleared after sudo + # OpenSSH's sshd creates entries in utmp for every login so use those + _ksi_prompt[hostname_prefix]="\h: "; + fi + fi 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