mirror of
https://github.com/tealdeer-rs/tealdeer.git
synced 2026-08-21 07:34:18 +02:00
zsh-completion: fix issue with [.md, add basic -L completion, remove extra _files args (#168)
- Use array `commands=(...)` and `_describe` to deal with '[.md' & empty cache scenario. Fixes #166 - Hide `tldr --list` stderr (`2>/dev/null`) which breaks completion with empty cache - Remove `sed` since #112 changed commas to newlines - Add new `sed`-equivalent replacement (`:` -> `\:`) using native [ZSH `${name//pattern/repl}`](http://zsh.sourceforge.net/Doc/Release/Expansion.html#Parameter-Expansion) since colon is special character in ZSH completions - Add basic support for `-L, --language` flag from #125. In future, can consider adding extra completions maybe based on caches `pages.{lang}` folders. - Remove extraneous completion of file names for positional arguments (i.e. `'*:file:_files'`)
This commit is contained in:
parent
2a6d09554b
commit
071680800a
1 changed files with 5 additions and 3 deletions
|
|
@ -1,7 +1,9 @@
|
|||
#compdef tldr
|
||||
|
||||
_applications() {
|
||||
_values 'applications' "${(uonzf)$(tldr --list | sed -e 's/, /\n/g')}"
|
||||
local -a commands
|
||||
commands=(${(uonzf)"$(tldr --list 2>/dev/null)"//:/\\:})
|
||||
_describe -t commands 'command' commands
|
||||
}
|
||||
|
||||
_tealdeer() {
|
||||
|
|
@ -18,6 +20,7 @@ _tealdeer() {
|
|||
sunos
|
||||
windows
|
||||
))'
|
||||
"($I -L --language)"{-L,--language}"[Override the language settings]:lang"
|
||||
"($I -u --update)"{-u,--update}"[Update the local cache]"
|
||||
"($I -c --clear-cache)"{-c,--clear-cache}"[Clear the local cache]"
|
||||
"($I -p --pager)"{-p,--pager}"[Use a pager to page output]"
|
||||
|
|
@ -31,8 +34,7 @@ _tealdeer() {
|
|||
never
|
||||
))"
|
||||
'(- *)'{-h,--help}'[Display help]'
|
||||
'(- *)'{-v,--version}'[Show version information]'
|
||||
'*:file:_files'
|
||||
'(- *)'{-v,--version}'[Show version information]'
|
||||
'1: :_applications'
|
||||
)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue