zsh-workers
 help / color / mirror / code / Atom feed
* PATCH: better Freebsd support in _external_pwds
@ 2016-09-12 22:07 Oliver Kiddle
  0 siblings, 0 replies; only message in thread
From: Oliver Kiddle @ 2016-09-12 22:07 UTC (permalink / raw)
  To: Zsh workers

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


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2016-09-12 22:14 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-09-12 22:07 PATCH: better Freebsd support in _external_pwds Oliver Kiddle

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).