113 lines
3.8 KiB
Plaintext
Raw Normal View History

2021-05-04 05:03:23 +08:00
2021-08-15 17:26:56 +05:30
use builtin;
use str;
2022-01-21 03:14:28 +05:30
set edit:completion:arg-completer[zoxide] = {|@words|
fn spaces {|n|
2021-08-15 17:26:56 +05:30
builtin:repeat $n ' ' | str:join ''
2021-05-04 05:03:23 +08:00
}
2022-01-21 03:14:28 +05:30
fn cand {|text desc|
2021-10-21 00:01:06 +05:30
edit:complex-candidate $text &display=$text' '(spaces (- 14 (wcswidth $text)))$desc
2021-05-04 05:03:23 +08:00
}
2021-10-21 00:01:06 +05:30
var command = 'zoxide'
2021-08-15 17:26:56 +05:30
for word $words[1..-1] {
if (str:has-prefix $word '-') {
2021-05-04 05:03:23 +08:00
break
}
2021-10-21 00:01:06 +05:30
set command = $command';'$word
2021-05-04 05:03:23 +08:00
}
2021-10-21 00:01:06 +05:30
var completions = [
2021-05-04 05:03:23 +08:00
&'zoxide'= {
cand -h 'Print help'
cand --help 'Print help'
cand -V 'Print version'
cand --version 'Print version'
2021-05-04 05:03:23 +08:00
cand add 'Add a new directory or increment its rank'
2023-01-07 22:58:10 +05:30
cand edit 'Edit the database'
2021-05-04 05:03:23 +08:00
cand import 'Import entries from another application'
cand init 'Generate shell configuration'
cand query 'Search for a directory in the database'
cand remove 'Remove a directory from the database'
}
&'zoxide;add'= {
cand -h 'Print help'
cand --help 'Print help'
cand -V 'Print version'
cand --version 'Print version'
2021-05-04 05:03:23 +08:00
}
2023-01-07 22:58:10 +05:30
&'zoxide;edit'= {
cand -h 'Print help'
cand --help 'Print help'
cand -V 'Print version'
cand --version 'Print version'
2023-01-07 22:58:10 +05:30
cand decrement 'decrement'
cand delete 'delete'
cand increment 'increment'
cand reload 'reload'
}
&'zoxide;edit;decrement'= {
cand -h 'Print help'
cand --help 'Print help'
cand -V 'Print version'
cand --version 'Print version'
2023-01-07 22:58:10 +05:30
}
&'zoxide;edit;delete'= {
cand -h 'Print help'
cand --help 'Print help'
cand -V 'Print version'
cand --version 'Print version'
2023-01-07 22:58:10 +05:30
}
&'zoxide;edit;increment'= {
cand -h 'Print help'
cand --help 'Print help'
cand -V 'Print version'
cand --version 'Print version'
2023-01-07 22:58:10 +05:30
}
&'zoxide;edit;reload'= {
cand -h 'Print help'
cand --help 'Print help'
cand -V 'Print version'
cand --version 'Print version'
2023-01-07 22:58:10 +05:30
}
2021-05-04 05:03:23 +08:00
&'zoxide;import'= {
cand --from 'Application to import from'
cand --merge 'Merge into existing database'
cand -h 'Print help'
cand --help 'Print help'
cand -V 'Print version'
cand --version 'Print version'
2021-05-04 05:03:23 +08:00
}
&'zoxide;init'= {
2022-04-11 03:41:51 +05:30
cand --cmd 'Changes the prefix of the `z` and `zi` commands'
cand --hook 'Changes how often zoxide increments a directory''s score'
cand --no-cmd 'Prevents zoxide from defining the `z` and `zi` commands'
cand -h 'Print help'
cand --help 'Print help'
cand -V 'Print version'
cand --version 'Print version'
2021-05-04 05:03:23 +08:00
}
&'zoxide;query'= {
cand --exclude 'Exclude the current directory'
2023-05-09 00:51:26 +05:30
cand -a 'Show unavailable directories'
cand --all 'Show unavailable directories'
2021-05-04 05:03:23 +08:00
cand -i 'Use interactive selection'
cand --interactive 'Use interactive selection'
cand -l 'List all matching directories'
cand --list 'List all matching directories'
cand -s 'Print score with results'
cand --score 'Print score with results'
cand -h 'Print help'
cand --help 'Print help'
cand -V 'Print version'
cand --version 'Print version'
2021-05-04 05:03:23 +08:00
}
&'zoxide;remove'= {
cand -h 'Print help'
cand --help 'Print help'
cand -V 'Print version'
cand --version 'Print version'
2021-05-04 05:03:23 +08:00
}
]
$completions[$command]
}