diff options
author | Henil Dedania <dedaniahenil@gmail.com> | 2021-01-07 15:14:28 +0530 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-01-07 15:14:28 +0530 |
commit | 0994c8abcd0f522362532ecbaa4900915d1c42f9 (patch) | |
tree | 297b3e1f1b6a7b4fd70aa57d76720df148f625c2 /assets | |
parent | 610545f54aad4a1d1a8c03de1cdb5a7debd92ea5 (diff) |
feat(completions): Add shell completions files (#128)
* Add shell completions and output files to `assets/completions`
* Rename files and struct name
* Update tests to take into account new changes
Diffstat (limited to 'assets')
-rw-r--r-- | assets/completions/_mosaic | 45 | ||||
-rw-r--r-- | assets/completions/mosaic.bash | 69 | ||||
-rw-r--r-- | assets/completions/mosaic.fish | 8 |
3 files changed, 122 insertions, 0 deletions
diff --git a/assets/completions/_mosaic b/assets/completions/_mosaic new file mode 100644 index 000000000..9587c2bf8 --- /dev/null +++ b/assets/completions/_mosaic @@ -0,0 +1,45 @@ +#compdef mosaic + +autoload -U is-at-least + +_mosaic() { + 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[@]}" \ +'-s+[Send "split (direction h == horizontal / v == vertical)" to active mosaic session]' \ +'--split=[Send "split (direction h == horizontal / v == vertical)" to active mosaic session]' \ +'-o+[Send "open file in new pane" to active mosaic session]' \ +'--open-file=[Send "open file in new pane" to active mosaic session]' \ +'--max-panes=[Maximum panes on screen, caution: opening more panes will close old ones]' \ +'-l+[Path to a layout yaml file]' \ +'--layout=[Path to a layout yaml file]' \ +'-m[Send "move focused pane" to active mosaic session]' \ +'--move-focus[Send "move focused pane" to active mosaic session]' \ +'-d[]' \ +'--debug[]' \ +'-h[Prints help information]' \ +'--help[Prints help information]' \ +'-V[Prints version information]' \ +'--version[Prints version information]' \ +&& ret=0 + +} + +(( $+functions[_mosaic_commands] )) || +_mosaic_commands() { + local commands; commands=( + + ) + _describe -t commands 'mosaic commands' commands "$@" +} + +_mosaic "$@"
\ No newline at end of file diff --git a/assets/completions/mosaic.bash b/assets/completions/mosaic.bash new file mode 100644 index 000000000..7b6219c0b --- /dev/null +++ b/assets/completions/mosaic.bash @@ -0,0 +1,69 @@ +_mosaic() { + local i cur prev opts cmds + COMPREPLY=() + cur="${COMP_WORDS[COMP_CWORD]}" + prev="${COMP_WORDS[COMP_CWORD-1]}" + cmd="" + opts="" + + for i in ${COMP_WORDS[@]} + do + case "${i}" in + mosaic) + cmd="mosaic" + ;; + + *) + ;; + esac + done + + case "${cmd}" in + mosaic) + opts=" -m -d -h -V -s -o -l --move-focus --debug --help --version --split --open-file --max-panes --layout " + if [[ ${cur} == -* || ${COMP_CWORD} -eq 1 ]] ; then + COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") ) + return 0 + fi + case "${prev}" in + + --split) + COMPREPLY=($(compgen -f "${cur}")) + return 0 + ;; + -s) + COMPREPLY=($(compgen -f "${cur}")) + return 0 + ;; + --open-file) + COMPREPLY=($(compgen -f "${cur}")) + return 0 + ;; + -o) + COMPREPLY=($(compgen -f "${cur}")) + return 0 + ;; + --max-panes) + COMPREPLY=($(compgen -f "${cur}")) + return 0 + ;; + --layout) + COMPREPLY=($(compgen -f "${cur}")) + return 0 + ;; + -l) + COMPREPLY=($(compgen -f "${cur}")) + return 0 + ;; + *) + COMPREPLY=() + ;; + esac + COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") ) + return 0 + ;; + + esac +} + +complete -F _mosaic -o bashdefault -o default mosaic diff --git a/assets/completions/mosaic.fish b/assets/completions/mosaic.fish new file mode 100644 index 000000000..925d6432e --- /dev/null +++ b/assets/completions/mosaic.fish @@ -0,0 +1,8 @@ +complete -c mosaic -n "__fish_use_subcommand" -s s -l split -d 'Send "split (direction h == horizontal / v == vertical)" to active mosaic session' +complete -c mosaic -n "__fish_use_subcommand" -s o -l open-file -d 'Send "open file in new pane" to active mosaic session' +complete -c mosaic -n "__fish_use_subcommand" -l max-panes -d 'Maximum panes on screen, caution: opening more panes will close old ones' +complete -c mosaic -n "__fish_use_subcommand" -s l -l layout -d 'Path to a layout yaml file' +complete -c mosaic -n "__fish_use_subcommand" -s m -l move-focus -d 'Send "move focused pane" to active mosaic session' +complete -c mosaic -n "__fish_use_subcommand" -s d -l debug +complete -c mosaic -n "__fish_use_subcommand" -s h -l help -d 'Prints help information' +complete -c mosaic -n "__fish_use_subcommand" -s V -l version -d 'Prints version information' |