Add 49.3 (alias of doas or sudo) and tree (alias of erd) completion

This commit is contained in:
Benjamin VAUDOUR 2023-04-26 10:27:15 +02:00
parent 406023ed33
commit c2fd22e54b
3 changed files with 86 additions and 1 deletions

View File

@ -2,9 +2,11 @@ use ./completion/arc
use ./completion/archiver
use ./completion/desarchiver
use ./completion/doas
use ./completion/49.3
use ./completion/kcp
use ./completion/mpv
#use ./completion/mpv
use ./completion/pacman
use ./completion/ssh
use ./completion/sudo
use ./completion/tree
use ./completion/use

10
completion/49.3.elv Normal file
View File

@ -0,0 +1,10 @@
fn complete {|@argv|
if (and (> (count $argv) 2) (has-key $edit:completion:arg-completer $argv[1])) {
$edit:completion:arg-completer[$argv[1]] (all $argv[1:])
} else {
edit:complete-sudo $@argv
}
}
set edit:completion:arg-completer[49.3] = $edit:complete-sudo~
#edit:completion:arg-completer[doas] = $-complete~

73
completion/tree.elv Normal file
View File

@ -0,0 +1,73 @@
use builtin;
use str;
set edit:completion:arg-completer[tree] = {|@words|
fn spaces {|n|
builtin:repeat $n ' ' | str:join ''
}
fn cand {|text desc|
edit:complex-candidate $text &display=$text' '(spaces (- 14 (wcswidth $text)))$desc
}
var command = 'et'
for word $words[1..-1] {
if (str:has-prefix $word '-') {
break
}
set command = $command';'$word
}
var completions = [
&'et'= {
cand -d 'Print physical or logical file size'
cand --disk-usage 'Print physical or logical file size'
cand --time 'Which kind of timestamp to use; modified by default'
cand -L 'Maximum depth to display'
cand --level 'Maximum depth to display'
cand -p 'Regular expression (or glob if ''--glob'' or ''--iglob'' is used) used to match files'
cand --pattern 'Regular expression (or glob if ''--glob'' or ''--iglob'' is used) used to match files'
cand -t 'Restrict regex or glob search to a particular file-type'
cand --file-type 'Restrict regex or glob search to a particular file-type'
cand -s 'Sort-order to display directory content'
cand --sort 'Sort-order to display directory content'
cand -T 'Number of threads to use'
cand --threads 'Number of threads to use'
cand -u 'Report disk usage in binary or SI units'
cand --unit 'Report disk usage in binary or SI units'
cand --completions 'Print completions for a given shell to stdout'
cand -C 'Turn on colorization always'
cand --force-color 'Turn on colorization always'
cand -f 'Follow symlinks'
cand --follow 'Follow symlinks'
cand -F 'Print disk usage information in plain format without the ASCII tree'
cand --flat 'Print disk usage information in plain format without the ASCII tree'
cand -H 'Print disk usage in human-readable format'
cand --human 'Print disk usage in human-readable format'
cand -i 'Do not respect .gitignore files'
cand --no-ignore 'Do not respect .gitignore files'
cand -I 'Display file icons'
cand --icons 'Display file icons'
cand -l 'Show extended metadata and attributes'
cand --long 'Show extended metadata and attributes'
cand --octal 'Show permissions in numeric octal format instead of symbolic'
cand --glob 'Enables glob based searching'
cand --iglob 'Enables case-insensitive glob based searching'
cand -P 'Remove empty directories from output'
cand --prune 'Remove empty directories from output'
cand --dirs-first 'Sort directories above files'
cand -. 'Show hidden files'
cand --hidden 'Show hidden files'
cand --no-git 'Disable traversal of .git directory when traversing hidden files'
cand --dirs-only 'Only print directories'
cand --inverted 'Print tree with the root directory at the topmost position'
cand --no-color 'Print plainly without ANSI escapes'
cand --no-config 'Don''t read configuration file'
cand --suppress-size 'Omit disk usage from output'
cand --truncate 'Truncate output to fit terminal emulator window'
cand -h 'Print help (see more with ''--help'')'
cand --help 'Print help (see more with ''--help'')'
cand -V 'Print version'
cand --version 'Print version'
}
]
$completions[$command]
}