mirror of
git://git.code.sf.net/p/zsh/code
synced 2025-09-02 10:01:11 +02:00
41481: _df: Complete mounted device and mount points.
This splits umount's "udevordir" completion from _mount to a new file, without changing it.
This commit is contained in:
parent
e2124c4719
commit
5654b905f9
4 changed files with 52 additions and 45 deletions
|
@ -1,5 +1,9 @@
|
|||
2017-08-08 Daniel Shahaf <d.s@daniel.shahaf.name>
|
||||
|
||||
* 41481: Completion/Unix/Command/_df,
|
||||
Completion/Unix/Command/_mount, Completion/Unix/Type/_umountable:
|
||||
_df: Complete mounted device and mount points.
|
||||
|
||||
* 41486: Completion/Unix/Command/_tmux: Correct completions of
|
||||
new-window, split-window, respawn-window, respawn-pane.
|
||||
|
||||
|
|
|
@ -16,7 +16,7 @@ if _pick_variant gnu=GNU unix --version; then
|
|||
'-v[(ignored)]'
|
||||
'(- : *)--help[display help and exit]'
|
||||
'(- : *)--version[output version information and exit]'
|
||||
'*:files:_files'
|
||||
'*:files:_umountable'
|
||||
- '(format)'
|
||||
{-B+,--block-size=}'[specify block size]:size (bytes)'
|
||||
'-k[like --block-size=1K]'
|
||||
|
@ -39,7 +39,7 @@ elif [[ "$OSTYPE" == (darwin|freebsd|dragonfly)* ]]; then
|
|||
'-i[include inode usage statistics (default)]'
|
||||
'-l[only display locally-mounted file systems]'
|
||||
'-n[use previously obtained statistics]'
|
||||
'*:files:_files'
|
||||
'*:files:_umountable'
|
||||
)
|
||||
spec='[only display file systems of specified types]:file system type:->fslist'
|
||||
case "$OSTYPE" in
|
||||
|
@ -59,7 +59,7 @@ else
|
|||
'-k[use 1024-byte blocks]'
|
||||
'-P[POSIX compliant output]'
|
||||
'-t[include total allocated-space figures in the output]'
|
||||
'*:files:_files'
|
||||
'*:files:_umountable'
|
||||
)
|
||||
fi
|
||||
|
||||
|
|
|
@ -931,48 +931,7 @@ devordir)
|
|||
esac
|
||||
;;
|
||||
udevordir)
|
||||
local dev_tmp dpath_tmp mp_tmp mline
|
||||
|
||||
case "$OSTYPE" in
|
||||
linux*|irix*)
|
||||
tmp=( "${(@f)$(< /etc/mtab)}" )
|
||||
dev_tmp=( "${(@)${(@)tmp%% *}:#none}" )
|
||||
mp_tmp=( "${(@)${(@)tmp#* }%% *}" )
|
||||
;;
|
||||
freebsd*|dragonfly*)
|
||||
/sbin/mount | while read mline; do
|
||||
dev_tmp+=( $mline[(w)1] )
|
||||
mp_tmp+=( $mline[(w)3] )
|
||||
done
|
||||
;;
|
||||
darwin*)
|
||||
tmp=( "${(@f)$(/sbin/mount)}" )
|
||||
dev_tmp=( "${(@)${(@)tmp%% *}:#map}" )
|
||||
mp_tmp=( "${(@)${(@)tmp#* on }%% \(*}" )
|
||||
;;
|
||||
*)
|
||||
/sbin/mount | while read mline; do
|
||||
mp_tmp+=( $mline[(w)1] )
|
||||
dev_tmp+=( $mline[(w)3] )
|
||||
done
|
||||
;;
|
||||
esac
|
||||
|
||||
local MATCH MBEGIN MEND
|
||||
# The complicated substitution for mount point names is required because
|
||||
# characters in /etc/mtab that might confuse programs reading the names
|
||||
# are encoded as exactly 3 octal digits, like for example \040 for space.
|
||||
# The cleaner-looking ${(g::)mp_tmp} might consume too many digits.
|
||||
# Both mp_tmp and dev_tmp are derived from /etc/mtab or "mount" output.
|
||||
mp_tmp=("${(@)mp_tmp//(#m)\\[0-7](#c3)/${(#)$(( 8#${MATCH[2,-1]} ))}}")
|
||||
dev_tmp=("${(@)dev_tmp//(#m)\\[0-7](#c3)/${(#)$(( 8#${MATCH[2,-1]} ))}}")
|
||||
dpath_tmp=( "${(@M)dev_tmp:#/*}" )
|
||||
dev_tmp=( "${(@)dev_tmp:#/*}" )
|
||||
|
||||
_alternative \
|
||||
'device-labels:device label:compadd -a dev_tmp' \
|
||||
'device-paths: device path:_canonical_paths -A dpath_tmp -N -M "r:|/=* r:|=*" device-paths device\ path' \
|
||||
'directories:mount point:_canonical_paths -A mp_tmp -N -M "r:|/=* r:|=*" directories mount\ point' && ret=0
|
||||
_umountable
|
||||
;;
|
||||
labels)
|
||||
_wanted labels expl 'disk label' compadd /dev/disk/by-label/*(:t) && ret=0
|
||||
|
|
44
Completion/Unix/Type/_umountable
Normal file
44
Completion/Unix/Type/_umountable
Normal file
|
@ -0,0 +1,44 @@
|
|||
#autoload
|
||||
local tmp
|
||||
local dev_tmp dpath_tmp mp_tmp mline
|
||||
|
||||
case "$OSTYPE" in
|
||||
linux*|irix*)
|
||||
tmp=( "${(@f)$(< /etc/mtab)}" )
|
||||
dev_tmp=( "${(@)${(@)tmp%% *}:#none}" )
|
||||
mp_tmp=( "${(@)${(@)tmp#* }%% *}" )
|
||||
;;
|
||||
freebsd*|dragonfly*)
|
||||
/sbin/mount | while read mline; do
|
||||
dev_tmp+=( $mline[(w)1] )
|
||||
mp_tmp+=( $mline[(w)3] )
|
||||
done
|
||||
;;
|
||||
darwin*)
|
||||
tmp=( "${(@f)$(/sbin/mount)}" )
|
||||
dev_tmp=( "${(@)${(@)tmp%% *}:#map}" )
|
||||
mp_tmp=( "${(@)${(@)tmp#* on }%% \(*}" )
|
||||
;;
|
||||
*)
|
||||
/sbin/mount | while read mline; do
|
||||
mp_tmp+=( $mline[(w)1] )
|
||||
dev_tmp+=( $mline[(w)3] )
|
||||
done
|
||||
;;
|
||||
esac
|
||||
|
||||
local MATCH MBEGIN MEND
|
||||
# The complicated substitution for mount point names is required because
|
||||
# characters in /etc/mtab that might confuse programs reading the names
|
||||
# are encoded as exactly 3 octal digits, like for example \040 for space.
|
||||
# The cleaner-looking ${(g::)mp_tmp} might consume too many digits.
|
||||
# Both mp_tmp and dev_tmp are derived from /etc/mtab or "mount" output.
|
||||
mp_tmp=("${(@)mp_tmp//(#m)\\[0-7](#c3)/${(#)$(( 8#${MATCH[2,-1]} ))}}")
|
||||
dev_tmp=("${(@)dev_tmp//(#m)\\[0-7](#c3)/${(#)$(( 8#${MATCH[2,-1]} ))}}")
|
||||
dpath_tmp=( "${(@M)dev_tmp:#/*}" )
|
||||
dev_tmp=( "${(@)dev_tmp:#/*}" )
|
||||
|
||||
_alternative \
|
||||
'device-labels:device label:compadd -a dev_tmp' \
|
||||
'device-paths: device path:_canonical_paths -A dpath_tmp -N -M "r:|/=* r:|=*" device-paths device\ path' \
|
||||
'directories:mount point:_canonical_paths -A mp_tmp -N -M "r:|/=* r:|=*" directories mount\ point' && ret=0
|
Loading…
Reference in a new issue