Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
[PATCH] completion: add chdman, fish, nano
- X-seq: zsh-workers 54501
- From: dana <dana@xxxxxxx>
- To: zsh-workers@xxxxxxx
- Subject: [PATCH] completion: add chdman, fish, nano
- Date: Thu, 07 May 2026 20:39:30 -0500
- Archived-at: <https://zsh.org/workers/54501>
- Feedback-id: i9be146f9:Fastmail
- List-id: <zsh-workers.zsh.org>
_fish wants w/54451, but it's usable without
dana
diff --git a/Completion/Unix/Command/_chdman b/Completion/Unix/Command/_chdman
new file mode 100644
index 000000000..c1fea7d42
--- /dev/null
+++ b/Completion/Unix/Command/_chdman
@@ -0,0 +1,195 @@
+#compdef chdman
+
+local ret=1 words1=$words[1]
+local -a opts args context state state_descr line expl
+local -a create_common_opts extract_common_opts ld_common_opts
+local -a meta_common_opts input_bytes_hunks_opts
+local -A opt_args
+
+opts=(
+ '(--input -i)'{--input,-i}'[specify input file]:input file:_files'
+ '(--inputparent -ip)'{--inputparent,-ip}'[specify parent file for input CHD]:input parent file:_files'
+ '(--output -o)'{--output,-o}'[specify output file]:output file:_files'
+ '(--outputbin -ob)'{--outputbin,-ob}'[specify output file for binary data]:output binary file:_files'
+ '(--splitbin -sb)'{--splitbin,-sb}'[output one binary file per track]'
+ '(--force -f)'{--force,-f}'[overwrite existing file]' # note same short option as --fix
+ '(--outputparent -op)'{--outputparent,-op}'[specify parent file for output CHD]:output parent file:_files'
+ '(--inputstartbyte -isb)'{--inputstartbyte,-isb}'[specify starting byte offset within input]: :\
+ _numbers -u bytes "start byte" k m g'
+ '(--inputstarthunk -ish)'{--inputstarthunk,-ish}'[specify starting hunk offset within input]: :\
+ _numbers -u hunks "start hunk" k m g'
+ '(--inputstartframe -isf)'{--inputstartframe,-isf}'[specify starting frame within input]: :\
+ _numbers -u frames "start frame" k m g'
+ '(--inputbytes -ib)'{--inputbytes,-ib}'[specify effective length of input in bytes]: :\
+ _numbers -u bytes "input length" k m g'
+ '(--inputhunks -ih)'{--inputhunks,-ih}'[specify effective length of input in hunks]: :\
+ _numbers -u hunks "input length" k m g'
+ '(--inputframes -if)'{--inputframes,-if}'[specify effective length of input in frames]: :\
+ _numbers -u frames "input length" k m g'
+ '(--hunksize -hs)'{--hunksize,-hs}'[specify size of each hunk in bytes]: :\
+ _numbers -u bytes -l 16 -m $((1024*1024)) "hunk size" k m g'
+ '(--unitsize -us)'{--unitsize,-us}'[specify size of each unit in bytes]: :\
+ _numbers -u bytes "unit size" k m g'
+ '(--compression -c)'{--compression,-c}'[specify compression codecs to use]: :->codecs'
+ '(--ident -id)'{--ident,-id}'[specify ident file to provide CHS information]:ident file:_files'
+ '(--chs -chs)'{--chs,-chs}'[specify CHS information directly]:cylinders,heads,sectors:'
+ '(--sectorsize -ss)'{--sectorsize,-ss}'[specfiy size of each hard disk sector]: :\
+ _numbers -u bytes "sector size" k m g'
+ '(--tag -t)'{--tag,-t}'[specify metadata tag]:4-character metadata tag:'
+ '(--index -ix)'{--index,-ix}'[specify indexed instance of metadata tag]:index:'
+ '(--valuetext -vt)'{--valuetext,-vt}'[specify metadata value as text]:metadata value:'
+ '(--valuefile -vf)'{--valuefile,-vf}'[specify file containing metadata value]:metadata value file:_files'
+ '(--numprocessors -np)'{--numprocessors,-np}'[specify max number of processors to use during compression]: :\
+ _numbers -u processors -l1 "processor limit"'
+ '(--nochecksum -nocs)'{--nochecksum,-nocs}'[excluded added metadata from SHA-1]'
+ '(--fix -f)'{--fix,-f}'[fix SHA-1 if incorrect]' # note same short option as --force
+ '(--verbose -v)'{--verbose,-v}'[output additional information]'
+ '(--size -s)'{--size,-s}'[specify size of output file]: :\
+ _numbers -u bytes "output file size" k m g'
+ '(--template -tp)'{--template,-tp}'[specify hard disk template]: :->templates'
+)
+create_common_opts=(
+ ${(M)opts:#(|*\))--(output|outputparent|force|input|hunksize|compression|numprocessors)\[*}
+ ${(M)opts:#(|*\))-(o|op|f|i|hs|c|np)\[*~*-f*fix*}
+)
+extract_common_opts=(
+ ${(M)opts:#(|*\))--(output|force|input|inputparent)\[*}
+ ${(M)opts:#(|*\))-(o|f|i|ip)\[*~*-f*fix*}
+)
+ld_common_opts=(
+ ${(M)opts:#(|*\))--(inputstartframe|inputframes)\[*}
+ ${(M)opts:#(|*\))-(isf|if)\[*}
+)
+meta_common_opts=(
+ ${(M)opts:#(|*\))--(input|tag|index)\[*}
+ ${(M)opts:#(|*\))-(i|t|ix)\[*}
+)
+input_bytes_hunks_opts=(
+ ${(M)opts:#(|*\))--(inputstartbyte|inputstarthunk|inputbytes|inputhunks)\[*}
+ ${(M)opts:#(|*\))-(isb|ish|ib|ih)\[*}
+)
+
+if (( CURRENT < 3 )); then
+ args=( ': :->commands' )
+else
+ case $words[2] in
+ help) args=( ': :->commands' ) ;;
+ info) args=(
+ ${(M)opts:#(|*\))--(input|verbose)\[*}
+ ${(M)opts:#(|*\))-(i|v)\[*}
+ ) ;;
+ verify) args=(
+ ${(M)opts:#(|*\))--(input|inputparent)\[*}
+ ${(M)opts:#(|*\))-(i|ip)\[*}
+ ) ;;
+ createraw|createdvd) args=(
+ $create_common_opts
+ $input_bytes_hunks_opts
+ ${(M)opts:#(|*\))--(unitsize)\[*}
+ ${(M)opts:#(|*\))-(us)\[*}
+ ) ;;
+ createhd) args=(
+ $create_common_opts
+ $input_bytes_hunks_opts
+ ${(M)opts:#(|*\))--(unitsize|chs|sectorsize|template|ident)\[*}
+ ${(M)opts:#(|*\))-(us|chs|ss|tp|id)\[*}
+ ) ;;
+ createcd) args=( $create_common_opts ) ;;
+ createld) args=( $create_common_opts $ld_common_opts ) ;;
+ extractraw|extractdvd|extracthd) args=(
+ $extract_common_opts
+ $input_bytes_hunks_opts
+ ) ;;
+ extractcd) args=(
+ $extract_common_opts
+ ${(M)opts:#(|*\))--(outputbin)\[*}
+ ${(M)opts:#(|*\))-(ob)\[*}
+ ) ;;
+ extractld) args=( $extract_common_opts $ld_common_opts ) ;;
+ copy) args=(
+ $create_common_opts
+ $input_bytes_hunks_opts
+ ${(M)opts:#(|*\))--(inputparent)\[*}
+ ${(M)opts:#(|*\))-(ip)\[*}
+ ) ;;
+ addmeta) args=(
+ $meta_common_opts
+ ${(M)opts:#(|*\))--(valuetext|valuefile|nochecksum)\[*}
+ ${(M)opts:#(|*\))-(vt|vf|nocs)\[*}
+ ) ;;
+ delmeta) args=( $meta_common_opts ) ;;
+ dumpmeta) args=(
+ $meta_common_opts
+ ${(M)opts:#(|*\))--(output|force)\[*}
+ ${(M)opts:#(|*\))-(o|f)\[*~*-f*fix*}
+ ) ;;
+ esac
+ shift words
+ (( CURRENT-- ))
+fi
+
+_arguments : $args && ret=0
+
+case $state in
+ commands)
+ _describe -t commands command '(
+ "help:display usage information"
+ "info:display CHD information"
+ "verify:verify CHD integrity"
+ "createraw:create raw CHD"
+ "createhd:create hard disk CHD"
+ "createcd:create CD CHD"
+ "createdvd:create DVD CHD"
+ "createld:create LaserDisc CHD"
+ "extractraw:extract raw file from CHD"
+ "extracthd:extract hard disk file from CHD"
+ "extractcd:extract CD file from CHD"
+ "extractdvd:extract DVD file from CHD"
+ "extractld:extract LaserDisc AVI from CHD"
+ "copy:copy data from one CHD to another"
+ "addmeta:add metadata to CHD"
+ "delmeta:remove metadata from CHD"
+ "dumpmeta:dump metadata from CHD"
+ "listtemplates:list hard disk templates"
+ )' && ret=0
+ ;;
+
+ codecs)
+ local -a codecs
+
+ case $words[1] in # was $words[2]
+ *ld) codecs=(
+ 'avhu[A/V Huffman]'
+ ) ;;
+ *cd) codecs=(
+ 'cdfl[CD FLAC]' 'cdlz[CD LZMA]' 'cdzl[CD Deflate]' 'cdzs[CD Zstandard]'
+ ) ;;
+ *) codecs=(
+ 'flac[FLAC]' 'huff[Huffman]' 'lzma[LZMA]' 'zlib[Deflate]' 'zstd[Zstandard]'
+ ) ;;
+ esac
+
+ _alternative \
+ 'codecs-none:no codec:(( none\:uncompressed ))' \
+ "codecs: :_values -s, 'compression codec' ${(j< >)${(@q+)codecs}}" \
+ && ret=0
+ ;;
+
+ templates)
+ local -a tpls tmp=( ${(f)"$(
+ _call_program templates $words1 listtemplates
+ )"} )
+ tmp=( ${(@)${(@)tmp//[[:space:]]##/ }# } )
+ tmp=( ${(@M)tmp:#<-> *} )
+
+ for 1 in $tmp; do
+ tmp=( ${(z)1} )
+ # id : mfg model (c,h,s)
+ tpls+=( "${tmp[1]}:$tmp[2] $tmp[3] (${(j<,>)${(@)tmp[4,6]}})" )
+ done
+
+ _describe -2V -t templates 'hard disk template' tpls && ret=0
+ ;;
+esac
+
+return ret
diff --git a/Completion/Unix/Command/_fish b/Completion/Unix/Command/_fish
new file mode 100644
index 000000000..08541bc83
--- /dev/null
+++ b/Completion/Unix/Command/_fish
@@ -0,0 +1,78 @@
+#compdef fish
+
+local MATCH MBEGIN MEND ret=1
+local -a args context line state state_descr
+local -A opt_args
+
+args=(
+ # unlike most shells, fish's -c is a normal option-with-optarg which can be
+ # interleaved with other options and can even be given multiple times.
+ # obviously we can't complete command strings reliably here but we'll try
+ '(1)*'{-c+,--command=}'[execute specified command string]: :_cmdstring'
+ '*'{-C+,--init-command=}'[execute specified command before other input]: :_cmdstring'
+ '(-d --debug)'{-d+,--debug=}'[enable debug output for specified categories]: :->debug'
+ '(-o --debug-output)'{-o+,--debug-output=}'[specify debug output file]:debug output file:_files'
+ '(-f --features)'{-f+,--features=}'[enable specified feature flags]: :->feature'
+ '(-i --interactive)'{-i,--interactive}'[act as interactive shell]'
+ '(-l --login)'{-l,--login}'[act as login shell]'
+ '(-N --no-config)'{-N,--no-config}'[do not read configuration files]'
+ '(-n --no-execute)'{-n,--no-execute}'[check syntax only (do not execute commands)]'
+ '(-p --profile)'{-p+,--profile=}'[specify profile output file]:profile output file:_files'
+ '--profile-startup=[specify start-up profile output file]:profile output file:_files'
+ '(-P --private)'{-P,--private}'[enable private mode (no history)]'
+ '--print-rusage-self[output getrusage() stats on exit]'
+ '(- : *)--print-debug-categories[display debug categories]'
+ '(- : *)'{-v,--version}'[display version information]'
+ '(- : *)'{-h,--help}'[display usage information]'
+ '(-)1:script file:_files'
+ '(-)*:argument:_files'
+)
+
+_arguments -s -S -A '-*' : $args && ret=0
+
+case $state in
+ debug)
+ local -a tmp=( ${(f)"$(
+ _call_program debug-categories $words[1] --print-debug-categories
+ )"} )
+ tmp=( ${${tmp/[[:space:]]##/\[}/%/\]} )
+ tmp=( ${tmp/(#m)\[[A-Z][^A-Z]/${(L)MATCH}} )
+ tmp=( ${tmp/.\]/\]} )
+ _values -s, 'debug category' $tmp && ret=0
+ ;;
+
+ feature)
+ local name def ver desc
+ local -a flags_on flags_off versions flags tmp
+
+ while IFS=$'\t ' read -r name def ver desc; do
+ desc=${${desc/#(#m)[A-Z][^A-Z]/${(L)MATCH}}//(#m)[]\\]/\\$MATCH}
+ if [[ $def == on ]]; then
+ flags_on+=( $name"[$desc ($ver, defaults on)]" )
+ else
+ flags_off+=( $name"[$desc ($ver, defaults off)]" )
+ fi
+ versions+=( $ver"[all features introduced in fish $ver]" )
+ done < <(
+ _call_program feature-flags $words[1] -NPc '"status features"'
+ )
+
+ # if an individual flag is already on, show the no- variant, and vice versa
+ flags+=( no-$^flags_on $flags_off )
+ # always show both for these 'groups'
+ flags+=( {no-,}all'[all features]' {no-,}${(u)versions} )
+
+ # only show redundant variants of individual flags when necessary
+ tmp=( no-$^flags_off )
+ [[ ${PREFIX##*,} == n* ]] || tmp=( '!'$^tmp )
+ flags+=( $tmp )
+
+ tmp=( ${(M)flags_on:#${${PREFIX##*,}[1]:----}*} )
+ (( $#tmp )) || tmp=( '!'$^flags_on )
+ flags+=( $tmp )
+
+ _values -s, 'feature flag' $flags && ret=0
+ ;;
+esac
+
+return ret
diff --git a/Completion/Unix/Command/_nano b/Completion/Unix/Command/_nano
new file mode 100644
index 000000000..e2333b9f4
--- /dev/null
+++ b/Completion/Unix/Command/_nano
@@ -0,0 +1,87 @@
+#compdef nano rnano
+
+local -a args context state state_descr line expl
+local -A opt_args
+
+args=(
+ '(-A --smarthome)'{-A,--smarthome}'[enable smart home key]'
+ '(-B --backup)'{-B,--backup}'[save backups of existing files]'
+ '(-C --backupdir)'{-C+,--backupdir=}'[save uniquely numbered backups to specified directory]:backup directory:_directories'
+ '(-D --boldtext)'{-D,--boldtext}'[use bold instead of reverse video text]'
+ '(-E --tabstospaces)'{-E,--tabstospaces}'[convert typed tabs to spaces]'
+ '(-F --multibuffer)'{-F,--multibuffer}'[read file into new buffer by default]'
+ '(-G --locking)'{-G,--locking}'[use vim-style lock files]'
+ '(-H --historylog)'{-H,--historylog}'[remember search/replace strings]'
+ '(-I --ignorercfiles)'{-I,--ignorercfiles}"[don't look at nanorc files]"
+ '(-J --guidestripe)'{-J+,--guidestripe=}'[show vertical stripe at specified column]: :_numbers -l1 "column number"'
+ '(-K --rawsequences)'{-K,--rawsequences}'[interpret escape sequences directly instead of via ncurses]'
+ '(-L --nonewlines)'{-L,--nonewlines}"[don't automatically add EOF newline]"
+ '(-M --trimblanks)'{-M,--trimblanks}'[trim trailing whitespaces when hard-wrapping]'
+ '(-N --noconvert -u --unix)'{-N,--noconvert}"[don't convert files from DOS/Mac format]"
+ '(-O --bookstyle)'{-O,--bookstyle}'[when justifying, leading whitespace means new paragraph]'
+ '(-P --positionlog)'{-P,--positionlog}'[remember cursor position]'
+ '(-Q --quotestr)'{-Q+,--quotestr=}'[specify regular expression to match quoting]:quoting regex [^([ \t]*([!#%%\:;>|}]|//))+]'
+ '(-R --restricted)'{-R,--restricted}'[restrict access to the file system]'
+ '(-S --softwrap)'{-S,--softwrap}'[soft-wrap long lines]'
+ '(-T --tabsize)'{-T+,--tabsize=}'[specify tab width]: :_numbers -u columns -l1 -d8 "tab width"'
+ '(-c --constantshow -U --quickblank)'{-U,--quickblank}'[hide status-bar messages after next keystroke]'
+ '(- : *)'{-V,--version}'[display version information]'
+ '(-W --wordbounds -X --wordchars)'{-W,--wordbounds}'[detect word boundaries more accurately]'
+ '(-W --wordbounds -X --wordchars)'{-X+,--wordchars=}'[specify word characters]:word characters'
+ '(-Y --syntax)'{-Y+,--syntax=}'[specify syntax-highlighting definition]: :->syntaxes'
+ '(-Z --zap)'{-Z,--zap}'[let Backspace/Delete erase marked region]'
+ '(-a --atblanks)'{-a,--atblanks}'[when soft wrapping, wrap at whitespace]'
+ '(-b --breaklonglines -w --nowrap)'{-b,--breaklonglines}'[automatically hard-wrap long lines]'
+ '(-c --constantshow -U --quickblank)'{-c,--constantshow}'[constantly report cursor position in status bar]'
+ '(-d --rebinddelete)'{-d,--rebinddelete}'[fix Backspace/Delete confusion problem]'
+ '(-e --emptyline)'{-e,--emptyline}'[keep line below title bar empty]'
+ '(-f --rcfile)'{-f+,--rcfile=}'[use only specified file for configuring nano]:rc file:_files'
+ '(-g --showcursor)'{-g,--showcursor}'[show cursor in file browser and help viewer]'
+ '(- : *)'{-h,--help}'[display help information]'
+ '(-i --autoindent)'{-i,--autoindent}'[automatically indent new lines]'
+ '(-j --jumpyscrolling)'{-j,--jumpyscrolling}'[scroll per half-screen, not per line]'
+ '(-k --cutfromcursor)'{-k,--cutfromcursor}"[make 'cut text' (^k) cut from cursor to end of line]"
+ '(-l --linenumbers)'{-l,--linenumbers}'[show line numbers]'
+ '(-m --mouse)'{-m,--mouse}'[enable mouse support]'
+ '(-n --noread)'{-n,--noread}'[only write to named files (do not read)]'
+ '(-o --operatingdir)'{-o+,--operatingdir=}'[specify operating directory]:operating directory:_directories'
+ '(-p --preserve -/ --modernbindings)'{-p,--preserve}'[preserve XON (^q) and XOFF (^s)]'
+ '(-q --indicator)'{-q,--indicator}'[show position indicator (scroll bar)]'
+ '(-r --fill)'{-r+,--fill=}'[specify width for hard-wrap and justify]: :_numbers -u columns -Nd-8 "wrap width"'
+ '(-s --speller)'{-s+,--speller=}'[specify spell-checking program]:spell-checking program/command:_cmdstring'
+ '(-t --saveonexit)'{-t,--saveonexit}'[save changes on exit without prompting]'
+ '(-N --noconvert -u --unix)'{-u,--unix}'[save files by default in Unix format]'
+ '(-v --view)'{-v,--view}'[disallow editing (read-only mode)]'
+ '(-b --breaklonglines -w --nowrap)'{-w,--nowrap}"[don't hard-wrap long lines]"
+ '(-x --nohelp)'{-x,--nohelp}"[don't show help lines at bottom]"
+ '(-y --afterends)'{-y,--afterends}'[make Ctrl+Right and Ctrl+Delete stop at word ends]'
+ '(- : *)'{-z,--listsyntaxes}'[list names of available syntax definitions]'
+ '(-! --magic)'{-!,--magic}'[use libmagic to determine syntax if necessary]'
+ '(-@ --colonparsing)'{-@,--colonparsing}'[accept filename:linenumber notation on command line]'
+ '(-% --stateflags)'{-%,--stateflags}'[show state flags in title bar]'
+ '(-_ --minibar)'{-_,--minibar}'[hide title bar and show mini bar at bottom]'
+ '(-0 --zero)'{-0,--zero}'[hide UI, use whole terminal]'
+ '(-/ --modernbindings)'{-/,--modernbindings}'[use better-known key bindings]'
+ '*: :->files'
+)
+
+_arguments -s -S : $args && ret=0
+
+case $state in
+ syntaxes)
+ local -a tmp
+ tmp=( ${(f)"$( _call_program syntaxes $words[1] --listsyntaxes )"} )
+ tmp=( ${tmp:#(#i)*available syntax*} )
+ tmp=( ${(@Z<n>)tmp} )
+ _wanted volume-names expl 'syntax' compadd -a - tmp && ret=0
+ ;;
+
+ files)
+ _alternative \
+ 'line-pattern: :_guard "(|+*)" "+line[,column] or +[crCR]{/|?}pattern"' \
+ 'files: :_files' \
+ && ret=0
+ ;;
+esac
+
+return ret
Messages sorted by:
Reverse Date,
Date,
Thread,
Author