From 5b29fedad850299950195a1878fe4923778f9dcc Mon Sep 17 00:00:00 2001 From: Peter Stephenson Date: Mon, 21 Jul 2008 19:15:22 +0000 Subject: 25324: Danek Duvall: some Solaris and more general completions --- Completion/Unix/Type/.distfiles | 2 ++ Completion/Unix/Type/_zfs_dataset | 22 ++++++++++++++++++++++ Completion/Unix/Type/_zfs_pool | 3 +++ 3 files changed, 27 insertions(+) create mode 100644 Completion/Unix/Type/_zfs_dataset create mode 100644 Completion/Unix/Type/_zfs_pool (limited to 'Completion/Unix/Type') diff --git a/Completion/Unix/Type/.distfiles b/Completion/Unix/Type/.distfiles index 4801f84c1..ecf086777 100644 --- a/Completion/Unix/Type/.distfiles +++ b/Completion/Unix/Type/.distfiles @@ -48,4 +48,6 @@ _urls _user_at_host _users _users_on +_zfs_dataset +_zfs_pool ' diff --git a/Completion/Unix/Type/_zfs_dataset b/Completion/Unix/Type/_zfs_dataset new file mode 100644 index 000000000..1840fb413 --- /dev/null +++ b/Completion/Unix/Type/_zfs_dataset @@ -0,0 +1,22 @@ +#autoload + +local -a type typearg list + +zparseopts -D -E -a type t+: + +[[ -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} ) + +datasetlist=( ${="$(zfs list -H -o name $typearg)":#no datasets available} ) + +expl_type=${typearg[2,-1]//,/\/} +if [[ -n $type[(r)mtpt] ]]; then + mlist=( ${="$(zfs list -H -o mountpoint $typearg)":#no mountpoints available} ) + datasetlist=( $datasetlist $mlist ) + expl_type="$expl_type/mountpoint" +fi + +# compadd "$@" - $list +_wanted dataset expl "$expl_type" _multi_parts "$@" / datasetlist diff --git a/Completion/Unix/Type/_zfs_pool b/Completion/Unix/Type/_zfs_pool new file mode 100644 index 000000000..7db865c7b --- /dev/null +++ b/Completion/Unix/Type/_zfs_pool @@ -0,0 +1,3 @@ +#autoload + +compadd "$@" - $(zpool list -H -o name) -- cgit 1.4.1