This commit is contained in:
2022-05-27 22:06:26 +03:00

6
bake
View File

@@ -42,7 +42,7 @@ complete -F _bake_complete bake
# Run me as: source <( $BAKE __autocomplete__ ) # Run me as: source <( $BAKE __autocomplete__ )
' '
exit; } exit; }
_flines() { cat "$BAKEFILE" | \ _flines() { cat "$BAKEFILE" 2>/dev/null | \
grep -E '^([^_][a-zA-Z0-9_\.\-]+)\(\) {.*'; } grep -E '^([^_][a-zA-Z0-9_\.\-]+)\(\) {.*'; }
_menu() { _flines | while read line; do _menu() { _flines | while read line; do
if [[ "$line" =~ ([a-zA-Z0-9_\.\-]+)\(\).\{[\ #]*(.*) ]]; then if [[ "$line" =~ ([a-zA-Z0-9_\.\-]+)\(\).\{[\ #]*(.*) ]]; then
@@ -113,6 +113,8 @@ _update_self() {
"https://raw.githubusercontent.com/moonq/bake/main/bake" "https://raw.githubusercontent.com/moonq/bake/main/bake"
chmod +x "$0" chmod +x "$0"
} }
@() { echo +"$@" >&2; "$@"; } # Print command before running it
for (( i=1; i<=$#; i++ )); do for (( i=1; i<=$#; i++ )); do
if [[ $i -eq 1 ]]; then if [[ $i -eq 1 ]]; then
if [[ "${!i}" = "__list__" ]]; then _flines | sed 's/().*//'; exit; fi if [[ "${!i}" = "__list__" ]]; then _flines | sed 's/().*//'; exit; fi
@@ -156,7 +158,7 @@ else
"$@" "$@"
else else
# but there is no defined completion # but there is no defined completion
compgen -o plusdirs -f -- "${@: -1}" compgen -f -d -- "${@: -1}"
fi fi
else else
# no such command # no such command