zsh: okay, actually, *properly* generalize this
This commit is contained in:
parent
87d00becf7
commit
463eeaa41a
|
@ -2,11 +2,20 @@
|
||||||
# processes of this shell and checking for things like sshd/tailscaled. Runs
|
# processes of this shell and checking for things like sshd/tailscaled. Runs
|
||||||
# first because multiple other things rely on this.
|
# 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
|
declare -a is_remote
|
||||||
is_remote=()
|
is_remote=()
|
||||||
|
|
||||||
proctree="$(pstree -s $$)"
|
proctree="$(pstree -s $$)"
|
||||||
[[ "$proctree" =~ sshd ]] && is_remote+=sshd
|
for d in $remote_daemons[@]; do
|
||||||
[[ "$proctree" =~ tailscaled ]] && is_remote+=tailscaled
|
[[ "$proctree" =~ $d ]] && is_remote+="$d"
|
||||||
|
done
|
||||||
|
|
||||||
[ -n "$is_remote" ] && export IS_REMOTE_SESSION="$is_remote[@]"
|
[ -n "$is_remote" ] && export IS_REMOTE_SESSION="$is_remote[@]"
|
||||||
|
echo is remote: $IS_REMOTE_SESSION
|
||||||
|
|
Loading…
Reference in a new issue