add some completion scripts

This commit is contained in:
Daylin Morgan 2022-04-13 00:53:34 -05:00
parent 692fcd71a9
commit 6080ff7531
6 changed files with 586 additions and 4 deletions

154
system/completions/_just Normal file
View file

@ -0,0 +1,154 @@
#compdef just
autoload -U is-at-least
_just() {
typeset -A opt_args
typeset -a _arguments_options
local ret=1
if is-at-least 5.2; then
_arguments_options=(-s -S -C)
else
_arguments_options=(-s -C)
fi
local context curcontext="$curcontext" state line
local common=(
'--chooser=[Override binary invoked by `--choose`]' \
'--color=[Print colorful output]: :(auto always never)' \
'--dump-format=[Dump justfile as <FORMAT>]: :(just json)' \
'--list-heading=[Print <TEXT> before list]' \
'--list-prefix=[Print <TEXT> before each list item]' \
'-f+[Use <JUSTFILE> as justfile]' \
'--justfile=[Use <JUSTFILE> as justfile]' \
'*--set[Override <VARIABLE> with <VALUE>]: :_just_variables' \
'--shell=[Invoke <SHELL> to run recipes]' \
'*--shell-arg=[Invoke shell with <SHELL-ARG> as an argument]' \
'-d+[Use <WORKING-DIRECTORY> as working directory. --justfile must also be set]' \
'--working-directory=[Use <WORKING-DIRECTORY> as working directory. --justfile must also be set]' \
'-c+[Run an arbitrary command with the working directory, `.env`, overrides, and exports set]' \
'--command=[Run an arbitrary command with the working directory, `.env`, overrides, and exports set]' \
'--completions=[Print shell completion script for <SHELL>]: :(zsh bash fish powershell elvish)' \
'-s+[Show information about <RECIPE>]: :_just_commands' \
'--show=[Show information about <RECIPE>]: :_just_commands' \
'(--dotenv-path)--dotenv-filename=[Search for environment file named <DOTENV-FILENAME> instead of `.env`]' \
'--dotenv-path=[Load environment file at <DOTENV-PATH> instead of searching for one]' \
'--check[Run `--fmt` in '\''check'\'' mode. Exits with 0 if justfile is formatted correctly. Exits with 1 and prints a diff if formatting is required.]' \
'(-q --quiet)--dry-run[Print what just would do without doing it]' \
'--highlight[Highlight echoed recipe lines in bold]' \
'--no-dotenv[Don'\''t load `.env` file]' \
'--no-highlight[Don'\''t highlight echoed recipe lines in bold]' \
'(--dry-run)-q[Suppress all output]' \
'(--dry-run)--quiet[Suppress all output]' \
'--shell-command[Invoke <COMMAND> with the shell used to run recipe lines and backticks]' \
'--clear-shell-args[Clear shell arguments]' \
'-u[Return list and summary entries in source order]' \
'--unsorted[Return list and summary entries in source order]' \
'--unstable[Enable unstable features]' \
'*-v[Use verbose output]' \
'*--verbose[Use verbose output]' \
'--changelog[Print changelog]' \
'--choose[Select one or more recipes to run using a binary. If `--chooser` is not passed the chooser defaults to the value of $JUST_CHOOSER, falling back to `fzf`]' \
'--dump[Print justfile]' \
'-e[Edit justfile with editor given by $VISUAL or $EDITOR, falling back to `vim`]' \
'--edit[Edit justfile with editor given by $VISUAL or $EDITOR, falling back to `vim`]' \
'--evaluate[Evaluate and print all variables. If a variable name is given as an argument, only print that variable'\''s value.]' \
'--fmt[Format and overwrite justfile]' \
'--init[Initialize new justfile in project root]' \
'-l[List available recipes and their arguments]' \
'--list[List available recipes and their arguments]' \
'--summary[List names of available recipes]' \
'--variables[List names of variables]' \
'-h[Print help information]' \
'--help[Print help information]' \
'-V[Print version information]' \
'--version[Print version information]' \
)
_arguments "${_arguments_options[@]}" $common \
'1: :_just_commands' \
'*: :->args' \
&& ret=0
case $state in
args)
curcontext="${curcontext%:*}-${words[2]}:"
local lastarg=${words[${#words}]}
local recipe
local cmds; cmds=(
${(s: :)$(_call_program commands just --summary)}
)
# Find first recipe name
for ((i = 2; i < $#words; i++ )) do
if [[ ${cmds[(I)${words[i]}]} -gt 0 ]]; then
recipe=${words[i]}
break
fi
done
if [[ $lastarg = */* ]]; then
# Arguments contain slash would be recognised as a file
_arguments -s -S $common '*:: :_files'
elif [[ $lastarg = *=* ]]; then
# Arguments contain equal would be recognised as a variable
_message "value"
elif [[ $recipe ]]; then
# Show usage message
_message "`just --show $recipe`"
# Or complete with other commands
#_arguments -s -S $common '*:: :_just_commands'
else
_arguments -s -S $common '*:: :_just_commands'
fi
;;
esac
return ret
}
(( $+functions[_just_commands] )) ||
_just_commands() {
[[ $PREFIX = -* ]] && return 1
integer ret=1
local variables; variables=(
${(s: :)$(_call_program commands just --variables)}
)
local commands; commands=(
${${${(M)"${(f)$(_call_program commands just --list)}":# *}/ ##/}/ ##/:Args: }
)
if compset -P '*='; then
case "${${words[-1]%=*}#*=}" in
*) _message 'value' && ret=0 ;;
esac
else
_describe -t variables 'variables' variables -qS "=" && ret=0
_describe -t commands 'just commands' commands "$@"
fi
}
(( $+functions[_just_variables] )) ||
_just_variables() {
[[ $PREFIX = -* ]] && return 1
integer ret=1
local variables; variables=(
${(s: :)$(_call_program commands just --variables)}
)
if compset -P '*='; then
case "${${words[-1]%=*}#*=}" in
*) _message 'value' && ret=0 ;;
esac
else
_describe -t variables 'variables' variables && ret=0
fi
return ret
}
_just "$@"

0
system/completions/_pdm Normal file
View file

172
system/completions/_sheldon Normal file
View file

@ -0,0 +1,172 @@
#compdef sheldon
autoload -U is-at-least
_sheldon() {
typeset -A opt_args
typeset -a _arguments_options
local ret=1
if is-at-least 5.2; then
_arguments_options=(-s -S -C)
else
_arguments_options=(-s -C)
fi
local context curcontext="$curcontext" state line
_arguments "${_arguments_options[@]}" \
'--color=[Output coloring: always, auto, or never]:WHEN: ' \
'--home=[The home directory]:PATH: ' \
'--config-dir=[The configuration directory]:PATH: ' \
'--data-dir=[The data directory]:PATH: ' \
'--config-file=[The config file]:PATH: ' \
'--lock-file=[The lock file]:PATH: ' \
'--clone-dir=[The directory where git sources are cloned to]:PATH: ' \
'--download-dir=[The directory where remote sources are downloaded to]:PATH: ' \
'-h[Print help information]' \
'--help[Print help information]' \
'-V[Print version information]' \
'--version[Print version information]' \
'-q[Suppress any informational output]' \
'--quiet[Suppress any informational output]' \
'-v[Use verbose output]' \
'--verbose[Use verbose output]' \
":: :_sheldon_commands" \
"*::: :->sheldon" \
&& ret=0
case $state in
(sheldon)
words=($line[1] "${words[@]}")
(( CURRENT += 1 ))
curcontext="${curcontext%:*:*}:sheldon-command-$line[1]:"
case $line[1] in
(init)
_arguments "${_arguments_options[@]}" \
'--shell=[The type of shell, accepted values are: bash, zsh]:SHELL: ' \
'-h[Print help information]' \
'--help[Print help information]' \
&& ret=0
;;
(add)
_arguments "${_arguments_options[@]}" \
'--git=[Add a clonable Git repository]:URL: ' \
'--gist=[Add a clonable Gist snippet]:ID: ' \
'--github=[Add a clonable GitHub repository]:REPO: ' \
'--remote=[Add a downloadable file]:URL: ' \
'--local=[Add a local directory]:DIR: ' \
'(--git --remote --local)--proto=[The Git protocol for a Gist or GitHub plugin]:PROTO: ' \
'--branch=[Checkout the tip of a branch]:BRANCH: ' \
'--rev=[Checkout a specific commit]:SHA: ' \
'--tag=[Checkout a specific tag]:TAG: ' \
'--dir=[Which sub directory to use in this plugin]:PATH: ' \
'*--use=[Which files to use in this plugin]:MATCH: ' \
'*--apply=[Templates to apply to this plugin]:TEMPLATE: ' \
'-h[Print help information]' \
'--help[Print help information]' \
':name -- A unique name for this plugin:' \
&& ret=0
;;
(edit)
_arguments "${_arguments_options[@]}" \
'-h[Print help information]' \
'--help[Print help information]' \
&& ret=0
;;
(remove)
_arguments "${_arguments_options[@]}" \
'-h[Print help information]' \
'--help[Print help information]' \
':name -- A unique name for this plugin:' \
&& ret=0
;;
(lock)
_arguments "${_arguments_options[@]}" \
'--update[Update all plugin sources]' \
'(--update)--reinstall[Reinstall all plugin sources]' \
'-h[Print help information]' \
'--help[Print help information]' \
&& ret=0
;;
(source)
_arguments "${_arguments_options[@]}" \
'--relock[Regenerate the lock file]' \
'--update[Update all plugin sources (implies --relock)]' \
'(--update)--reinstall[Reinstall all plugin sources (implies --relock)]' \
'-h[Print help information]' \
'--help[Print help information]' \
&& ret=0
;;
(completions)
_arguments "${_arguments_options[@]}" \
'--shell=[The type of shell, accepted values are: bash, zsh]:SHELL: ' \
'-h[Print help information]' \
'--help[Print help information]' \
&& ret=0
;;
(version)
_arguments "${_arguments_options[@]}" \
'-h[Print help information]' \
'--help[Print help information]' \
&& ret=0
;;
esac
;;
esac
}
(( $+functions[_sheldon_commands] )) ||
_sheldon_commands() {
local commands; commands=(
'init:Initialize a new config file' \
'add:Add a new plugin to the config file' \
'edit:Open up the config file in the default editor' \
'remove:Remove a plugin from the config file' \
'lock:Install the plugins sources and generate the lock file' \
'source:Generate and print out the script' \
'completions:Generate completions for the given shell' \
'version:Prints detailed version information' \
)
_describe -t commands 'sheldon commands' commands "$@"
}
(( $+functions[_sheldon__add_commands] )) ||
_sheldon__add_commands() {
local commands; commands=()
_describe -t commands 'sheldon add commands' commands "$@"
}
(( $+functions[_sheldon__completions_commands] )) ||
_sheldon__completions_commands() {
local commands; commands=()
_describe -t commands 'sheldon completions commands' commands "$@"
}
(( $+functions[_sheldon__edit_commands] )) ||
_sheldon__edit_commands() {
local commands; commands=()
_describe -t commands 'sheldon edit commands' commands "$@"
}
(( $+functions[_sheldon__init_commands] )) ||
_sheldon__init_commands() {
local commands; commands=()
_describe -t commands 'sheldon init commands' commands "$@"
}
(( $+functions[_sheldon__lock_commands] )) ||
_sheldon__lock_commands() {
local commands; commands=()
_describe -t commands 'sheldon lock commands' commands "$@"
}
(( $+functions[_sheldon__remove_commands] )) ||
_sheldon__remove_commands() {
local commands; commands=()
_describe -t commands 'sheldon remove commands' commands "$@"
}
(( $+functions[_sheldon__source_commands] )) ||
_sheldon__source_commands() {
local commands; commands=()
_describe -t commands 'sheldon source commands' commands "$@"
}
(( $+functions[_sheldon__version_commands] )) ||
_sheldon__version_commands() {
local commands; commands=()
_describe -t commands 'sheldon version commands' commands "$@"
}
_sheldon "$@"

241
system/completions/_zellij Normal file
View file

@ -0,0 +1,241 @@
#compdef zellij
autoload -U is-at-least
_zellij() {
typeset -A opt_args
typeset -a _arguments_options
local ret=1
if is-at-least 5.2; then
_arguments_options=(-s -S -C)
else
_arguments_options=(-s -C)
fi
local context curcontext="$curcontext" state line
_arguments "${_arguments_options[@]}" \
'--max-panes=[Maximum panes on screen, caution: opening more panes will close old ones]:MAX_PANES: ' \
'--data-dir=[Change where zellij looks for layouts and plugins]:DATA_DIR: ' \
'--server=[Run server listening at the specified socket path]:SERVER: ' \
'-s+[Specify name of a new session]:SESSION: ' \
'--session=[Specify name of a new session]:SESSION: ' \
'-l+[Name of a layout file in the layout directory]:LAYOUT: ' \
'--layout=[Name of a layout file in the layout directory]:LAYOUT: ' \
'--layout-path=[Path to a layout yaml file]:LAYOUT_PATH: ' \
'-c+[Change where zellij looks for the configuration file]:CONFIG: ' \
'--config=[Change where zellij looks for the configuration file]:CONFIG: ' \
'--config-dir=[Change where zellij looks for the configuration directory]:CONFIG_DIR: ' \
'-h[Print help information]' \
'--help[Print help information]' \
'-V[Print version information]' \
'--version[Print version information]' \
'-d[]' \
'--debug[]' \
":: :_zellij_commands" \
"*::: :->zellij" \
&& ret=0
case $state in
(zellij)
words=($line[1] "${words[@]}")
(( CURRENT += 1 ))
curcontext="${curcontext%:*:*}:zellij-command-$line[1]:"
case $line[1] in
(options)
_arguments "${_arguments_options[@]}" \
'--simplified-ui=[Allow plugins to use a more simplified layout that is compatible with more fonts (true or false)]:SIMPLIFIED_UI: ' \
'--theme=[Set the default theme]:THEME: ' \
'--default-mode=[Set the default mode]:DEFAULT_MODE:((normal\:"In `Normal` mode, input is always written to the terminal, except for the shortcuts leading to other modes"
locked\:"In `Locked` mode, input is always written to the terminal and all shortcuts are disabled except the one leading back to normal mode"
resize\:"`Resize` mode allows resizing the different existing panes"
pane\:"`Pane` mode allows creating and closing panes, as well as moving between them"
tab\:"`Tab` mode allows creating and closing tabs, as well as moving between them"
scroll\:"`Scroll` mode allows scrolling up and down within a pane"
rename-tab\:"`RenameTab` mode allows assigning a new name to a tab"
rename-pane\:"`RenamePane` mode allows assigning a new name to a pane"
session\:"`Session` mode allows detaching sessions"
move\:"`Move` mode allows moving the different existing panes within a tab"
prompt\:"`Prompt` mode allows interacting with active prompts"
tmux\:"`Tmux` mode allows for basic tmux keybindings functionality"))' \
'--default-shell=[Set the default shell]:DEFAULT_SHELL: ' \
'--layout-dir=[Set the layout_dir, defaults to subdirectory of config dir]:LAYOUT_DIR: ' \
'--mouse-mode=[Set the handling of mouse events (true or false) Can be temporarily bypassed by the \[SHIFT\] key]:MOUSE_MODE: ' \
'--pane-frames=[Set display of the pane frames (true or false)]:PANE_FRAMES: ' \
'--mirror-session=[Mirror session when multiple users are connected (true or false)]:MIRROR_SESSION: ' \
'--on-force-close=[Set behaviour on force close (quit or detach)]:ON_FORCE_CLOSE:(quit detach)' \
'--scroll-buffer-size=[]:SCROLL_BUFFER_SIZE: ' \
'--copy-command=[Switch to using a user supplied command for clipboard instead of OSC52]:COPY_COMMAND: ' \
'(--copy-command)--copy-clipboard=[OSC52 destination clipboard]:COPY_CLIPBOARD:(system primary)' \
'(--mouse-mode)--disable-mouse-mode[Disable handling of mouse events]' \
'(--pane-frames)--no-pane-frames[Disable display of pane frames]' \
'-h[Print help information]' \
'--help[Print help information]' \
&& ret=0
;;
(setup)
_arguments "${_arguments_options[@]}" \
'--dump-layout=[Dump the specified layout file to stdout]:DUMP_LAYOUT: ' \
'--generate-completion=[Generates completion for the specified shell]:SHELL: ' \
'--dump-config[Dump the default configuration file to stdout]' \
'--clean[Disables loading of configuration file at default location, loads the defaults that zellij ships with]' \
'--check[Checks the configuration of zellij and displays currently used directories]' \
'-h[Print help information]' \
'--help[Print help information]' \
&& ret=0
;;
(list-sessions)
_arguments "${_arguments_options[@]}" \
'-h[Print help information]' \
'--help[Print help information]' \
&& ret=0
;;
(attach)
_arguments "${_arguments_options[@]}" \
'--index=[Number of the session index in the active sessions ordered creation date]:INDEX: ' \
'-c[Create a session if one does not exist]' \
'--create[Create a session if one does not exist]' \
'-h[Print help information]' \
'--help[Print help information]' \
'::session-name -- Name of the session to attach to:' \
":: :_zellij__attach_commands" \
"*::: :->attach" \
&& ret=0
case $state in
(attach)
words=($line[2] "${words[@]}")
(( CURRENT += 1 ))
curcontext="${curcontext%:*:*}:zellij-attach-command-$line[2]:"
case $line[2] in
(options)
_arguments "${_arguments_options[@]}" \
'--simplified-ui=[Allow plugins to use a more simplified layout that is compatible with more fonts (true or false)]:SIMPLIFIED_UI: ' \
'--theme=[Set the default theme]:THEME: ' \
'--default-mode=[Set the default mode]:DEFAULT_MODE:((normal\:"In `Normal` mode, input is always written to the terminal, except for the shortcuts leading to other modes"
locked\:"In `Locked` mode, input is always written to the terminal and all shortcuts are disabled except the one leading back to normal mode"
resize\:"`Resize` mode allows resizing the different existing panes"
pane\:"`Pane` mode allows creating and closing panes, as well as moving between them"
tab\:"`Tab` mode allows creating and closing tabs, as well as moving between them"
scroll\:"`Scroll` mode allows scrolling up and down within a pane"
rename-tab\:"`RenameTab` mode allows assigning a new name to a tab"
rename-pane\:"`RenamePane` mode allows assigning a new name to a pane"
session\:"`Session` mode allows detaching sessions"
move\:"`Move` mode allows moving the different existing panes within a tab"
prompt\:"`Prompt` mode allows interacting with active prompts"
tmux\:"`Tmux` mode allows for basic tmux keybindings functionality"))' \
'--default-shell=[Set the default shell]:DEFAULT_SHELL: ' \
'--layout-dir=[Set the layout_dir, defaults to subdirectory of config dir]:LAYOUT_DIR: ' \
'--mouse-mode=[Set the handling of mouse events (true or false) Can be temporarily bypassed by the \[SHIFT\] key]:MOUSE_MODE: ' \
'--pane-frames=[Set display of the pane frames (true or false)]:PANE_FRAMES: ' \
'--mirror-session=[Mirror session when multiple users are connected (true or false)]:MIRROR_SESSION: ' \
'--on-force-close=[Set behaviour on force close (quit or detach)]:ON_FORCE_CLOSE:(quit detach)' \
'--scroll-buffer-size=[]:SCROLL_BUFFER_SIZE: ' \
'--copy-command=[Switch to using a user supplied command for clipboard instead of OSC52]:COPY_COMMAND: ' \
'(--copy-command)--copy-clipboard=[OSC52 destination clipboard]:COPY_CLIPBOARD:(system primary)' \
'--version[Print version information]' \
'(--mouse-mode)--disable-mouse-mode[Disable handling of mouse events]' \
'(--pane-frames)--no-pane-frames[Disable display of pane frames]' \
'-h[Print help information]' \
'--help[Print help information]' \
&& ret=0
;;
(help)
_arguments "${_arguments_options[@]}" \
'--version[Print version information]' \
'-h[Print help information]' \
'--help[Print help information]' \
'*::subcommand -- The subcommand whose help message to display:' \
&& ret=0
;;
esac
;;
esac
;;
(kill-session)
_arguments "${_arguments_options[@]}" \
'-h[Print help information]' \
'--help[Print help information]' \
'::target-session -- Name of target session:' \
&& ret=0
;;
(kill-all-sessions)
_arguments "${_arguments_options[@]}" \
'-y[Automatic yes to prompts]' \
'--yes[Automatic yes to prompts]' \
'-h[Print help information]' \
'--help[Print help information]' \
&& ret=0
;;
(help)
_arguments "${_arguments_options[@]}" \
'*::subcommand -- The subcommand whose help message to display:' \
&& ret=0
;;
esac
;;
esac
}
(( $+functions[_zellij_commands] )) ||
_zellij_commands() {
local commands; commands=(
'options:Change the behaviour of zellij' \
'setup:Setup zellij and check its configuration' \
'list-sessions:List active sessions' \
'attach:Attach to session' \
'kill-session:Kill the specific session' \
'kill-all-sessions:Kill all sessions' \
'help:Print this message or the help of the given subcommand(s)' \
)
_describe -t commands 'zellij commands' commands "$@"
}
(( $+functions[_zellij__attach_commands] )) ||
_zellij__attach_commands() {
local commands; commands=(
'options:Change the behaviour of zellij' \
'help:Print this message or the help of the given subcommand(s)' \
)
_describe -t commands 'zellij attach commands' commands "$@"
}
(( $+functions[_zellij__attach__help_commands] )) ||
_zellij__attach__help_commands() {
local commands; commands=()
_describe -t commands 'zellij attach help commands' commands "$@"
}
(( $+functions[_zellij__help_commands] )) ||
_zellij__help_commands() {
local commands; commands=()
_describe -t commands 'zellij help commands' commands "$@"
}
(( $+functions[_zellij__kill-all-sessions_commands] )) ||
_zellij__kill-all-sessions_commands() {
local commands; commands=()
_describe -t commands 'zellij kill-all-sessions commands' commands "$@"
}
(( $+functions[_zellij__kill-session_commands] )) ||
_zellij__kill-session_commands() {
local commands; commands=()
_describe -t commands 'zellij kill-session commands' commands "$@"
}
(( $+functions[_zellij__list-sessions_commands] )) ||
_zellij__list-sessions_commands() {
local commands; commands=()
_describe -t commands 'zellij list-sessions commands' commands "$@"
}
(( $+functions[_zellij__attach__options_commands] )) ||
_zellij__attach__options_commands() {
local commands; commands=()
_describe -t commands 'zellij attach options commands' commands "$@"
}
(( $+functions[_zellij__options_commands] )) ||
_zellij__options_commands() {
local commands; commands=()
_describe -t commands 'zellij options commands' commands "$@"
}
(( $+functions[_zellij__setup_commands] )) ||
_zellij__setup_commands() {
local commands; commands=()
_describe -t commands 'zellij setup commands' commands "$@"
}
_zellij "$@"

16
system/completions/update.sh Executable file
View file

@ -0,0 +1,16 @@
#!/usr/bin/env zsh
gen() {
if is-executable $1;then
echo "$1 updated"
"$@" > "_$argv[1]"
else;
echo "skipping $1"
fi
}
echo "GENERATING COMPLETION SCRIPTS"
echo "-----------------------------"
gen sheldon completions --shell zsh
gen just --completions zsh
gen zellij setup --generate-completion zsh

View file

@ -10,6 +10,9 @@ export SAVEHIST=4096
export HISTCONTROL=ignoredups:erasedups
export LESS='-R'
# add completions to fpath
fpath=($DOTFILES_DIR/system/completions $fpath)
# Append to the history file, rather than overwriting it
setopt APPEND_HISTORY
@ -49,10 +52,6 @@ if is-executable lf; then
fi
# ----------------
# nvm settings
#export NVM_DIR="$HOME/.nvm"
#[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm
#[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion
if is-executable fnm; then
eval "$(fnm env)"
fi