This repository has been archived by the owner on Jul 4, 2023. It is now read-only.
/
brew_fish_completion.fish
73 lines (57 loc) 路 2.14 KB
/
brew_fish_completion.fish
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
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