mirror of
https://github.com/sharkdp/bat.git
synced 2025-01-31 10:11:07 +00:00
Fix packaging and Use parameterized names for zsh completion
This commit is contained in:
parent
d9e8bbcb10
commit
a86f3e5b81
1
.gitignore
vendored
1
.gitignore
vendored
@ -3,5 +3,6 @@
|
|||||||
|
|
||||||
# Generated files
|
# Generated files
|
||||||
/assets/completions/bat.fish
|
/assets/completions/bat.fish
|
||||||
|
/assets/completions/bat.zsh
|
||||||
/assets/manual/bat.1
|
/assets/manual/bat.1
|
||||||
/assets/metadata.yaml
|
/assets/metadata.yaml
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
#compdef bat
|
#compdef {{PROJECT_EXECUTABLE}}
|
||||||
|
|
||||||
local context state state_descr line
|
local context state state_descr line
|
||||||
typeset -A opt_args
|
typeset -A opt_args
|
||||||
@ -19,8 +19,8 @@ _cache_subcommand() {
|
|||||||
_arguments -S -s $args
|
_arguments -S -s $args
|
||||||
}
|
}
|
||||||
|
|
||||||
(( $+functions[_bat_main] )) ||
|
(( $+functions[_main] )) ||
|
||||||
_bat_main() {
|
_main() {
|
||||||
local -a args
|
local -a args
|
||||||
args=(
|
args=(
|
||||||
'(-A --show-all)'{-A,--show-all}'[Show non-printable characters (space, tab, newline, ..)]'
|
'(-A --show-all)'{-A,--show-all}'[Show non-printable characters (space, tab, newline, ..)]'
|
||||||
@ -55,7 +55,7 @@ _bat_main() {
|
|||||||
language)
|
language)
|
||||||
local IFS=$'\n'
|
local IFS=$'\n'
|
||||||
local -a languages
|
local -a languages
|
||||||
languages=( $(bat --list-languages | awk -F':|,' '{ for (i = 1; i <= NF; ++i) printf("%s:%s\n", $i, $1) }') )
|
languages=( $({{PROJECT_EXECUTABLE}} --list-languages | awk -F':|,' '{ for (i = 1; i <= NF; ++i) printf("%s:%s\n", $i, $1) }') )
|
||||||
|
|
||||||
_describe 'language' languages
|
_describe 'language' languages
|
||||||
;;
|
;;
|
||||||
@ -63,7 +63,7 @@ _bat_main() {
|
|||||||
theme)
|
theme)
|
||||||
local IFS=$'\n'
|
local IFS=$'\n'
|
||||||
local -a themes
|
local -a themes
|
||||||
themes=( $(bat --list-themes | sort) )
|
themes=( $({{PROJECT_EXECUTABLE}} --list-themes | sort) )
|
||||||
|
|
||||||
_values 'theme' $themes
|
_values 'theme' $themes
|
||||||
;;
|
;;
|
||||||
@ -79,7 +79,7 @@ if (( ${#words} == 2 )); then
|
|||||||
local -a subcommands
|
local -a subcommands
|
||||||
subcommands=('cache:Modify the syntax-definition and theme cache')
|
subcommands=('cache:Modify the syntax-definition and theme cache')
|
||||||
_describe subcommand subcommands
|
_describe subcommand subcommands
|
||||||
_bat_main
|
_main
|
||||||
else
|
else
|
||||||
case $words[2] in
|
case $words[2] in
|
||||||
cache)
|
cache)
|
||||||
@ -87,7 +87,7 @@ else
|
|||||||
;;
|
;;
|
||||||
|
|
||||||
*)
|
*)
|
||||||
_bat_main
|
_main
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
fi
|
fi
|
5
build.rs
5
build.rs
@ -53,6 +53,11 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
|
|||||||
"assets/completions/bat.fish.in",
|
"assets/completions/bat.fish.in",
|
||||||
out_dir.join("assets/completions/bat.fish"),
|
out_dir.join("assets/completions/bat.fish"),
|
||||||
)?;
|
)?;
|
||||||
|
template(
|
||||||
|
&variables,
|
||||||
|
"assets/completions/bat.zsh.in",
|
||||||
|
out_dir.join("assets/completions/bat.zsh"),
|
||||||
|
)?;
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user