Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions tools/completions/Makefile.am
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
PREFIX=/usr/share
PREFIX=${datadir}
EXTRA_DIST = \
fish-completion.fish \
zsh-completion.zsh
zsh-completion.zsh \
bash-completion.sh

.PHONY: install-zsh-completion
install-zsh-completion:
Expand All @@ -10,3 +11,7 @@ install-zsh-completion:
.PHONY: install-fish-completion
install-fish-completion:
install -Dm644 fish-completion.fish $(PREFIX)/fish/vendor_completions.d/chafa.fish

.PHONY: install-bash-completion
install-bash-completion:
install -Dm644 bash-completion.sh $(PREFIX)/bash-completion/completions/chafa
65 changes: 65 additions & 0 deletions tools/completions/bash-completion.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
_chafa()
{
local cur prev opts
COMPREPLY=()
cur="${COMP_WORDS[COMP_CWORD]}"
prev="${COMP_WORDS[COMP_CWORD-1]}"

opts="--help -h --version -v --verbose --probe --files --files0 --format -f --optimize -O --relative --passthrough --polite --align --clear --center -C --exact-size --fit-width --font-ratio --grid -g --label -l --link --margin-bottom --margin-right --scale --size -s --stretch --view-size --animate --duration -d --speed --watch --bg --colors -c --color-extractor --color-space --dither --dither-grain --dither-intensity --fg --invert --preprocess -p --threshold -t --threads --work -w --fg-only --fill --glyph-file --symbols --dump-detect --fuzz-options --zoom"

if [[ ${cur} == -* ]] ; then
COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
return 0
fi

case "${prev}" in
--format|-f)
COMPREPLY=( $(compgen -W "iterm kitty sixels symbols" -- "${cur}") )
;;
--optimize|-O)
COMPREPLY=( $(compgen -W "0 1 2 3 4 5 6 7 8 9" -- "${cur}") )
;;
--relative|--polite|--animate|--preprocess|-p|--center|-C|--label)
COMPREPLY=( $(compgen -W "on off" -- "${cur}") )
;;
--passthrough)
COMPREPLY=( $(compgen -W "auto none screen tmux" -- "${cur}") )
;;

--exact-size|--link|--probe)
COMPREPLY=( $(compgen -W "auto on off" -- "${cur}") )
;;
--grid)
COMPREPLY=( $(compgen -W "auto" -- "${cur}") )
;;
--scale)
COMPREPLY=( $(compgen -W "max" -- "${cur}") )
;;

--colors|-c)
COMPREPLY=( $(compgen -W "none 2 8 16/8 16 240 256 full" -- "${cur}") )
;;
--color-extractor)
COMPREPLY=( $(compgen -W "average median" -- "${cur}") )
;;
--color-space)
COMPREPLY=( $(compgen -W "rgb din99d" -- "${cur}") )
;;
--dither)
COMPREPLY=( $(compgen -W "none ordered diffusion noise" -- "${cur}") )
;;

--fill|--symbols)
local symbols="all asci braille extra imported narrow solid ugly alnum bad diagonal geometric inverted none space vhalf alpha block digit half latin quad stipple wedge ambiguous border dot hhalf legacy sextant technical wide"
COMPREPLY=( $(compgen -W "${symbols}" -- "${cur}") )
;;

--work|-w)
COMPREPLY=( $(compgen -W "1 2 3 4 5 6 7 8 9" -- "${cur}") )
;;
esac

return 0
}

complete -o default -F _chafa chafa
16 changes: 12 additions & 4 deletions tools/completions/fish-completion.fish
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
complete -c chafa -e

complete -c chafa -o 'h' -l 'help' -d 'Show help'
complete -c chafa -l 'version' -d 'Show version'
complete -c chafa -o 'v' -l 'verbose' -d 'Be verbose'
complete -c chafa -l 'files' -x -a '(- _files)' -d 'Read list of files to process from PATH (newline-separated), or "-" for stdin'
complete -c chafa -l 'files0' -x -a '(- _files)' -d 'Read list of files to process from PATH (NUL-separated), or "-" for stdin'
complete -c chafa -o 'h' -l 'help' -d 'Show help'
complete -c chafa -l 'probe' -x -a 'auto on off' -d 'Probe terminal\'s capabilities and wait for response'
complete -c chafa -l 'version' -d 'Show version'
complete -c chafa -o 'v' -l 'verbose' -d 'Be verbose'

complete -c chafa -o 'f' -l 'format' -x -a 'iterm kitty sixels symbols' -d 'Set output format'
complete -c chafa -o 'O' -l 'optimize' -x -a "(seq 0 9)" -d 'Compress the output by using control sequences intelligently'
Expand All @@ -15,6 +18,11 @@ complete -c chafa -l 'clear' -d 'Clear screen
complete -c chafa -l 'exact-size' -x -a 'auto on off' -d 'Try to match the input\'s size exactly'
complete -c chafa -l 'fit-width' -d 'Fit images to view\'s width, possibly exceeding their height'
complete -c chafa -l 'font-ratio' -x -d 'Target font\'s width/height ratio'
complete -c chafa -l 'grid' -x -a 'auto' -d 'Lay out images in a grid of CxR columns/rows per screenful'
complete -c chafa -o 'g' -l 'grid-on' -d 'Alias for "--grid auto"'
complete -c chafa -l 'label' -x -a 'on off' -d 'Labeling filenames below images'
complete -c chafa -o 'l' -l 'label-on' -d 'Alias for "--label on"'
complete -c chafa -l 'link' -x -a 'auto on off' -d 'Turns labels into clickable hyperlinks'
complete -c chafa -l 'margin-bottom' -x -d 'Reserve at least NUM rows at the bottom as a safety margin'
complete -c chafa -l 'margin-right' -x -d 'Reserve at least NUM columns safety margin on right-hand side'
complete -c chafa -l 'scale' -x -d 'Scale image, respecting view\'s dimentions. Specify "max" to fit view'
Expand All @@ -31,7 +39,7 @@ complete -c chafa -l 'bg' -x
complete -c chafa -l 'colors' -x -a 'none 2 8 16/8 16 240 256 full' -d 'Set output color mode'
complete -c chafa -l 'color-extractor' -x -a 'average median' -d 'Method for extracting color from an area'
complete -c chafa -l 'color-space' -x -a 'rgb din99d' -d 'Color space used for quantization'
complete -c chafa -l 'dither' -x -a 'none ordered diffusion' -d 'Set output dither mode'
complete -c chafa -l 'dither' -x -a 'none ordered diffusion noise' -d 'Set output dither mode'
complete -c chafa -l 'dither-grain' -x -d 'Set dimentions of dither grains in 1/8ths of a character cell'
complete -c chafa -l 'dither-intensity' -x -d 'Multiplier for dither intensity [0.0 - inf]'
complete -c chafa -l 'fg' -x -d 'Foreground color of display (color name or hex)'
Expand Down
2 changes: 1 addition & 1 deletion tools/completions/zsh-completion.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ local options=(
{-c,--colors}"[Set output color mode. Defaults to best guess]:MODE:(none 2 8 16/8 16 240 256 full)"
--color-extractor"[Method for extracting color from an area. Average is the default]:EXTR:(average median)"
--color-space"[Color space used for quantization. Defaults to rgb, which is faster but less accurate]:CS:(rgb din99d)"
--dither"[Set output dither mode. No effect with 24-bit color. Defaults to none]:DITHER:(none ordered diffusion)"
--dither"[Set output dither mode. No effect with 24-bit color. Defaults to none]:DITHER:(none ordered diffusion noise)"
--dither-grain"[Set dimensions of dither grains in 1/8ths of a character cell. Defaults to 4x4]:WxH:(1 2 4 8)"
--dither-intensity"[Multiplier for dither intensity. Defaults to 1.0]:NUM 0.0 - inf"
{-d,--duration}"[The time to show each file]:SECONDS"
Expand Down