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 cur="${COMP_WORDS[COMP_CWORD]}"
|
||||||
local lib=$(brew --repository)/Library
|
local lib=$(brew --repository)/Library
|
||||||
|
local taps=${lib}/Taps
|
||||||
local ff=$(\ls ${lib}/Formula 2>/dev/null | sed 's/\.rb//g')
|
local ff=$(\ls ${lib}/Formula 2>/dev/null | sed 's/\.rb//g')
|
||||||
local af=$(\ls ${lib}/Aliases 2>/dev/null)
|
local af=$(\ls ${lib}/Aliases 2>/dev/null)
|
||||||
local tf tap
|
local tf file
|
||||||
|
|
||||||
for dir in $(\ls ${lib}/Taps 2>/dev/null); do
|
for file in ${taps}/*/*.rb ${taps}/*/Formula/*.rb ${taps}/*/HomebrewFormula/*.rb; do
|
||||||
tap="$(echo "$dir" | sed 's|-|/|g')"
|
file=${file/"Formula/"/}
|
||||||
tf="$tf $(\ls -1R "${lib}/Taps/${dir}" 2>/dev/null |
|
file=${file/"HomebrewFormula/"/}
|
||||||
grep '.\+.rb' | sed -E 's|(.+)\.rb|'"${tap}"'/\1|g')"
|
file=${file#${lib}/Taps/}
|
||||||
|
file=${file%.rb}
|
||||||
|
file=${file/-//}
|
||||||
|
tf="${tf} ${file}"
|
||||||
done
|
done
|
||||||
|
|
||||||
COMPREPLY=($(compgen -W "$ff $af $tf" -- "$cur"))
|
COMPREPLY=($(compgen -W "$ff $af $tf" -- "$cur"))
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user