diff options
author | Christian Duerr <chrisduerr@users.noreply.github.com> | 2018-03-07 21:34:05 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-03-07 21:34:05 +0000 |
commit | f298ebb2179eff947cdb9cb7a4bd96e9739eac5c (patch) | |
tree | 16500c7f17e68d91a39b5908f327d7aac752401a /alacritty-completions.bash | |
parent | 7f2b398ad2084bdaaa266e8da770a213f0a9a2eb (diff) | |
download | alacritty-f298ebb2179eff947cdb9cb7a4bd96e9739eac5c.tar.gz alacritty-f298ebb2179eff947cdb9cb7a4bd96e9739eac5c.zip |
Add shell completions and manpage
* Add manpage
Adds a basic manpage that was autogenerated with `help2man` and then
slightly adjusted with information from the README.md and better
formatting.
* Add zsh completions
Add completions for the zsh shell. These should be complete and even
allow completion of the command inside `--command` and `-e`.
* Add bash completions
The bash completions are almost on the same level as the zsh
completions. The only little thing the bash completions do not do is
complete inside of `--command` and `-e`, instead bash just stops
completion after these options.
* Update readme with manpage and completions
Added the install instructions for the manpage and completions to the
README.md.
Also tweaked the current readme a slight bit because the build section
was structured in a slightly confusing way.
Diffstat (limited to 'alacritty-completions.bash')
-rw-r--r-- | alacritty-completions.bash | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/alacritty-completions.bash b/alacritty-completions.bash new file mode 100644 index 00000000..57191515 --- /dev/null +++ b/alacritty-completions.bash @@ -0,0 +1,58 @@ +#/usr/bin/env bash + +# Load completion function +complete -F _alacritty alacritty + +# Completion function +_alacritty() +{ + local cur prev prevprev opts + COMPREPLY=() + cur="${COMP_WORDS[COMP_CWORD]}" + prev="${COMP_WORDS[COMP_CWORD-1]}" + prevprev="${COMP_WORDS[COMP_CWORD-2]}" + opts="-h --help -V --version --live-config-reload --no-live-config-reload --print-events -q -qq -v -vv -vvv --ref-test -e --command --config-file -d --dimensions -t --title --working-directory" + + # If `--command` or `-e` is used, stop completing + for i in "${!COMP_WORDS[@]}"; do + echo "${COMP_WORDS[i]}" >> ./testfile + if [[ "${COMP_WORDS[i]}" == "--command" ]] \ + || [[ "${COMP_WORDS[i]}" == "-e" ]] \ + && [[ "${#COMP_WORDS[@]}" -gt "$(($i + 2))" ]] + then + return 0 + fi + done + + # Make sure the Y dimension isn't completed + if [[ "${prevprev}" == "--dimensions" ]] || [[ "${prevprev}" == "-d" ]]; then + return 0 + fi + + # Match the previous word + case "${prev}" in + --command | -e) + # Complete all commands in $PATH + COMPREPLY=( $(compgen -c -- "${cur}") ) + return 0;; + --config-file) + # Path based completion + local IFS=$'\n' + compopt -o filenames + COMPREPLY=( $(compgen -f -- "${cur}") ) + return 0;; + --dimensions | -d | --title | -t) + # Don't complete here + return 0;; + --working-directory) + # Directory completion + local IFS=$'\n' + compopt -o filenames + COMPREPLY=( $(compgen -d -- "${cur}") ) + return 0;; + esac + + # Show all flags if there was no previous word + COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") ) + return 0 +} |