Formatting and more bash colors
This commit is contained in:
@@ -1,22 +1,26 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
if which tput >/dev/null 2>&1; then
|
||||
ncolors=$(tput colors)
|
||||
ncolors=$(tput colors)
|
||||
fi
|
||||
if [ -t 1 ] && [ -n "$ncolors" ] && [ "$ncolors" -ge 8 ]; then
|
||||
RED="$(tput setaf 1)"
|
||||
GREEN="$(tput setaf 2)"
|
||||
YELLOW="$(tput setaf 3)"
|
||||
BLUE="$(tput setaf 4)"
|
||||
BOLD="$(tput bold)"
|
||||
NORMAL="$(tput sgr0)"
|
||||
RED="$(tput setaf 1)"
|
||||
GREEN="$(tput setaf 2)"
|
||||
YELLOW="$(tput setaf 3)"
|
||||
BLUE="$(tput setaf 4)"
|
||||
MAGENTA="$(tput setaf 5)"
|
||||
CYAN="$(tput setaf 6)"
|
||||
BOLD="$(tput bold)"
|
||||
NORMAL="$(tput sgr0)"
|
||||
else
|
||||
RED=""
|
||||
GREEN=""
|
||||
YELLOW=""
|
||||
BLUE=""
|
||||
BOLD=""
|
||||
NORMAL=""
|
||||
RED=""
|
||||
GREEN=""
|
||||
YELLOW=""
|
||||
BLUE=""
|
||||
MAGENTA=""
|
||||
CYAN=""
|
||||
BOLD=""
|
||||
NORMAL=""
|
||||
fi
|
||||
|
||||
if [[ $1 == "" ]]; then
|
||||
|
||||
@@ -1,31 +1,35 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
if which tput >/dev/null 2>&1; then
|
||||
ncolors=$(tput colors)
|
||||
ncolors=$(tput colors)
|
||||
fi
|
||||
if [ -t 1 ] && [ -n "$ncolors" ] && [ "$ncolors" -ge 8 ]; then
|
||||
RED="$(tput setaf 1)"
|
||||
GREEN="$(tput setaf 2)"
|
||||
YELLOW="$(tput setaf 3)"
|
||||
BLUE="$(tput setaf 4)"
|
||||
BOLD="$(tput bold)"
|
||||
NORMAL="$(tput sgr0)"
|
||||
RED="$(tput setaf 1)"
|
||||
GREEN="$(tput setaf 2)"
|
||||
YELLOW="$(tput setaf 3)"
|
||||
BLUE="$(tput setaf 4)"
|
||||
MAGENTA="$(tput setaf 5)"
|
||||
CYAN="$(tput setaf 6)"
|
||||
BOLD="$(tput bold)"
|
||||
NORMAL="$(tput sgr0)"
|
||||
else
|
||||
RED=""
|
||||
GREEN=""
|
||||
YELLOW=""
|
||||
BLUE=""
|
||||
BOLD=""
|
||||
NORMAL=""
|
||||
RED=""
|
||||
GREEN=""
|
||||
YELLOW=""
|
||||
BLUE=""
|
||||
MAGENTA=""
|
||||
CYAN=""
|
||||
BOLD=""
|
||||
NORMAL=""
|
||||
fi
|
||||
|
||||
error() {
|
||||
printf "${BOLD}${RED}$1${NORMAL}"
|
||||
printf "${BOLD}${RED}$1${NORMAL}"
|
||||
}
|
||||
|
||||
abort() {
|
||||
error "\nAborting...\n"
|
||||
exit 1
|
||||
error "\nAborting...\n"
|
||||
exit 1
|
||||
}
|
||||
|
||||
set -e
|
||||
@@ -38,12 +42,12 @@ adb forward tcp:9222 localabstract:chrome_devtools_remote
|
||||
|
||||
src=_tabs.json
|
||||
if wget -qO $src http://localhost:9222/json/list; then
|
||||
ts=`date +"%Y-%m-%d_%H-%M-%S"`
|
||||
dest="${cwd}/${ts}_android-chrome-tabs.md"
|
||||
sed -n "/\"url\"/p" $src | sed -e "s/^[ \t]*.\{8\}//" -e "s/.\{2\}$//" > $dest
|
||||
printf "${BOLD}Saved tabs to: ${YELLOW}$dest${NORMAL}\n"
|
||||
ts=`date +"%Y-%m-%d_%H-%M-%S"`
|
||||
dest="${cwd}/${ts}_android-chrome-tabs.md"
|
||||
sed -n "/\"url\"/p" $src | sed -e "s/^[ \t]*.\{8\}//" -e "s/.\{2\}$//" > $dest
|
||||
printf "${BOLD}Saved tabs to: ${YELLOW}$dest${NORMAL}\n"
|
||||
else
|
||||
error "Unable to download tabs from device!\n"
|
||||
error "Unable to download tabs from device!\n"
|
||||
fi
|
||||
|
||||
rm $src
|
||||
|
||||
Reference in New Issue
Block a user