Skip to content

Commit 56bf0fa

Browse files
committed
Add improved completion.zsh script for fastlane
Tweaked in order to also support lanes defined in `fastlane/lanes/*.rb`
1 parent 8831b4c commit 56bf0fa

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed

fastlane/completion.zsh

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
#!/bin/zsh
2+
3+
# This is a revised version of the ZSH completion script for fastlane
4+
# which adds support for some lanes being defined in `fastlane/lanes/*.rb`
5+
#
6+
# Based on https://github.com/fastlane/fastlane/blob/master/fastlane/lib/assets/completions/completion.zsh
7+
#
8+
# To install, copy this file to `~/.fastlane/completions/completion.zsh`,
9+
# then `source` it from your `~/.zshrc`.
10+
#
11+
_fastlane_complete() {
12+
local word completions file
13+
word="$1"
14+
15+
# look for Fastfile either in this directory or fastlane/ then grab the lane names
16+
if [[ -e "Fastfile" ]] then
17+
file=("Fastfile")
18+
elif [[ -e "fastlane/Fastfile" ]] then
19+
file=("fastlane/Fastfile")
20+
elif [[ -e ".fastlane/Fastfile" ]] then
21+
file=(".fastlane/Fastfile")
22+
else
23+
return 1
24+
fi
25+
26+
# Add any fastlane/lanes/*.rb file too, if any
27+
files=("$file" fastlane/lanes/*.rb(N))
28+
29+
# parse 'beta' out of 'lane :beta do', etc
30+
completions="$(sed -En 's/^[ ]*lane +:([^ ]+).*$/\1/p' "${files[@]}")"
31+
completions="$completions update_fastlane"
32+
33+
reply=( "${=completions}" )
34+
}
35+
36+
compctl -K _fastlane_complete bundle exec fastlane

0 commit comments

Comments
 (0)