Created
February 24, 2018 10:54
-
-
Save rmunn/49871011ac2eab6c3f10e5fa5abc52d9 to your computer and use it in GitHub Desktop.
Bash completion file for FAKE build scripts (build.fsx)
This file contains 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
# bash completion for FAKE build.sh scripts | |
# Assumes that your FAKE build script is named build.fsx | |
# Put this file in /etc/bash_completion.d/ and start a new terminal to activate it | |
_build_sh() | |
{ | |
local cur base dir | |
cur="${COMP_WORDS[COMP_CWORD]}" | |
base="${COMP_WORDS[0]}" | |
dir=$(dirname "${base}") | |
if [ -e "${dir}/build.fsx" ]; then | |
BUILD_FSX="${dir}/build.fsx" | |
elif [ -e "${dir}/build/build.fsx" ]; then | |
BUILD_FSX="${dir}/build/build.fsx" | |
elif [ -e "${dir}/Build/build.fsx" ]; then | |
BUILD_FSX="${dir}/Build/build.fsx" | |
else | |
BUILD_FSX=$(find ${dir} -name build.fsx) | |
fi | |
if [ -z "${BUILD_FSX}" ]; then | |
COMPREPLY=() | |
else | |
OLDIFS="$IFS" | |
IFS=$'\n' | |
RESULTS=$(grep -o 'Target ".*"' "${BUILD_FSX}" | cut -d'"' -f2) | |
COMPREPLY=($(compgen -W "${RESULTS}" -- $cur)) | |
IFS="$OLDIFS" | |
fi | |
} | |
complete -F _build_sh build.sh |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
note that for FAKE 5 targets the regex needs to be changed to
grep -o 'Target.create ".*"' "${BUILD_FSX}"
, since it's now a factory function instead of a constructor.