From 8ecb7b06123dbfff556f54fc17758ec2d5aab77a Mon Sep 17 00:00:00 2001 From: Darcy Laycock Date: Fri, 11 Sep 2009 23:10:47 +0800 Subject: [PATCH] Add fish completions for the brew binary See Library/Contributions --- .../Contributions/brew_fish_completion.fish | 73 +++++++++++++++++++ 1 file changed, 73 insertions(+) create mode 100644 Library/Contributions/brew_fish_completion.fish diff --git a/Library/Contributions/brew_fish_completion.fish b/Library/Contributions/brew_fish_completion.fish new file mode 100644 index 0000000000..12a89120cd --- /dev/null +++ b/Library/Contributions/brew_fish_completion.fish @@ -0,0 +1,73 @@ +# This script contains basic completion of brew commands for +# fish (http://fishshell.org). To install it either put it +# in /share/fish/completions +# or ~/.config/fish/completions - and name it 'brew.fish' +# e.g.: +# mkdir -p ~/.config/fish/completions +# cp brew_fish_completion.fish ~/.config/fish/completions/brew.fish + +function __fish_complete_homebrew_formula + set arguments (commandline -opc) + for cmd in $arguments + + if contains -- $cmd edit install homepage home + ls (brew --prefix)/Library/Formula | sed s/\.rb// + return 0 + end + + if contains -- $cmd abv info list link ls ln rm remove uninstall + ls (brew --prefix)/Cellar + return 0 + end + + end +end + +function __fish_complete_brew_has_command + set arguments (commandline -opc) + + if [ (count $arguments) = 1 ] + return 1 + end + + for cmd in $arguments + if contains -- $cmd abv info list link ls ln rm remove uninstall edit install homepage home prune gen + return 0 + end + end + return 1 + +end + +function __fish_complete_brew_command + set arguments (commandline -opc) + set cmd $argv[1] + + if contains -- $cmd abv info list link ls ln rm remove uninstall edit install homepage home prune gen + return 0 + end + return 1 +end + +function __fish_complete_brew_no_command + for cmd in (commandline -opc) + if contains -- $cmd abv info list link ls ln rm remove uninstall edit install homepage home prune gen + return 1 + end + end + return 0 +end + +complete -c brew -x -a "abv info list link ls ln rm remove uninstall edit install homepage home prune gen" -n '__fish_complete_brew_no_command' +complete -c brew -x -a '(__fish_complete_homebrew_formula)' -n '__fish_complete_brew_has_command' + +complete -c brew -s d -l debug -n '__fish_complete_brew_command install' +complete -c brew -s i -l interactive -n '__fish_complete_brew_command install' + +complete -c brew -l github -n '__fish_complete_brew_command info' + +complete -c brew -l prefix -n '__fish_complete_brew_no_command' +complete -c brew -l version -n '__fish_complete_brew_no_command' +complete -c brew -l cache -n '__fish_complete_brew_no_command' + +complete -c brew -s v -l verbose