Add cat alias detection to info.sh (#911)

This commit is contained in:
Ethan P 2020-04-20 23:33:44 -07:00 committed by GitHub
parent 4cc2989fe9
commit 96aedf6240
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 26 additions and 19 deletions

View File

@ -71,27 +71,34 @@ _bat_wrapper_:run() {
} }
_bat_wrapper_function_:run() { _bat_wrapper_function_:run() {
_bat_wrapper_function_:detect_wrapper() {
local command="$1"
case "$("$SHELL" --version | head -n 1)" in case "$("$SHELL" --version | head -n 1)" in
*fish*) *fish*)
if "$SHELL" --login -i -c 'type bat' 2>&1 | grep 'function' &> /dev/null; then if "$SHELL" --login -i -c "type ${command}" 2>&1 | grep 'function' &>/dev/null; then
_out_fence "$SHELL" --login -c 'functions bat' _out_fence "$SHELL" --login -i -c "functions ${command}"
return return
fi fi ;;
;;
*bash* | *zsh*) *bash*|*zsh*)
if "$SHELL" --login -i -c 'type bat' 2>&1 | grep 'function' &> /dev/null; then local type="$("$SHELL" --login -i -c "type ${command}" 2>&1)"
_out_fence "$SHELL" --login -i -c 'declare -f bat' if grep 'function' <<< "$type" &>/dev/null; then
_out_fence "$SHELL" --login -i -c "declare -f ${command}"
return return
fi elif grep 'alias' <<< "$type" &>/dev/null; then
;; _out_fence "$SHELL" --login -i -c "type ${command}"
return
fi ;;
*) *)
echo "Unable to determine if a wrapper function is set." echo "Unable to determine if a wrapper function for '${command}' is set."
return return ;;
;;
esac esac
printf "\nNo wrapper function.\n" printf "\nNo wrapper function for '%s'.\n" "${command}"
}
_bat_wrapper_function_:detect_wrapper bat
_bat_wrapper_function_:detect_wrapper cat
} }
_system_:run() { _system_:run() {