diff --git a/styler/.local/bin/styler b/styler/.local/bin/styler index a48570f..ea13e3a 100755 --- a/styler/.local/bin/styler +++ b/styler/.local/bin/styler @@ -8,20 +8,6 @@ readonly PROCESSOR_PATH="$BASE_PATH/processors" readonly VERSION="0.4.1" -# ensures that some grep-like program is available, prefers rg -setgrepper() { - if command -v rg 1>/dev/null 2>&1; then - GREPPER="rg" - elif command -v grep 1>/dev/null 2>&1; then - GREPPER="grep" - else - notify-send "grep missing" "styler needs grep, or preferably rg to work." - echo "grep missing!" "styler needs grep, or preferably rg to work." - exit 127 - fi -} -setgrepper - main() { local cmd="" local ret=0 @@ -116,7 +102,7 @@ get_processors() { for processor in "$package"/*; do [[ -e "$processor" ]] || break [[ -f "$processor" ]] || break - if ${GREPPER} -q -e '/theme_[[:alnum:]]\{1,\}$' <<<"$processor"; then + if grep -q -e '/theme_[[:alnum:]]\{1,\}$' <<<"$processor"; then printf "%s\n" "$(basename -- "$processor")" fi done @@ -180,7 +166,7 @@ _fetch_universal_themes() { local filtered for t in $unique; do for p in $packages; do - if ! echo "$themes" | ${GREPPER} -qe "^.*$p.*$t.*$" -; then + if ! echo "$themes" | grep -qe "^.*$p.*$t.*$" -; then themes="$(echo "$themes" | sed "/$t/d")" unique="$(echo "$unique" | sed "/$t/d")" break @@ -261,7 +247,7 @@ set_theme() { appext=$(sed -e 's|^[A-Za-z0-9-]\{1,\}/base16-||' <<<"$pkg") # Compares application extension with existing processors and runs the appropriate processor if found - processor=$(find "$PROCESSOR_PATH" -type f | ${GREPPER} -e "theme_$appext") + processor=$(find "$PROCESSOR_PATH" -type f | grep -e "theme_$appext") if [[ -f "$processor" ]]; then "$processor" "$PACKAGE_PATH" "$pkg" "$theme" "$permanent" else @@ -315,9 +301,9 @@ download() { # if package has patter name/base16-program, put it in packages; if name/process16-program put it in processors # if none of the above, assume it's a processor but warn the user - if ${GREPPER} -q -e '^[0-9A-Za-z-]\{1,\}/base16-[0-9A-Za-z-]\{1,\}$' <<<"$pkg"; then + if grep -q -e '^[0-9A-Za-z-]\{1,\}/base16-[0-9A-Za-z-]\{1,\}$' <<<"$pkg"; then git clone "$repo" "$PACKAGE_PATH/$pkg" - elif ${GREPPER} -q -e '^[0-9A-Za-z-]\{1,\}/process16-[0-9A-Za-z-]\{1,\}$' <<<"$pkg"; then + elif grep -q -e '^[0-9A-Za-z-]\{1,\}/process16-[0-9A-Za-z-]\{1,\}$' <<<"$pkg"; then git clone "$repo" "$PROCESSOR_PATH/$pkg" else echo "Package does not fit default naming scheme of packages/processors. Assuming it is a processor but please check manually."