aboutsummarylogtreecommitdiffstats
path: root/haur
diff options
context:
space:
mode:
authorYash Karandikar2020-02-19 17:23:02 -0600
committerYash Karandikar2020-02-19 17:23:02 -0600
commit6721f53f690766aaf4568dc50b408f94690a5a80 (patch)
treebe5992153fd3ae263f58d76e59fb851d47f74963 /haur
parentade999c16112e3ca0757b054c10af68a1910a74f (diff)
downloadaur-6721f53f690766aaf4568dc50b408f94690a5a80.tar.gz
Add colored output
Diffstat (limited to 'haur')
-rwxr-xr-xhaur39
1 files changed, 30 insertions, 9 deletions
diff --git a/haur b/haur
index 33ad48678d8c..d4c8ab83ce58 100755
--- a/haur
+++ b/haur
@@ -1,5 +1,26 @@
#!/bin/bash
+if test -t 1; then
+
+ # see if it supports colors...
+ ncolors=$(tput colors)
+
+ if test -n "$ncolors" && test $ncolors -ge 8; then
+ bold="$(tput bold)"
+ underline="$(tput smul)"
+ standout="$(tput smso)"
+ normal="$(tput sgr0)"
+ black="$(tput setaf 0)"
+ red="$(tput setaf 1)"
+ green="$(tput setaf 2)"
+ yellow="$(tput setaf 3)"
+ blue="$(tput setaf 4)"
+ magenta="$(tput setaf 5)"
+ cyan="$(tput setaf 6)"
+ white="$(tput setaf 7)"
+ fi
+fi
+
REMOVE=false
CLEAR_CACHE=false
@@ -27,7 +48,7 @@ while getopts ":rch" opt; do
exit 0
;;
\?)
- echo "Invalid Option: -$OPTARG" 1>&2
+ echo "${red}Invalid Option: -$OPTARG${normal}" 1>&2
exit 1
;;
esac
@@ -37,37 +58,37 @@ shift $((OPTIND -1))
if [ $REMOVE == true ]; then
for PACKAGE_NAME in "$@"; do
- echo "Removing $PACKAGE_NAME..."
+ echo "${blue}Removing $PACKAGE_NAME...${normal}"
sudo pacman -Rns $PACKAGE_NAME
echo $PACKAGE_NAME > ~/.haur_cache
done
if [ $CLEAR_CACHE == true ]; then
if test -f "$HOME/.haur_cache"; then
- echo "Clearing cache..."
+ echo "${blue}Clearing cache...${normal}"
while IFS= read -r line || [[ -n "$line" ]]; do
- echo "Removing $line"
+ echo "${blue}Removing $line${normal}"
rm -rf $HOME/.haur/$line
done < "$HOME/.haur_cache"
rm ~/.haur_cache
else
- echo "Nothing to clear"
+ echo "${blue}Nothing to clear${normal}"
fi
fi
else
if [ $CLEAR_CACHE == true ]; then
if test -f "$HOME/.haur_cache"; then
- echo "Clearing cache..."
+ echo "${blue}Clearing cache...${normal}"
while IFS= read -r line || [[ -n "$line" ]]; do
- echo "Removing $line"
+ echo "${blue}Removing $line${normal}"
rm -rf $HOME/.haur/$line
done < "$HOME/.haur_cache"
rm ~/.haur_cache
else
- echo "Nothing to clear"
+ echo "${blue}Nothing to clear${normal}"
fi
fi
for PACKAGE_NAME in "$@"; do
- echo "Installing $PACKAGE_NAME..."
+ echo "${blue}Installing $PACKAGE_NAME...${normal}"
mkdir -p ~/.haur
cd ~/.haur
git clone https://aur.archlinux.org/$PACKAGE_NAME.git