Avoid calling who is either of SSH_TTY or SSH2_TTY are defined
This commit is contained in:
parent
0c79561977
commit
e469b46ce5
@ -155,7 +155,11 @@ _ksi_main() {
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ "${_ksi_prompt[title]}" == "y" ]]; then
|
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
|
# 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
|
# 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\]"
|
_ksi_prompt[ps1_suffix]+="\[\e]2;${_ksi_prompt[hostname_prefix]}\w\a\]"
|
||||||
|
|||||||
@ -90,11 +90,11 @@ _ksi_deferred_init() {
|
|||||||
unset KITTY_SHELL_INTEGRATION
|
unset KITTY_SHELL_INTEGRATION
|
||||||
|
|
||||||
# The directory where kitty-integration is located: /.../shell-integration/zsh.
|
# The directory where kitty-integration is located: /.../shell-integration/zsh.
|
||||||
builtin local self_dir=${functions_source[_ksi_deferred_init]:A:h}
|
builtin local self_dir="${functions_source[_ksi_deferred_init]:A:h}"
|
||||||
# The directory with _kitty. We store it in a directory of its own rather than
|
# The directory with _kitty. We store it in a directory of its own rather than
|
||||||
# in $self_dir because we are adding it to fpath and we don't want any other
|
# in $self_dir because we are adding it to fpath and we don't want any other
|
||||||
# files to be accidentally autoloadable.
|
# files to be accidentally autoloadable.
|
||||||
builtin local comp_dir=$self_dir/completions
|
builtin local comp_dir="$self_dir/completions"
|
||||||
|
|
||||||
# Enable completions for `kitty` command.
|
# Enable completions for `kitty` command.
|
||||||
if (( ! opt[(Ie)no-complete] )) && [[ -r $comp_dir/_kitty ]]; then
|
if (( ! opt[(Ie)no-complete] )) && [[ -r $comp_dir/_kitty ]]; then
|
||||||
@ -232,8 +232,14 @@ _ksi_deferred_init() {
|
|||||||
# We use (V) in preexec to convert control characters to something visible
|
# We use (V) in preexec to convert control characters to something visible
|
||||||
# (LF becomes \n, etc.). This isn't necessary in precmd because (%) does it
|
# (LF becomes \n, etc.). This isn't necessary in precmd because (%) does it
|
||||||
# for us.
|
# for us.
|
||||||
|
builtin local is_ssh_session="n"
|
||||||
|
if [[ -n "$SSH_TTY$SSH2_TTY" ]]; then
|
||||||
|
is_ssh_session="y";
|
||||||
|
elif [[ -n "$(builtin command -v who)" ]]; then
|
||||||
|
[[ "$(builtin command who -m 2> /dev/null)" =~ "\([a-fA-F.:0-9]+\)$" ]] && is_ssh_session="y";
|
||||||
|
fi
|
||||||
|
|
||||||
if [[ "$(builtin command who -m 2> /dev/null)" =~ "\([a-fA-F.:0-9]+\)$" ]]; then
|
if [[ "$is_ssh_session" == "y" ]]; then
|
||||||
# show the hostname via %m for SSH sessions
|
# show the hostname via %m for SSH sessions
|
||||||
functions[_ksi_precmd]+="
|
functions[_ksi_precmd]+="
|
||||||
builtin print -Prnu $_ksi_fd \$'\\e]2;'\"%m: \${(%):-%(4~|…/%3~|%~)}\"\$'\\a'"
|
builtin print -Prnu $_ksi_fd \$'\\e]2;'\"%m: \${(%):-%(4~|…/%3~|%~)}\"\$'\\a'"
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user