zsh: detect remote cleanup
This commit is contained in:
parent
6061b04da4
commit
8a918a132e
|
@ -3,16 +3,13 @@
|
||||||
# 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
|
# names of daemon processes a remote shell might be a child process of
|
||||||
declare -a remote_daemons
|
|
||||||
remote_daemons=(
|
remote_daemons=(
|
||||||
sshd
|
sshd
|
||||||
tailscaled
|
tailscaled
|
||||||
)
|
)
|
||||||
|
|
||||||
declare -a is_remote
|
|
||||||
is_remote=()
|
is_remote=()
|
||||||
|
parent_procs="$(pstree -s $$)"
|
||||||
|
for d in $remote_daemons[@]; [[ "$parent_procs" =~ "$d" ]] && is_remote+="$d"
|
||||||
|
|
||||||
proctree="$(pstree -s $$)"
|
[ $#is_remote -gt 0 ] && export IS_REMOTE_SESSION="$is_remote[@]"
|
||||||
for d in $remote_daemons[@]; [[ "$proctree" =~ "$d" ]] && is_remote+="$d"
|
|
||||||
|
|
||||||
[ -n "$is_remote" ] && export IS_REMOTE_SESSION="$is_remote[@]"
|
|
||||||
|
|
Loading…
Reference in a new issue