mirror of
https://github.com/fish-shell/fish-shell
synced 2024-12-26 21:03:12 +00:00
fix(completion): move d2 related functions to completion file
This commit is contained in:
parent
fce17a90a7
commit
e45a8acda4
3 changed files with 26 additions and 24 deletions
|
@ -1,3 +1,29 @@
|
||||||
|
function __fish_d2__complete_themes
|
||||||
|
d2 themes |
|
||||||
|
sed -n '3,$p' |
|
||||||
|
string match --entire --regex '^-' |
|
||||||
|
string replace --regex -- '- ([^:]+): (.+)' '$2\t$1'
|
||||||
|
end
|
||||||
|
|
||||||
|
function __fish_d2__complete_layouts
|
||||||
|
set -l layouts (d2 layout |
|
||||||
|
sed -n '3,$p' |
|
||||||
|
sed -n '/^$/,$d; p' |
|
||||||
|
string replace --regex '^(\w+)\s+\(bundled\)' '$1')
|
||||||
|
|
||||||
|
set -l identifiers
|
||||||
|
set -l descriptions
|
||||||
|
|
||||||
|
for layout in $layouts
|
||||||
|
set -a identifiers (string replace --regex ' - .+$' '' -- $layouts)
|
||||||
|
set -a descriptions (string replace --regex '^\w+ - ' '' -- $layouts)
|
||||||
|
end
|
||||||
|
|
||||||
|
for index in (seq (count $layouts))
|
||||||
|
printf '%s\t%s\n' $identifiers[$index] $descriptions[$index]
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
set -l command kroki
|
set -l command kroki
|
||||||
|
|
||||||
complete -c $command -f
|
complete -c $command -f
|
||||||
|
|
|
@ -1,18 +0,0 @@
|
||||||
function __fish_d2__complete_layouts
|
|
||||||
set -l layouts (d2 layout |
|
|
||||||
sed -n '3,$p' |
|
|
||||||
sed -n '/^$/,$d; p' |
|
|
||||||
string replace --regex '^(\w+)\s+\(bundled\)' '$1')
|
|
||||||
|
|
||||||
set -l identifiers
|
|
||||||
set -l descriptions
|
|
||||||
|
|
||||||
for layout in $layouts
|
|
||||||
set -a identifiers (string replace --regex ' - .+$' '' -- $layouts)
|
|
||||||
set -a descriptions (string replace --regex '^\w+ - ' '' -- $layouts)
|
|
||||||
end
|
|
||||||
|
|
||||||
for index in (seq (count $layouts))
|
|
||||||
printf '%s\t%s\n' $identifiers[$index] $descriptions[$index]
|
|
||||||
end
|
|
||||||
end
|
|
|
@ -1,6 +0,0 @@
|
||||||
function __fish_d2__complete_themes
|
|
||||||
d2 themes |
|
|
||||||
sed -n '3,$p' |
|
|
||||||
string match --entire --regex '^-' |
|
|
||||||
string replace --regex -- '- ([^:]+): (.+)' '$2\t$1'
|
|
||||||
end
|
|
Loading…
Reference in a new issue