Created
April 18, 2019 17:51
-
-
Save samtay/30397d6894c707a315a6c16e3fca77e9 to your computer and use it in GitHub Desktop.
Forward `stack ghci` completions to `ghcid -c 'stack ghci...'`
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
stack-ghcid() | |
{ | |
ghcid -c 'stack ghci '"$@"'' | |
} | |
_stack-ghcid() | |
{ | |
local CMDLINE | |
local IFS=$'\n' | |
export COMP_LINE="${COMP_LINE/stack-ghcid/'stack ghci'}" | |
export COMP_POINT=$(($COMP_POINT - 1)) | |
export COMP_WORDS=("stack" "ghci" "${COMP_WORDS[@]:1}" ) | |
export COMP_CWORD=$(($COMP_CWORD + 1)) | |
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-ghcid stack-ghcid |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment