Do path and string manipulation in pure bash
This commit is contained in:
parent
76b0140af5
commit
47d24c461c
@ -61,14 +61,18 @@ __brew_complete_formulae ()
|
||||
{
|
||||
local cur="${COMP_WORDS[COMP_CWORD]}"
|
||||
local lib=$(brew --repository)/Library
|
||||
local taps=${lib}/Taps
|
||||
local ff=$(\ls ${lib}/Formula 2>/dev/null | sed 's/\.rb//g')
|
||||
local af=$(\ls ${lib}/Aliases 2>/dev/null)
|
||||
local tf tap
|
||||
local tf file
|
||||
|
||||
for dir in $(\ls ${lib}/Taps 2>/dev/null); do
|
||||
tap="$(echo "$dir" | sed 's|-|/|g')"
|
||||
tf="$tf $(\ls -1R "${lib}/Taps/${dir}" 2>/dev/null |
|
||||
grep '.\+.rb' | sed -E 's|(.+)\.rb|'"${tap}"'/\1|g')"
|
||||
for file in ${taps}/*/*.rb ${taps}/*/Formula/*.rb ${taps}/*/HomebrewFormula/*.rb; do
|
||||
file=${file/"Formula/"/}
|
||||
file=${file/"HomebrewFormula/"/}
|
||||
file=${file#${lib}/Taps/}
|
||||
file=${file%.rb}
|
||||
file=${file/-//}
|
||||
tf="${tf} ${file}"
|
||||
done
|
||||
|
||||
COMPREPLY=($(compgen -W "$ff $af $tf" -- "$cur"))
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user