Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
PATCH: better Freebsd support in _external_pwds
- X-seq: zsh-workers 39299
- From: Oliver Kiddle <okiddle@xxxxxxxxxxx>
- To: Zsh workers <zsh-workers@xxxxxxx>
- Subject: PATCH: better Freebsd support in _external_pwds
- Date: Tue, 13 Sep 2016 00:07:58 +0200
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.co.uk; s=s2048; t=1473718079; bh=A5P11bXiRJ2mhpzcYzt/HCeFnE4Jmw9VsZl0ymz2r5A=; h=From:To:Subject:Date:From:Subject; b=Rluo3ZlzLvMhcQGhKOmBfGDy8+mCEXaXlq8BFqaXvYW8O/Y9S21+M75RWE0hAaCqnWtV0DDEiFDVhCISt9F4OcYVo8mRnsX/p8LGh+6ewQiXQVWQHNqzZHKbr4d6DAprubfDJAc/dAWsXPwHmR7uZSRmc6mz6xZL7cY0aWhmDQk+zKrLmLkk+pUsOt/PjczaAujyplmLraKrDvha/38YjZTe0M3OXKby4lw8TVyKPoffsjblT88j/g7sRMtT9KxesVTpoa8sNVauok5TmfuLnZOyCvwcHP8tXWkL53Lp0n7njffwEWAPD9Z1u+01tF+5N7WN0CuBodsMqk1tqBhvOw==
- List-help: <mailto:zsh-workers-help@zsh.org>
- List-id: Zsh Workers List <zsh-workers.zsh.org>
- List-post: <mailto:zsh-workers@zsh.org>
- Mailing-list: contact zsh-workers-help@xxxxxxx; run by ezmlm
procstat provides a way to get process current directories on FreeBSD
and unlike lsof, it is available in the base system along with pgrep.
I've intentionally used two steps rather than pass pgrep output directly
to procstat because that was resulting in a subshell process being
picked up.
I also found that on Linux, it should include -zsh with zsh when finding
applicable processes.
Oliver
diff --git a/Completion/Base/Completer/_external_pwds b/Completion/Base/Completer/_external_pwds
index 79e3ba0..a9dc859 100644
--- a/Completion/Base/Completer/_external_pwds
+++ b/Completion/Base/Completer/_external_pwds
@@ -22,9 +22,13 @@ case $OSTYPE in
)
;;
linux*)
- dirs=( /proc/${^$(pidof zsh):#$$}/cwd(N:P) )
+ dirs=( /proc/${^$(pidof -- -zsh zsh):#$$}/cwd(N:P) )
dirs=( $^dirs(N^@) )
;;
+ freebsd*)
+ dirs=( $(pgrep -U $UID -x zsh) )
+ dirs=( $(procstat -h -f $dirs|awk '{if ($3 == "cwd") print $NF}') )
+ ;;
*)
if (( $+commands[lsof] )); then
dirs=( ${${${(M)${(f)"$(lsof -a -u $EUID -c zsh -p \^$$ -d cwd -F n -w
Messages sorted by:
Reverse Date,
Date,
Thread,
Author