From c2fd22e54b1572262be644e14857ea6388a185a9 Mon Sep 17 00:00:00 2001 From: Benjamin VAUDOUR <60374-benjamin.vaudour@users.noreply.framagit.org> Date: Wed, 26 Apr 2023 10:27:15 +0200 Subject: [PATCH] Add 49.3 (alias of doas or sudo) and tree (alias of erd) completion --- completion.elv | 4 ++- completion/49.3.elv | 10 +++++++ completion/tree.elv | 73 +++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 86 insertions(+), 1 deletion(-) create mode 100644 completion/49.3.elv create mode 100644 completion/tree.elv diff --git a/completion.elv b/completion.elv index a75b8a3..bdc196b 100644 --- a/completion.elv +++ b/completion.elv @@ -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 diff --git a/completion/49.3.elv b/completion/49.3.elv new file mode 100644 index 0000000..0aef551 --- /dev/null +++ b/completion/49.3.elv @@ -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~ diff --git a/completion/tree.elv b/completion/tree.elv new file mode 100644 index 0000000..6a832ed --- /dev/null +++ b/completion/tree.elv @@ -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] +}