Skip to content

Commit a225164

Browse files
committed
misc. tweaks to GitHub zsh-users#131
general: adjust wording for consistency, conventional mood and capitalisation _apt: - improve _apt_sources(). simplify apt-config calls. add fall-back paths. don't create global sources array - rename _snapshotdates() to _apt_snapshot_dates. eliminate superfluous getdates() function. use $commands instead of whence. eliminate superfluous variable _fortune: use _files to complete databases _smartmontools: fix -j/--json exclusivity, --json optarg style _schroot: fix -n/-o optargs, short option optarg styles
1 parent c63b224 commit a225164

File tree

8 files changed

+38
-39
lines changed

8 files changed

+38
-39
lines changed

Completion/Debian/Command/_apt

Lines changed: 19 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -430,7 +430,7 @@ _apt-cmd () {
430430
/$'changelog\0'/ /$'[^\0]#\0'/ ':packages::_deb_packages "$expl_packages[@]" avail' \# \| \
431431
/$'full-upgrade\0'/ \| \
432432
/$'dist-upgrade\0'/ \| \
433-
/$'edit-sources\0'/ /$'[^\0]#\0'/ ':sourcefiles::_values 'sourcefiles' $sources ' \# \| \
433+
/$'edit-sources\0'/ /$'[^\0]#\0'/ ': ::_apt_sources' \# \| \
434434
/"[]"/ ':argument-1::compadd "$expl_action[@]" list search showsrc show depends rdepends policy update install reinstall download source build-dep satisfy remove upgrade full-upgrade dist-upgrade edit-sources autoclean distclean changelog autoremove autopurge purge'
435435

436436
_apt-cmd () {
@@ -482,7 +482,7 @@ _apt-get () {
482482
--arch-only:bool \
483483
--allow-unauthenticated:bool \
484484
--auto-remove:bool \
485-
-S,--snapshot:_snapshotdates \
485+
-S,--snapshot:_apt_snapshot_dates \
486486
-- \
487487
/$'update\0'/ \| \
488488
/$'upgrade\0'/ \| \
@@ -640,12 +640,15 @@ ${${${${(M)tmp:#*release*n=*}#*n=}%%,*}:#now}
640640
}
641641

642642
_apt_sources () {
643-
local sourcelist sourceparts diretc
644-
diretc="${"${"$(apt-config shell x dir::etc)"#*\'}"%\'*}"
645-
sourceparts="${"${"$(apt-config shell x dir::etc::sourceparts)"#*\'}"%\'*}"
646-
print /${diretc}/$sourceparts/*.{list,sources}(N:t)
643+
local diretc=etc/apt sourceparts=sources.list.d
644+
local -a expl
645+
646+
eval "$(apt-config shell diretc dir::etc 2> /dev/null)"
647+
eval "$(apt-config shell sourceparts dir::etc::sourceparts 2> /dev/null)"
648+
649+
_description files expl 'source file'
650+
_files "${(@)expl}" -W /$diretc/$sourceparts -g '*.(list|sources)(.:t)'
647651
}
648-
sources=( $(_apt_sources) )
649652

650653
_apt_releases () {
651654
local update_policy
@@ -735,21 +738,17 @@ _apt-mark () {
735738
_apt-mark "$@"
736739
}
737740

738-
_snapshotdates() {
739-
local expl
740-
local -a waybackdates
741-
742-
getdates() {
743-
whence -p python3 &>/dev/null || return 0
744-
local timespan='-6month'
745-
local timestamp="$(date +%Y%m%d --date="${timespan}")"
746-
local url="http://snapshot.debian.org/mr/timestamp/?archive=debian&after=${timestamp}"
747-
python3 -c 'import sys,urllib.request,json;[print(x) for x in json.loads(urllib.request.urlopen(sys.argv[1]).read())["result"]["debian"]]' "$url" 2>/dev/null || :
748-
}
741+
_apt_snapshot_dates() {
742+
local -a expl snapshotdates
749743
snapshotdates=(
750-
${(u)$(getdates)%T*}
744+
${(u)$(
745+
(( $+commands[python3] )) || return 0
746+
local timestamp="$(date +%Y%m%d --date=-6month)"
747+
local url="http://snapshot.debian.org/mr/timestamp/?archive=debian&after=${timestamp}"
748+
python3 -c 'import sys,urllib.request,json;[print(x) for x in json.loads(urllib.request.urlopen(sys.argv[1]).read())["result"]["debian"]]' "$url" 2>/dev/null || :
749+
)%T*}
751750
)
752-
_wanted list expl 'wayback date(s)' compadd ${expl} -- ${snapshotdates}
751+
_wanted list expl 'wayback date' compadd -- ${snapshotdates}
753752
}
754753

755754

Completion/Debian/Command/_apt-file

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ case $state in
2828
'update:resynchronize package contents'
2929
{find,search}:'search in which package file is included'
3030
{list,show}:'list contents of a package'
31-
'list-indices:list the known content indices'
31+
'list-indices:list known content indices'
3232
'purge:remove all Contents-<ARCH>.gz files in cache directory'
3333
)
3434
_describe -t commands 'apt-list command' cmds

Completion/Debian/Command/_dhomepage

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@
33
local arguments
44

55
arguments=(
6-
'(-v,--vcs)'{-v,--vcs}'[Open VCS-Homepage instead]'
7-
'(-e,--echo)'{-e,--echo}'[Only print the URL]'
8-
{-h,--help}'[Show help]'
9-
'--version[Show version information]'
6+
'(-v,--vcs)'{-v,--vcs}'[open VCS homepage instead]'
7+
'(-e,--echo)'{-e,--echo}'[only print URL]'
8+
{-h,--help}'[show help]'
9+
'--version[show version information]'
1010
':package:_deb_packages avail'
1111
)
1212

Completion/Debian/Command/_dpkg

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ _dpkg_deb_actions=(
2222
'(--control -e)'{--control,-e}'[extract control]: :_deb_files'
2323
'(--extract -x)'{--extract,-x}'[extract files]: :_deb_files'
2424
'(--vextract -X)'{--vextract,-X}'[extract and list files]: :_deb_files'
25-
'(--raw-extract -R)'{--raw-extract,-R}'[extracts files and control]: :_deb_files'
25+
'(--raw-extract -R)'{--raw-extract,-R}'[extract files and control]: :_deb_files'
2626
'(--field -f)'{--field,-f}'[show fields]: :_deb_files'
2727
'--fsys-tarfile[output fs tarfile]: :_deb_files'
2828
'--ctrl-tarfile[output ctrl tarfile]: :_deb_files'
@@ -42,7 +42,7 @@ _dpkg_actions=(
4242
'(--remove -r)'{--remove,-r}'[remove package]:*:package:->remove'
4343
'(--purge -P)'{--purge,-P}'[purge package]:*:package:->purge'
4444
'(--verify -V)'{--verify,-V}'[verify package]:*:package:->verify'
45-
'(--audit -C)'{--audit,-C}'[check for broken pkgs]'
45+
'(--audit -C)'{--audit,-C}'[check for broken packages]'
4646
'--update-avail[update available]:package file:_files'
4747
'--merge-avail[merge available]:package file:_files'
4848
'(--record-avail -A)'{--record-avail,-A}'[record available]:*:package files:->record_avail'

Completion/Debian/Command/_schroot

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,23 +11,23 @@ _arguments -S \
1111
'--all-sessions[select all active sessions]' \
1212
'--all-source-chroots[select all source chroots]' \
1313
'--exclude-aliases[do not include aliases]' \
14-
'*'{-c,--chroot=}'[use specified chroot]:chroot:->chroot' \
15-
'(-d --directory)'{-d,--directory=}'[directory to use]:dir:_files -W / -P /' \
16-
'(-u --user)'{-u,--user=}'[username (default current user)]:user:_users' \
17-
'(-s --shell)'{-s,--shell=}'[shell to use as login shell]:shell:->shells' \
14+
'*'{-c+,--chroot=}'[use specified chroot]:chroot:->chroot' \
15+
'(-d --directory)'{-d+,--directory=}'[directory to use]:dir:_files -W / -P /' \
16+
'(-u --user)'{-u+,--user=}'[username (default current user)]:user:_users' \
17+
'(-s --shell)'{-s+,--shell=}'[shell to use as login shell]:shell:->shells' \
1818
'(-l --list)'{-l,--list}'[list available chroots]' \
1919
'(-i --info)'{-i,--info}'[show information about selected chroots]' \
2020
'--location[print location of selected chroots]' \
2121
'--config[dump configuration of selected chroots]' \
2222
'(-p --preserve-environment)'{-p,--preserve-environment}'[preserve user environment]' \
23-
'(-o --option)'{-o,--option}'[set option]' \
23+
'(-o --option)'{-o+,--option=}'[set option]:option key=value' \
2424
'(-q --quiet)'{-q,--quiet}'[quiet]' \
2525
'(-v --verbose)'{-v,--verbose}'[verbose]' \
2626
'(-V --version)'{-V,--version}'[version]' \
2727
'--automatic-session[begin, run and end a session automatically]' \
2828
'(-b --begin-session)'{-b,--begin-session}'[begin a session; returns a session ID]' \
2929
'(-r --run-session)'{-r,--run-session}'[run an existing session]' \
30-
'(-n --session-name)'{-n,--session-name}'[session name]' \
30+
'(-n --session-name)'{-n+,--session-name=}'[session name]:session name' \
3131
'--recover-session[recover an existing session]' \
3232
'(-e --end-session)'{-e,--end-session}'[end an existing session]' \
3333
'(-f --force)'{-f,--force}'[force operation]' \

Completion/Unix/Command/_fortune

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,4 @@ _arguments -S \
1212
'-s[short apothegms only]' \
1313
'-i[ignore case for -m patterns]' \
1414
'-w[wait before termination for a time based on msg length]' \
15-
'*:databases:_values -S " " "fortune db" /usr/share/games/fortunes/*(N:r:t)'
15+
'*:fortune db:_files -W /usr/share/games/fortunes -g "*(.:r)"'

Completion/Unix/Command/_smartmontools

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,14 @@ _arguments -s -S \
99
"w[print all words]"
1010
"(b v)n[suppress printing bits]"
1111
"(b n)v[print all bits from valid words]"' \
12-
'-j[output as json]' \
13-
'--json=[output in various json formats or yaml]: : _values -S "" "output format"
12+
'(--json)-j[output as JSON]' \
13+
'(-j)--json=-[specify JSON/YAML output format]: : _values -S "" "output format"
1414
"(b v)c[compact]"
1515
"(b v)g[grep/gron]"
1616
"(b v)o[original]"
1717
"(b v)s[sorted]"
1818
"(b v)v[verbose]"
19-
"(b v)y[yaml]"
19+
"(b v)y[YAML]"
2020
"(b v)i[implemented dev]"
2121
"(b v)u[unimplemented dev]"' \
2222
'(H)*'{-g+,--get=}'[get device setting]:setting:(all aam apm lookahead security wcache rcache wcreorder)' \

Completion/Unix/Command/_zfs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1083,7 +1083,7 @@ case $service:$words[1] in
10831083
zpool:iostat)
10841084
if [[ $implementation = openzfs ]]; then
10851085
args=(
1086-
'-c+[run scripts on each vdev]: :_values -s , "scriptname" $scriptnames'
1086+
'-c+[run scripts on each vdev]: :_values -s , "script name" $scriptnames'
10871087
'-g[display vdev GUIDs instead of normal device names]'
10881088
'-H[suppress headers and tab-delimit fields]'
10891089
'-L[display real paths for vdevs resolving all symbolic links]'
@@ -1252,7 +1252,7 @@ case $service:$words[1] in
12521252
args=(
12531253
'--power[display vdev enclosure slot power status]'
12541254
'-D[display a histogram of deduplication statistics]'
1255-
'-c+[run scripts on each vdev]: :_values -s , "scriptname" $scriptnames'
1255+
'-c+[run scripts on each vdev]: :_values -s , "script name" $scriptnames'
12561256
'-e[only show unhealthy vdevs]'
12571257
'-i[display vdev initialization status]'
12581258
'-g[display vdev GUIDs instead of the normal device names]'

0 commit comments

Comments
 (0)