diff --git a/scripts/test-completions.bash b/scripts/test-completions.bash new file mode 100755 index 00000000..a010d899 --- /dev/null +++ b/scripts/test-completions.bash @@ -0,0 +1,11 @@ +#!/usr/bin/env bash + +# Spawns a new bash shell that's set up with a PATH that points +# the `bat` executable and completions from the `target/` dir. + +# Requires https://github.com/scop/bash-completion + +target_dir="$(dirname "$(realpath "$0")")/../target/debug" +completion_file=$target_dir/build/bat-*/out/assets/completions/bat.bash +export PATH="$target_dir:$PATH" +bash --noprofile --rcfile <(echo "source /usr/share/bash-completion/bash_completion; source $completion_file") +o history diff --git a/scripts/test-completions.fish b/scripts/test-completions.fish new file mode 100755 index 00000000..7ef29efa --- /dev/null +++ b/scripts/test-completions.fish @@ -0,0 +1,11 @@ +#!/usr/bin/env fish + +# Spawns a new fish shell that's set up with a PATH that points +# the `bat` executable and completions from the `target/` dir. + +set target_dir "$(dirname (realpath (status -f)))/../target/debug" +set completion_file $target_dir/build/bat-*/out/assets/completions/bat.fish +set --export PATH "$target_dir:$PATH" +fish \ + --no-config --private \ + --init-command="set -U fish_color_command brcyan; set -U fish_pager_color_description yellow; source $completion_file" diff --git a/scripts/test-completions.zsh b/scripts/test-completions.zsh new file mode 100755 index 00000000..e3f52245 --- /dev/null +++ b/scripts/test-completions.zsh @@ -0,0 +1,24 @@ +#!/usr/bin/env bash + +# Spawns a new zsh shell that's set up with a PATH that points +# the `bat` executable and completions from the `target/` dir. + +# Yes, this is a .zsh file that's executed with bash instead :) + +target_dir="$(dirname "$(realpath "$0")")/../target/debug" +completion_file=$target_dir/build/bat-*/out/assets/completions/bat.zsh + +# Setup a temporary ZDOTDIR- +# that's the place where ZSH looks up config files (defaults to $HOME) +ZDOTDIR=$(mktemp -d); export ZDOTDIR +mkdir "$ZDOTDIR/completions" +cp $completion_file "$ZDOTDIR/completions/_bat" + +# Setup an RC file that adds our temporary completions dir to the autoload path +# and initializes completions. +echo 'fpath+=("$ZDOTDIR/completions"); autoload -U compinit; compinit' > "$ZDOTDIR/.zshrc" + +export PATH="$target_dir:$PATH" +zsh --no-globalrcs + +rm -rf "$ZDOTDIR"