get rid of the who -m ssh session test

I dont like executing a binary in a fast startup script. Lets see
if there are a lot of sessions in the wild that dont use the SSH_TTY
env var
This commit is contained in:
Kovid Goyal 2022-03-06 15:47:08 +05:30
parent 75d5e386d3
commit 795953a341
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
2 changed files with 5 additions and 11 deletions

View File

@ -61,17 +61,17 @@ if [ "${BASH_VERSINFO:-0}" -lt 4 ]; then
builtin return;
fi
if [[ "${_ksi_prompt[sourced]}" == "y" ]]; then
if [[ "${_ksi_prompt[sourced]}" == "y" ]]; then
# we have already run
builtin unset KITTY_SHELL_INTEGRATION
builtin return;
fi
builtin return;
fi
# this is defined outside _ksi_main to make it global without using declare -g
# which is not available on older bash
builtin declare -A _ksi_prompt
_ksi_prompt=(
[cursor]='y' [title]='y' [mark]='y' [complete]='y' [ps0]='' [ps0_suffix]='' [ps1]='' [ps1_suffix]='' [ps2]=''
_ksi_prompt=(
[cursor]='y' [title]='y' [mark]='y' [complete]='y' [ps0]='' [ps0_suffix]='' [ps1]='' [ps1_suffix]='' [ps2]=''
[hostname_prefix]='' [sourced]='y'
)
@ -157,9 +157,6 @@ _ksi_main() {
if [[ "${_ksi_prompt[title]}" == "y" ]]; then
if [[ -n "$SSH_TTY$SSH2_TTY" ]]; then
_ksi_prompt[hostname_prefix]="\h: ";
elif [[ -n "$(builtin command -v who)" ]]; then
# 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: ";
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

View File

@ -235,9 +235,6 @@ _ksi_deferred_init() {
builtin local is_ssh_session="n"
if [[ -n "$SSH_TTY$SSH2_TTY" ]]; then
is_ssh_session="y";
elif [[ -n "$(builtin command -v who)" ]]; then
# 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]+\)$" ]] && is_ssh_session="y";
fi
if [[ "$is_ssh_session" == "y" ]]; then