mirror of
https://github.com/janet-lang/janet
synced 2026-06-11 23:49:09 +00:00
2814fc53c2
Adds completion scripts for the janet interpreter covering all flags documented in the man page: -h -v -s -e -E -d -n -N -r -R -p -q -k -i -m -c -l -w -x --. Flag-aware completions: -m completes directories, -c/-l complete .janet files, -w/-x complete linting levels. Closes #1567
43 lines
1.0 KiB
Bash
43 lines
1.0 KiB
Bash
# Bash completion for janet
|
|
# Install: source this file, or place it in /etc/bash_completion.d/janet
|
|
# or ~/.local/share/bash-completion/completions/janet
|
|
|
|
_janet() {
|
|
local cur prev words cword
|
|
_init_completion || return
|
|
|
|
local flags="-h -v -s -e -E -d -n -N -r -R -p -q -k -m -c -i -l -w -x --"
|
|
|
|
case "$prev" in
|
|
-e|-E)
|
|
# Argument is Janet source code — no file completion
|
|
return
|
|
;;
|
|
-m)
|
|
# syspath: complete directories
|
|
_filedir -d
|
|
return
|
|
;;
|
|
-c|-l)
|
|
# source file: complete .janet files
|
|
_filedir janet
|
|
return
|
|
;;
|
|
-w|-x)
|
|
# linting level
|
|
COMPREPLY=($(compgen -W ":none :relaxed :normal :strict" -- "$cur"))
|
|
return
|
|
;;
|
|
esac
|
|
|
|
if [[ "$cur" == -* ]]; then
|
|
COMPREPLY=($(compgen -W "$flags" -- "$cur"))
|
|
return
|
|
fi
|
|
|
|
# Default: complete .janet files and directories
|
|
_filedir janet
|
|
}
|
|
|
|
complete -F _janet janet
|