summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKienyew <aobi100bt@hotmail.com>2020-09-08 18:34:42 +0800
committerDavid Peter <sharkdp@users.noreply.github.com>2020-09-14 11:28:09 +0200
commita86f3e5b81bbc79e5ae3f4be11f091019db2079f (patch)
tree7f8b00479d4ce13a1e0da5d8a9c4f1ab5fa5ef27
parentd9e8bbcb10f9d4631e66b086a6cd7e358ef9e7a8 (diff)
Fix packaging and Use parameterized names for zsh completion
-rw-r--r--.gitignore1
-rw-r--r--assets/completions/bat.zsh.in (renamed from assets/completions/bat.zsh)14
-rw-r--r--build.rs5
3 files changed, 13 insertions, 7 deletions
diff --git a/.gitignore b/.gitignore
index 3c788cfd..ea15e472 100644
--- a/.gitignore
+++ b/.gitignore
@@ -3,5 +3,6 @@
# Generated files
/assets/completions/bat.fish
+/assets/completions/bat.zsh
/assets/manual/bat.1
/assets/metadata.yaml
diff --git a/assets/completions/bat.zsh b/assets/completions/bat.zsh.in
index 592463f9..cef5daaa 100644
--- a/assets/completions/bat.zsh
+++ b/assets/completions/bat.zsh.in
@@ -1,4 +1,4 @@
-#compdef bat
+#compdef {{PROJECT_EXECUTABLE}}
local context state state_descr line
typeset -A opt_args
@@ -19,8 +19,8 @@ _cache_subcommand() {
_arguments -S -s $args
}
-(( $+functions[_bat_main] )) ||
-_bat_main() {
+(( $+functions[_main] )) ||
+_main() {
local -a args
args=(
'(-A --show-all)'{-A,--show-all}'[Show non-printable characters (space, tab, newline, ..)]'
@@ -55,7 +55,7 @@ _bat_main() {
language)
local IFS=$'\n'
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
;;
@@ -63,7 +63,7 @@ _bat_main() {
theme)
local IFS=$'\n'
local -a themes
- themes=( $(bat --list-themes | sort) )
+ themes=( $({{PROJECT_EXECUTABLE}} --list-themes | sort) )
_values 'theme' $themes
;;
@@ -79,7 +79,7 @@ if (( ${#words} == 2 )); then
local -a subcommands
subcommands=('cache:Modify the syntax-definition and theme cache')
_describe subcommand subcommands
- _bat_main
+ _main
else
case $words[2] in
cache)
@@ -87,7 +87,7 @@ else
;;
*)
- _bat_main
+ _main
;;
esac
fi
diff --git a/build.rs b/build.rs
index 40c4c017..a84755f1 100644
--- a/build.rs
+++ b/build.rs
@@ -53,6 +53,11 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
"assets/completions/bat.fish.in",
out_dir.join("assets/completions/bat.fish"),
)?;
+ template(
+ &variables,
+ "assets/completions/bat.zsh.in",
+ out_dir.join("assets/completions/bat.zsh"),
+ )?;
Ok(())
}