dots/scripts/check-tools

49 lines
1.3 KiB
Bash
Executable file

#!/usr/bin/env bash
source "${DOTS}/config/zsh/config/colors.zsh"
define_colors
# linux cli/tui tools and apps that i use
declare -A tools
tools=(
[alacritty]=" --version"
[bat]="󰭟 --version"
[btop]=" --version"
[dust]=" --version"
[exa]=" --version"
[fd]="--version"
[fzf]="c --version"
[git]=" --version"
[librewolf]=" --version"
[mpv]=" --version"
[neofetch]=" --version"
[nvim]=" --version"
[rg]=" --version"
[starship]="󱓞 --version"
[tldr]=" --version"
[tmux]=" -V"
[zsh]=" --version"
)
mapfile -t sorted_tools < <(echo "${!tools[@]}" | tr ' ' '\n' | sort)
printf "${BLD}%-18s %-10s %-10s\n" "Tools" "Status" "Version"
printf "%s\n${RST}" "-----------------------------------------------"
for tool in "${sorted_tools[@]}"; do
IFS=' ' read -r -a tool_data <<<"${tools[$tool]}"
if command -v "$tool" &>/dev/null; then
version=$("$tool" "${tool_data[1]}" 2>/dev/null | awk '{
for (i = 1; i <= NF; i++) {
if ($i ~ /[0-9]+.[0-9]+([.][0-9]+)?/) {
print $i;
exit;
}
}
}')
printf "${BLU}${tool_data[0]}${RST}${BLD} %-18s ${GRN}%-10s ${RST}${YLW}%-10s\n${RST}" \
"$tool" "" "$version"
else
printf "${CYN}${tool_data[0]}${RST}${BLD} %-18s ${RED}%-10s ${BLK}%-10s\n${RST}" \
"$tool" "" "command not found"
fi
done