1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70
|
<div class="hidden-warning"><a href="https://docs.haskellstack.org/"><img src="https://cdn.jsdelivr.net/gh/commercialhaskell/stack/doc/img/hidden-warning.svg"></a></div>
# Shell auto-completion
The following adds support for the tab completion of standard Stack arguments to
the following shell programs: Bash, Zsh (the Z shell) and fish. Completion of
file names and executables within Stack is still lacking. For further
information, see issue
[#823](https://github.com/commercialhaskell/stack/issues/832).
!!! info
Stack's completion library provides
[hidden options](https://github.com/pcapriotti/optparse-applicative#bash-zsh-and-fish-completions)
for Bash, Zsh, and fish which output commands used for shell
auto-completion. For example:
~~~bash
$ stack --bash-completion-script stack
_stack()
{
local CMDLINE
local IFS=$'\n'
CMDLINE=(--bash-completion-index $COMP_CWORD)
for arg in ${COMP_WORDS[@]}; do
CMDLINE=(${CMDLINE[@]} --bash-completion-word $arg)
done
COMPREPLY=( $(stack "${CMDLINE[@]}") )
}
complete -o filenames -F _stack stack
~~~
=== "Bash"
Add the output of the following command to your preferred completions file
(e.g. `~/.config/bash_completions.d/stack`).
~~~bash
stack --bash-completion-script $(which stack)
~~~
You may need to `source` this.
=== "Zsh"
Add the output of the following command to your preferred completions file
(e.g. `~/.config/zsh/completions/_stack`).
~~~zsh
stack --zsh-completion-script $(which stack)
~~~
You won't need to `source` this, but do update your `fpath`:
~~~zsh
fpath=($HOME/.config/zsh/completions $fpath)
autoload -U compinit && compinit
~~~
=== "fish"
Add the output of the following command to your preferred completions file
(e.g. `~/.config/fish/completions/stack.fish`).
~~~fish
stack --fish-completion-script $(which stack)
~~~
|