zsh: okay, actually, *properly* generalize this

This commit is contained in:
Erin 2023-07-19 23:24:02 -04:00
parent 87d00becf7
commit 463eeaa41a

View file

@ -2,11 +2,20 @@
# processes of this shell and checking for things like sshd/tailscaled. Runs
# first because multiple other things rely on this.
# names of daemon processes a remote shell might be a child process of
declare -a remote_daemons
remote_daemons=(
sshd
tailscaled
)
declare -a is_remote
is_remote=()
proctree="$(pstree -s $$)"
[[ "$proctree" =~ sshd ]] && is_remote+=sshd
[[ "$proctree" =~ tailscaled ]] && is_remote+=tailscaled
for d in $remote_daemons[@]; do
[[ "$proctree" =~ $d ]] && is_remote+="$d"
done
[ -n "$is_remote" ] && export IS_REMOTE_SESSION="$is_remote[@]"
echo is remote: $IS_REMOTE_SESSION