mirror of
git://git.code.sf.net/p/zsh/code
synced 2025-09-29 06:51:03 +02:00
new mtools completion
This commit is contained in:
parent
bee1fa9e0d
commit
5aefa35c49
3 changed files with 160 additions and 1 deletions
|
@ -1,5 +1,8 @@
|
|||
2001-12-11 Oliver Kiddle <opk@zsh.org>
|
||||
|
||||
* 16322: Completion/Unix/Command/_mtools,
|
||||
Completion/Unix/Command/.distfiles: new mtools completion
|
||||
|
||||
* 16320: Completion/Unix/Type/_file_systems,
|
||||
Completion/Unix/Type/.distfiles, Completion/Unix/Command/_find,
|
||||
Completion/Unix/Command/_mount: factor out file system completion
|
||||
|
|
|
@ -15,5 +15,5 @@ _dd _gprof _lynx _perldoc _telnet _pine
|
|||
_dict _grep _lzop _prcs _tiff _elm
|
||||
_diff _gs _make _psutils _tin _apm _mail
|
||||
_last _loadkeys _modutils _ruby _sysctl _links _samba
|
||||
_user_admin _rsync _arping _spamassassin
|
||||
_user_admin _rsync _arping _spamassassin _mtools
|
||||
'
|
||||
|
|
156
Completion/Unix/Command/_mtools
Executable file
156
Completion/Unix/Command/_mtools
Executable file
|
@ -0,0 +1,156 @@
|
|||
#compdef mattrib mcopy mdel mdu mcd mdeltree mdir mformat mlabel mmd mmount mmove mrd mread mren mtoolstest mtype
|
||||
|
||||
(( $+functions[_mtools_drives] )) ||
|
||||
_mtools_drives() {
|
||||
local expl
|
||||
|
||||
_wanted drives expl drive compadd "$@" -M "m:{a-z}={A-Z}" \
|
||||
${${(M)${(f)"$(mtoolstest)"}:#drive*}##drive }
|
||||
}
|
||||
|
||||
(( $+functions[_mtools_dosfiles] )) ||
|
||||
_mtools_dosfiles() {
|
||||
local expl files dirs disp dirsonly suf='/' ret=1
|
||||
|
||||
zparseopts -D -E '/=dirsonly'
|
||||
if compset -P '[A-Za-z]:'; then
|
||||
_tags files
|
||||
else
|
||||
_tags files drives
|
||||
fi
|
||||
compset -P '*/'
|
||||
if compset -S '/*'; then
|
||||
suf=''
|
||||
dirsonly=(1)
|
||||
fi
|
||||
|
||||
while _tags; do
|
||||
_requested drives expl drive _mtools_drives -S '' && ret=0
|
||||
if _requested files; then
|
||||
files=( ${(f)"$(mdir -aX $IPREFIX 2>/dev/null)"} )
|
||||
dirs=( ${${${(M)files:#*/}%/}##*/} )
|
||||
disp=( $dirs/ )
|
||||
while _next_label files expl 'file'; do
|
||||
(( ! $#dirsonly )) && compadd "$@" "$expl[@]" -M 'm:{a-zA-Z}={A-Za-z}' \
|
||||
${files##*/} && ret=0
|
||||
compadd "$@" "$expl[@]" -M 'm:{a-zA-Z}={A-Za-z}' -S "$suf" -q \
|
||||
-d disp -a dirs && ret=0
|
||||
done
|
||||
fi
|
||||
(( ret )) || return 0
|
||||
done
|
||||
|
||||
return ret
|
||||
}
|
||||
|
||||
(( $+functions[_mtools_files] )) ||
|
||||
_mtools_files() {
|
||||
local dos
|
||||
|
||||
if [[ -prefix [a-zA-Z]: ]]; then
|
||||
dos='files:file:_mtools_dosfiles'
|
||||
else
|
||||
dos='drives:drive:_mtools_drives -S ""'
|
||||
fi
|
||||
_alternative $dos 'files:file:_files'
|
||||
}
|
||||
|
||||
_mtools() {
|
||||
local args Dopt oopt sopt topt vopt
|
||||
|
||||
Dopt='(-V)-D[specify name clash handling]:clash option:
|
||||
_values "name clash handling"
|
||||
"o[overwrite primary names]"
|
||||
"O[overwrite secondary names]"
|
||||
"r[rename primary name]"
|
||||
"R[rename secondary name]"
|
||||
"a[autorename primary name]"
|
||||
"A[autorename secondary name]"
|
||||
"s[skip primary name]"
|
||||
"S[skip secondary name]"
|
||||
"m[ask user what to do with primary name]"
|
||||
"M[ask user what to do with secondary name]"'
|
||||
oopt='(-V)-o[no confirmation on overwrite of DOS files]'
|
||||
sopt=( '(-V -s -/)'-{s,/}'[recurse subdirectories]' )
|
||||
topt='(-V)-t[perform text file translation]'
|
||||
vopt='(-V)-v[verbose]'
|
||||
|
||||
case $service in
|
||||
mattrib)
|
||||
args=( $mdfiles
|
||||
'(-V)-+a[archive]'
|
||||
'(-V)-+h[hidden]'
|
||||
'(-V)-+r[readonly]'
|
||||
'(-V)-+s[system]'
|
||||
'(-V)-/[recurse subdirectories]'
|
||||
'(-V)-X[concise output]'
|
||||
'(-V)-p[replay mode]'
|
||||
'(-V)*:file:_mtools_dosfiles'
|
||||
)
|
||||
;;
|
||||
mcopy|mread)
|
||||
args=( $Dopt $oopt $sopt $topt $vopt
|
||||
'(-V)-b[batch mode]'
|
||||
'(-V)-p[preserve file attributes]'
|
||||
'(-V)-Q[quit on failure]'
|
||||
'(-V)-a[text mode transfer]'
|
||||
'(-V)-n[no confirmation on overwrite of Unix files]'
|
||||
'(-V)-m[preserve modification time]'
|
||||
'(-V)*:source file:_mtools_files'
|
||||
)
|
||||
;;
|
||||
mdeltree|mrd)
|
||||
args=( $vopt '(-V)*:directory:_mtools_dosfiles -/' )
|
||||
;;
|
||||
mdel)
|
||||
args=( $vopt '(-V)*:file:_mtools_dosfiles' )
|
||||
;;
|
||||
mdir)
|
||||
args=( $Dopt $sopt
|
||||
'(-V)-w[wide output]'
|
||||
'(-V)-a[also list hidden files]'
|
||||
'(-V)-f[fast - do not find free space]'
|
||||
'(-V -b -X)'-{b,X}'[concise output]'
|
||||
'(-V)*:file:_mtools_dosfiles'
|
||||
)
|
||||
;;
|
||||
mdu)
|
||||
args=(
|
||||
'(-V)-a[output for all files]'
|
||||
'(-V)-s[summarize - output only for each argument]'
|
||||
'(-V)*:file:_mtools_dosfiles'
|
||||
)
|
||||
;;
|
||||
mlabel)
|
||||
args=(
|
||||
'(-V -s)-c[clear existing label]'
|
||||
'(-V -c)-s[show existing label]'
|
||||
'(-V -N)-n[assign new random serial number]'
|
||||
'(-V -n)-N[specify new serial number]:serial number'
|
||||
'1:drive:_mtools_drives -S ""'
|
||||
)
|
||||
;;
|
||||
mmd)
|
||||
args=( $Dopt '(-V)*:directory:_mtools_dosfiles -/' )
|
||||
;;
|
||||
mmove|mren)
|
||||
# target file should be completed relative to source here
|
||||
args=( $Dopt $oopt $vopt '(-V)*:file:_mtools_dosfiles' )
|
||||
;;
|
||||
mtype)
|
||||
args=( $topt
|
||||
'(-V)-s[strip the high bit]'
|
||||
'(-V)*:file:_mtools_files'
|
||||
)
|
||||
;;
|
||||
mbadblocks|mmount|mformat|mtoolstest|mdrive)
|
||||
args=( '(-V)1:drive:_mtools_drives' )
|
||||
;;
|
||||
mcd) args=( '(-V)*:directory:_mtools_dosfiles -/' ) ;;
|
||||
esac
|
||||
|
||||
_arguments -s -S "$args[@]" \
|
||||
'(-D -o -s -t -v -w -a -h -r -s -/ -X -p -f -b * 1)-V[display version information]'
|
||||
}
|
||||
|
||||
_mtools "$@"
|
Loading…
Reference in a new issue