Skip to content

Instantly share code, notes, and snippets.

@JosephDuffy
Last active March 16, 2017 19:38
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save JosephDuffy/e40fc115f849555c5ef8453d3ece1c10 to your computer and use it in GitHub Desktop.
Save JosephDuffy/e40fc115f849555c5ef8453d3ece1c10 to your computer and use it in GitHub Desktop.
A simple fish script to provide tab completion of fastlane lanes
# Author: Joseph Duffy
# License: MIT
# Notes: Place this script in `~/.config/fish/completions/` to enable Fastlane lane completion
# URL: https://gist.github.com/JosephDuffy/e40fc115f849555c5ef8453d3ece1c10
# This function was taken from https://github.com/Carthage/Carthage/blob/master/Source/Scripts/carthage-fish-completion
function __fish_prog_needs_subcommand
set cmd (commandline -opc)
if [ (count $cmd) -eq 1 -a $cmd[1] = 'fastlane' ]
return 0
end
return 1
end
if test -e "Fastfile"
set file "Fastfile"
else if test -e "fastlane/Fastfile"
set file "fastlane/Fastfile"
else if test -e ".fastlane/Fastfile"
set file ".fastlane/Fastfile"
else
exit 1
end
set commands (string match --regex '.*lane\ \:(?!private_)([^\s]*)\ do' (cat $file))
set commands_string
# Fish returns the fully matched string, plus the capture group. The actual captured value
# is every other line, starting at line 2.
set use_command false
for line in $commands
if [ $use_command = true ]
set commands_string "$commands_string $line"
set use_command false
else
set use_command true
end
end
complete -c fastlane -n '__fish_prog_needs_subcommand' -a (string trim $commands_string) -f
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment