about summary refs log tree commit diff
path: root/Completion/Unix/Type/_zfs_dataset
diff options
context:
space:
mode:
Diffstat (limited to 'Completion/Unix/Type/_zfs_dataset')
-rw-r--r--Completion/Unix/Type/_zfs_dataset20
1 files changed, 15 insertions, 5 deletions
diff --git a/Completion/Unix/Type/_zfs_dataset b/Completion/Unix/Type/_zfs_dataset
index 1840fb413..1cd49aebf 100644
--- a/Completion/Unix/Type/_zfs_dataset
+++ b/Completion/Unix/Type/_zfs_dataset
@@ -1,13 +1,24 @@
 #autoload
 
-local -a type typearg list
+local -a type paths_allowed typearg datasetlist expl
+local expl_type
 
-zparseopts -D -E -a type t+:
+zparseopts -D -E t+:=type p=paths_allowed
 
 [[ -n $type[(r)fs] ]]   && typearg=( filesystem )
 [[ -n $type[(r)vol] ]]  && typearg=( $typearg volume )
 [[ -n $type[(r)snap] ]] && typearg=( $typearg snapshot )
-[[ -n $typearg ]] && typearg=( -t ${(j:,:)typearg} )
+if [[ -n $typearg ]]; then
+	typearg=( -t ${(j:,:)typearg} )
+# We know we're in zfs list if paths_allowed is non-empty.
+elif [[ -n $opt_args[-t] && ${#paths_allowed} -gt 0 ]]; then
+	typearg=( -t $opt_args[-t] )
+fi
+
+if [[ ${#paths_allowed} -gt 0 && $PREFIX == /* ]]; then
+	_path_files
+	return
+fi
 
 datasetlist=( ${="$(zfs list -H -o name $typearg)":#no datasets available} )
 
@@ -18,5 +29,4 @@ if [[ -n $type[(r)mtpt] ]]; then
 	expl_type="$expl_type/mountpoint"
 fi
 
-# compadd "$@" - $list
-_wanted dataset expl "$expl_type" _multi_parts "$@" / datasetlist
+_wanted dataset expl "$expl_type" _multi_parts "$@" -q / datasetlist