From ea2179b35289c9217669e7fda0685f20d699dd50 Mon Sep 17 00:00:00 2001 From: Ethan P Date: Fri, 27 Sep 2019 12:13:55 -0700 Subject: [PATCH] Update fish completions to use parameterized names --- assets/completions/bat.fish | 76 ---------------------------------- assets/completions/bat.fish.in | 76 ++++++++++++++++++++++++++++++++++ build.rs | 7 ++++ 3 files changed, 83 insertions(+), 76 deletions(-) delete mode 100644 assets/completions/bat.fish create mode 100644 assets/completions/bat.fish.in diff --git a/assets/completions/bat.fish b/assets/completions/bat.fish deleted file mode 100644 index cbcb2ec2..00000000 --- a/assets/completions/bat.fish +++ /dev/null @@ -1,76 +0,0 @@ -# Fish Shell Completions -# Place or symlink to $XDG_CONFIG_HOME/fish/completions/bat.fish ($XDG_CONFIG_HOME is usually set to ~/.config) - -# Helper function: -function __bat_autocomplete_languages --description "A helper function used by "(status filename) - bat --list-languages | awk -F':' ' - { - lang=$1 - split($2, exts, ",") - - for (i in exts) { - ext=exts[i] - if (ext !~ /[A-Z].*/ && ext !~ /^\..*rc$/) { - print ext"\t"lang - } - } - } - ' | sort -end - -# Completions: - -complete -c bat -l color -xka "auto never always" -d "Specify when to use colored output (default: auto)" -n "not __fish_seen_subcommand_from cache" - -complete -c bat -l config-dir -d "Display location of 'bat' configuration directory" -n "not __fish_seen_subcommand_from cache" - -complete -c bat -l config-file -d "Display location of 'bat' configuration file" -n "not __fish_seen_subcommand_from cache" - -complete -c bat -l decorations -xka "auto never always" -d "Specify when to use the decorations specified with '--style' (default: auto)" -n "not __fish_seen_subcommand_from cache" - -complete -c bat -s h -l help -d "Print help message" -n "not __fish_seen_subcommand_from cache" - -complete -c bat -s H -l highlight-line -x -d " Highlight the N-th line with a different background color" -n "not __fish_seen_subcommand_from cache" - -complete -c bat -l italic-text -xka "always never" -d "Specify when to use ANSI sequences for italic text (default: never)" -n "not __fish_seen_subcommand_from cache" - -complete -c bat -s l -l language -d "Set the language for syntax highlighting" -n "not __fish_seen_subcommand_from cache" -xa "(__bat_autocomplete_languages)" - -complete -c bat -s r -l line-range -x -d " Only print the specified range of lines for each file" -n "not __fish_seen_subcommand_from cache" - -complete -c bat -l list-languages -d "Display list of supported languages for syntax highlighting" -n "not __fish_seen_subcommand_from cache" - -complete -c bat -l list-themes -d "Display a list of supported themes for syntax highlighting" -n "not __fish_seen_subcommand_from cache" - -complete -c bat -s m -l map-syntax -x -d " Map a file extension or file name to an existing syntax" -n "not __fish_seen_subcommand_from cache" - -complete -c bat -s n -l number -d "Only show line numbers, no other decorations. Alias for '--style=numbers'" -n "not __fish_seen_subcommand_from cache" - -complete -c bat -l pager -x -d " Specify which pager program to use (default: less)" -n "not __fish_seen_subcommand_from cache" - -complete -c bat -l paging -xka "auto never always" -d "Specify when to use the pager (default: auto)" -n "not __fish_seen_subcommand_from cache" - -complete -c bat -s p -l plain -d "Only show plain style, no decorations. Alias for '--style=plain'" -n "not __fish_seen_subcommand_from cache" - -complete -c bat -s A -l show-all -d "Show non-printable characters like space/tab/newline" -n "not __fish_seen_subcommand_from cache" - -complete -c bat -l style -xka "auto full plain changes header grid numbers" -d "Comma-separated list of style elements or presets to display with file contents" -n "not __fish_seen_subcommand_from cache" - -complete -c bat -l tabs -x -d " Set the tab width to T spaces (width of 0 passes tabs through directly)" -n "not __fish_seen_subcommand_from cache" - -complete -c bat -l terminal-width -x -d " Explicitly set terminal width; Prefix with '+' or '-' to offset (default width is auto determined)" -n "not __fish_seen_subcommand_from cache" - -complete -c bat -l theme -xka "(bat --list-themes | cat)" -d "Set the theme for syntax highlighting" -n "not __fish_seen_subcommand_from cache" - -complete -c bat -s u -l unbuffered -d "POSIX-compliant unbuffered output. Option is ignored" -n "not __fish_seen_subcommand_from cache" - -complete -c bat -s V -l version -d "Show version information" -n "not __fish_seen_subcommand_from cache" - -complete -c bat -l wrap -xka "auto never character" -d " Specify the text-wrapping mode (default: auto)" -n "not __fish_seen_subcommand_from cache" - -# Sub-command 'cache' completions -complete -c bat -a "cache" -d "Modify the syntax/language definition cache" -n "not __fish_seen_subcommand_from cache" - -complete -c bat -l build -f -d "Parse syntaxes/language definitions into cache" -n "__fish_seen_subcommand_from cache" - -complete -c bat -l clear -f -d "Reset syntaxes/language definitions to default settings" -n "__fish_seen_subcommand_from cache" diff --git a/assets/completions/bat.fish.in b/assets/completions/bat.fish.in new file mode 100644 index 00000000..bf22fe9b --- /dev/null +++ b/assets/completions/bat.fish.in @@ -0,0 +1,76 @@ +# Fish Shell Completions +# Place or symlink to $XDG_CONFIG_HOME/fish/completions/{{PROJECT_EXECUTABLE}}.fish ($XDG_CONFIG_HOME is usually set to ~/.config) + +# Helper function: +function __{{PROJECT_EXECUTABLE}}_autocomplete_languages --description "A helper function used by "(status filename) + {{PROJECT_EXECUTABLE}} --list-languages | awk -F':' ' + { + lang=$1 + split($2, exts, ",") + + for (i in exts) { + ext=exts[i] + if (ext !~ /[A-Z].*/ && ext !~ /^\..*rc$/) { + print ext"\t"lang + } + } + } + ' | sort +end + +# Completions: + +complete -c {{PROJECT_EXECUTABLE}} -l color -xka "auto never always" -d "Specify when to use colored output (default: auto)" -n "not __fish_seen_subcommand_from cache" + +complete -c {{PROJECT_EXECUTABLE}} -l config-dir -d "Display location of '{{PROJECT_EXECUTABLE}}' configuration directory" -n "not __fish_seen_subcommand_from cache" + +complete -c {{PROJECT_EXECUTABLE}} -l config-file -d "Display location of '{{PROJECT_EXECUTABLE}}' configuration file" -n "not __fish_seen_subcommand_from cache" + +complete -c {{PROJECT_EXECUTABLE}} -l decorations -xka "auto never always" -d "Specify when to use the decorations specified with '--style' (default: auto)" -n "not __fish_seen_subcommand_from cache" + +complete -c {{PROJECT_EXECUTABLE}} -s h -l help -d "Print help message" -n "not __fish_seen_subcommand_from cache" + +complete -c {{PROJECT_EXECUTABLE}} -s H -l highlight-line -x -d " Highlight the N-th line with a different background color" -n "not __fish_seen_subcommand_from cache" + +complete -c {{PROJECT_EXECUTABLE}} -l italic-text -xka "always never" -d "Specify when to use ANSI sequences for italic text (default: never)" -n "not __fish_seen_subcommand_from cache" + +complete -c {{PROJECT_EXECUTABLE}} -s l -l language -d "Set the language for syntax highlighting" -n "not __fish_seen_subcommand_from cache" -xa "(__{{PROJECT_EXECUTABLE}}_autocomplete_languages)" + +complete -c {{PROJECT_EXECUTABLE}} -s r -l line-range -x -d " Only print the specified range of lines for each file" -n "not __fish_seen_subcommand_from cache" + +complete -c {{PROJECT_EXECUTABLE}} -l list-languages -d "Display list of supported languages for syntax highlighting" -n "not __fish_seen_subcommand_from cache" + +complete -c {{PROJECT_EXECUTABLE}} -l list-themes -d "Display a list of supported themes for syntax highlighting" -n "not __fish_seen_subcommand_from cache" + +complete -c {{PROJECT_EXECUTABLE}} -s m -l map-syntax -x -d " Map a file extension or file name to an existing syntax" -n "not __fish_seen_subcommand_from cache" + +complete -c {{PROJECT_EXECUTABLE}} -s n -l number -d "Only show line numbers, no other decorations. Alias for '--style=numbers'" -n "not __fish_seen_subcommand_from cache" + +complete -c {{PROJECT_EXECUTABLE}} -l pager -x -d " Specify which pager program to use (default: less)" -n "not __fish_seen_subcommand_from cache" + +complete -c {{PROJECT_EXECUTABLE}} -l paging -xka "auto never always" -d "Specify when to use the pager (default: auto)" -n "not __fish_seen_subcommand_from cache" + +complete -c {{PROJECT_EXECUTABLE}} -s p -l plain -d "Only show plain style, no decorations. Alias for '--style=plain'" -n "not __fish_seen_subcommand_from cache" + +complete -c {{PROJECT_EXECUTABLE}} -s A -l show-all -d "Show non-printable characters like space/tab/newline" -n "not __fish_seen_subcommand_from cache" + +complete -c {{PROJECT_EXECUTABLE}} -l style -xka "auto full plain changes header grid numbers" -d "Comma-separated list of style elements or presets to display with file contents" -n "not __fish_seen_subcommand_from cache" + +complete -c {{PROJECT_EXECUTABLE}} -l tabs -x -d " Set the tab width to T spaces (width of 0 passes tabs through directly)" -n "not __fish_seen_subcommand_from cache" + +complete -c {{PROJECT_EXECUTABLE}} -l terminal-width -x -d " Explicitly set terminal width; Prefix with '+' or '-' to offset (default width is auto determined)" -n "not __fish_seen_subcommand_from cache" + +complete -c {{PROJECT_EXECUTABLE}} -l theme -xka "({{PROJECT_EXECUTABLE}} --list-themes | cat)" -d "Set the theme for syntax highlighting" -n "not __fish_seen_subcommand_from cache" + +complete -c {{PROJECT_EXECUTABLE}} -s u -l unbuffered -d "POSIX-compliant unbuffered output. Option is ignored" -n "not __fish_seen_subcommand_from cache" + +complete -c {{PROJECT_EXECUTABLE}} -s V -l version -d "Show version information" -n "not __fish_seen_subcommand_from cache" + +complete -c {{PROJECT_EXECUTABLE}} -l wrap -xka "auto never character" -d " Specify the text-wrapping mode (default: auto)" -n "not __fish_seen_subcommand_from cache" + +# Sub-command 'cache' completions +complete -c {{PROJECT_EXECUTABLE}} -a "cache" -d "Modify the syntax/language definition cache" -n "not __fish_seen_subcommand_from cache" + +complete -c {{PROJECT_EXECUTABLE}} -l build -f -d "Parse syntaxes/language definitions into cache" -n "__fish_seen_subcommand_from cache" + +complete -c {{PROJECT_EXECUTABLE}} -l clear -f -d "Reset syntaxes/language definitions to default settings" -n "__fish_seen_subcommand_from cache" diff --git a/build.rs b/build.rs index c3813274..5cd63e85 100644 --- a/build.rs +++ b/build.rs @@ -54,12 +54,19 @@ fn template( fn main() -> Result<(), Box> { let variables = init_template(); + template( &variables, "assets/manual/bat.1.in", &format!("assets/manual/{}.1", EXECUTABLE_NAME.to_owned()), )?; + template( + &variables, + "assets/completions/bat.fish.in", + &format!("assets/completions/{}.fish", EXECUTABLE_NAME.to_owned()), + )?; + Ok(()) }