aboutsummaryrefslogtreecommitdiffstats
path: root/Library/Contributions/brew_fish_completion.fish
diff options
context:
space:
mode:
authorDarcy Laycock2009-09-11 23:10:47 +0800
committerMax Howell2009-09-16 14:49:06 +0100
commitbe2f766dc53de76b68ebc69a1dc22d6ba1029afe (patch)
tree03a764f05e8ad1680e8eb35df9550b19147b6e51 /Library/Contributions/brew_fish_completion.fish
parent66fa5b9493c45a4576d139637ba6f4b5da3973f0 (diff)
downloadhomebrew-be2f766dc53de76b68ebc69a1dc22d6ba1029afe.tar.bz2
Add fish completions for the brew binary
See Library/Contributions
Diffstat (limited to 'Library/Contributions/brew_fish_completion.fish')
-rw-r--r--Library/Contributions/brew_fish_completion.fish73
1 files changed, 73 insertions, 0 deletions
diff --git a/Library/Contributions/brew_fish_completion.fish b/Library/Contributions/brew_fish_completion.fish
new file mode 100644
index 000000000..12a89120c
--- /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 <your-fish-install-location>/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