mirror of
https://github.com/sharkdp/bat.git
synced 2024-11-21 23:33:26 +01:00
Add helper scripts for testing the completions
This commit is contained in:
parent
b662fec214
commit
e0ad6beb60
11
scripts/test-completions.bash
Executable file
11
scripts/test-completions.bash
Executable file
@ -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
|
11
scripts/test-completions.fish
Executable file
11
scripts/test-completions.fish
Executable file
@ -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"
|
24
scripts/test-completions.zsh
Executable file
24
scripts/test-completions.zsh
Executable file
@ -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"
|
Loading…
Reference in New Issue
Block a user