appleseed command line widget (CLW)

Clash Royale CLAN TAG#URR8PPP
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty margin-bottom:0;
up vote
4
down vote
favorite
âÂÂâÂÂâ appleseed on GitHub
appleseed v1.0.0 is a command line widget (CLW), I designed for macOS
and iTerm2. Its a flexible platform for process automation and added
eye candy. It utilizes imgcat to view image files inside the terminal
with the help of shell integration. ⢠For best results, launch in a
tall by thin proportioned shell.
To use, you will need:
- macOS (High Sierra)
- Homebrew
- Bash
- iTerm2 (enable shell integration)
- imgcat
That being said, the code has been shellchecked, but please review this code for improvements and/or suggestions. When responding, consider the importance of the aesthetic value. Please only suggest changes that retain the exact appearance of the current functionality.
#!/usr/bin/env bash
# appleseed is a command line widget (CLW), designed for macOS and iTerm2.
#Variables
args=("$@")
endscript="false"
imgcat="/Users/matthew/.iterm2/imgcat"
minutes="10"
status1="Working.. "
copying="Copying.. "
host=$HOSTNAME
DIR="$HOME/git/appleseed/img"
BDIR="$HOME/git/appleseed/backup" #your backup directory
prefix=""
IFS='
'
#What do you want to backup?
dotfile0="$HOME/.zshrc"
dotfile1="$HOME/.oh-my-zsh/themes/trident.zsh-theme"
dotfile2="$HOME/Library/Fonts/Hack-Regular.ttf"
dotfile3="$HOME/.tmux.conf"
dotfile4="/etc/tmux.conf.local"
dotfile5="$HOME/osxui/okeanos/demo/trident.coffee"
#dotfile6=""
#dotfile7=""
#dotfile8=""
many="6"
#Colors
reset="$(tput sgr0)"
#black="$(tput bold; tput setaf 0)"
blue="$(tput bold; tput setaf 4)"
cyan="$(tput bold; tput setaf 6)"
green="$(tput bold; tput setaf 2)"
purple="$(tput bold; tput setaf 5)"
red="$(tput bold; tput setaf 1)"
#white="$(tput bold; tput setaf 7)"
yellow="$(tput bold; tput setaf 3)"
orange=$(tput bold; tput setaf 166);
#violet=$(tput bold; tput setaf 61);
header="$cyan[ $reset$green$reset$cyan appleseed @ $blue$host$reset $cyan]$reset"
backup="$purpleBackup:$reset"
packages="$purplePackages:$reset"
network="$purpleNetwork:$reset"
resources="$purpleResources:$reset"
#Arguments
version=$cyan1.0.0$reset
license="
$cyan$reset appleseed v$version
$purpleCopyright (C) 2018 Matthew A. Brassey$reset
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
"
help="
$cyanUsage:$cyan$green ./appleseed.sh $reset$purple[--help|--version]$reset
$cyan[options]$reset$green
--license Show lisense information.
--about What is appleseed?$reset
"
about="
$cyan$reset appleseed v$version
Is a command line widget (CLW), designed for macOS and iTerm2. For best results,
launch in a tall by thin proportioned shell.
"
#Functions
function panel()
start=$SECONDS
clear
echo "$header"
echo ""
echo "$backup"
backup
echo ""
echo "$packages"
macOS
homebrew
echo ""
echo "$network"
network
echo ""
echo "$resources"
system
echo ""
graphix
#Sleep sequence
completed
secs=$((minutes * 60))
while [ $secs -gt 0 ]; do
echo -ne "$blueâ°âÂÂâÂÂâÂÂâÂÂâ¼$reset$green Re-launch in:$reset $cyan$secs\033[0Ks\r$reset"
sleep 1
: $((secs--))
done
function graphix()
if [[ -d "$DIR" ]]
then
# shellcheck disable=SC2207
# taken care (through setting IFS)
file_matrix=($(ls "$DIR"))
num_files=($#file_matrix[*])
$imgcat "$DIR/$file_matrix[$((RANDOM%num_files))]"
fi
function homebrew()
echo "$cyan[$reset $blueHomebrew: $reset $yellow$status1$reset $cyan]$reset"
temp0="$(brew update 2>&1)"
if [[ "$temp0" = *"Already"* ]]; then
status4="$greenUpdated!$reset"
img_brew="âÂÂ"
echo "$cyan[$reset $blueHomebrew: $reset $green$status4$reset $cyan]$reset"
else
status4="$orangeMissing!$reset"
echo "$cyan[$reset $blueHomebrew: $reset $green$status4$reset $cyan]$reset"
img_brew="$orangeâÂÂ$reset$cyan"
if [[ "$temp0" = *"Updated"* ]]; then
echo "$cyan[$reset $greenâ $temp0:0:14$reset $cyan]$reset"
img_brew="âÂÂ"
fi
fi
brew_ver="$(brew --version 2>&1)"
# shellcheck disable=SC2206
# taken care (through setting IFS)
brew_ver_num=($brew_ver[@])
echo "$cyan[$reset$cyan $img_brew $brew_ver_num[0]$reset $cyan]$reset"
temp0=""
function macOS()
echo "$cyan[$reset $bluemacOS: $reset $yellow$status1$reset $cyan]$reset"
temp="$(softwareupdate -l 2>&1)"
# temp="No"
temp2="$(echo "$temp"
function network()sed 's/(.*)../1/')
country=$country_raw:14
echo "⢠$blueIP: $reset$green$public_ip$reset"
if [ -s "$city" ]
then
:
else
echo "⢠$blueCity: $reset$green$city$reset"
fi
if [ -s "$region" ]
then
:
else
if [ "$region" == "$city" ]
then
:
else
echo "⢠$blueRegion: $reset$green$region$reset"
fi
fi
if [ "$country" != "US" ]
then
vpn="$cyanâ $reset$greenVPN$reset"
else
vpn="$orangeâ $reset$yellowVPN$reset"
fi
echo "⢠$blueCountry: $reset$green$country$reset $vpn"
function backup()
count="0"
echo "$cyan[$reset $bluedotfiles: $reset$yellow$copying$reset $cyan]$reset"
if [ -f "$dotfile0" ]
then
cp "$dotfile0" "$BDIR" 2>&1
((count++))
else
:
fi
if [ -f "$dotfile1" ]
then
cp "$dotfile1" "$BDIR" 2>&1
((count++))
else
:
fi
if [ -f "$dotfile2" ]
then
cp "$dotfile2" "$BDIR" 2>&1
((count++))
else
:
fi
if [ -f "$dotfile3" ]
then
cp "$dotfile3" "$BDIR" 2>&1
((count++))
else
:
fi
if [ -f "$dotfile4" ]
then
cp "$dotfile4" "$BDIR" 2>&1
((count++))
else
:
fi
if [ -f "$dotfile5" ]
then
cp "$dotfile5" "$BDIR" 2>&1
((count++))
else
:
fi
# if [ -f "$dotfile6" ]
# then
# :
# ((count++))
# else
# :
# fi
if [ $count -eq $many ]
then
img_backup="âÂÂ"
else
img_backup="$orangeâÂÂ$reset"
fi
echo "$cyan[$reset $cyan$img_backup Copied: $reset$green$count$reset/$cyan$many$reset$cyan files!$reset $cyan]$reset"
function system()
cpu2=$(top -l 2 -n 0 -F
function completed()
duration=$(( SECONDS - start ))
echo "$blueâÂÂâÂÂâÂÂâÂÂâÂÂâ¼$reset$purple Completed in: $reset$cyan$duration$reset$cyans$reset"
#Arguments
for ((arg=0;arg<"$#args[@]";arg++)); do
[ "$args[$arg]" == "--version" ] && echo "$version" && exit
[ "$args[$arg]" == "--help" ] && echo "$help" && exit
[ "$args[$arg]" == "--license" ] && echo "$license" && exit
[ "$args[$arg]" == "--about" ] && echo "$about" && exit
#[ "$args[$arg]" == "--" ] && echo $args[$arg]
done
#Activate panel
while [ $endscript = "false" ]
do
panel
done
bash macos
add a comment |Â
up vote
4
down vote
favorite
âÂÂâÂÂâ appleseed on GitHub
appleseed v1.0.0 is a command line widget (CLW), I designed for macOS
and iTerm2. Its a flexible platform for process automation and added
eye candy. It utilizes imgcat to view image files inside the terminal
with the help of shell integration. ⢠For best results, launch in a
tall by thin proportioned shell.
To use, you will need:
- macOS (High Sierra)
- Homebrew
- Bash
- iTerm2 (enable shell integration)
- imgcat
That being said, the code has been shellchecked, but please review this code for improvements and/or suggestions. When responding, consider the importance of the aesthetic value. Please only suggest changes that retain the exact appearance of the current functionality.
#!/usr/bin/env bash
# appleseed is a command line widget (CLW), designed for macOS and iTerm2.
#Variables
args=("$@")
endscript="false"
imgcat="/Users/matthew/.iterm2/imgcat"
minutes="10"
status1="Working.. "
copying="Copying.. "
host=$HOSTNAME
DIR="$HOME/git/appleseed/img"
BDIR="$HOME/git/appleseed/backup" #your backup directory
prefix=""
IFS='
'
#What do you want to backup?
dotfile0="$HOME/.zshrc"
dotfile1="$HOME/.oh-my-zsh/themes/trident.zsh-theme"
dotfile2="$HOME/Library/Fonts/Hack-Regular.ttf"
dotfile3="$HOME/.tmux.conf"
dotfile4="/etc/tmux.conf.local"
dotfile5="$HOME/osxui/okeanos/demo/trident.coffee"
#dotfile6=""
#dotfile7=""
#dotfile8=""
many="6"
#Colors
reset="$(tput sgr0)"
#black="$(tput bold; tput setaf 0)"
blue="$(tput bold; tput setaf 4)"
cyan="$(tput bold; tput setaf 6)"
green="$(tput bold; tput setaf 2)"
purple="$(tput bold; tput setaf 5)"
red="$(tput bold; tput setaf 1)"
#white="$(tput bold; tput setaf 7)"
yellow="$(tput bold; tput setaf 3)"
orange=$(tput bold; tput setaf 166);
#violet=$(tput bold; tput setaf 61);
header="$cyan[ $reset$green$reset$cyan appleseed @ $blue$host$reset $cyan]$reset"
backup="$purpleBackup:$reset"
packages="$purplePackages:$reset"
network="$purpleNetwork:$reset"
resources="$purpleResources:$reset"
#Arguments
version=$cyan1.0.0$reset
license="
$cyan$reset appleseed v$version
$purpleCopyright (C) 2018 Matthew A. Brassey$reset
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
"
help="
$cyanUsage:$cyan$green ./appleseed.sh $reset$purple[--help|--version]$reset
$cyan[options]$reset$green
--license Show lisense information.
--about What is appleseed?$reset
"
about="
$cyan$reset appleseed v$version
Is a command line widget (CLW), designed for macOS and iTerm2. For best results,
launch in a tall by thin proportioned shell.
"
#Functions
function panel()
start=$SECONDS
clear
echo "$header"
echo ""
echo "$backup"
backup
echo ""
echo "$packages"
macOS
homebrew
echo ""
echo "$network"
network
echo ""
echo "$resources"
system
echo ""
graphix
#Sleep sequence
completed
secs=$((minutes * 60))
while [ $secs -gt 0 ]; do
echo -ne "$blueâ°âÂÂâÂÂâÂÂâÂÂâ¼$reset$green Re-launch in:$reset $cyan$secs\033[0Ks\r$reset"
sleep 1
: $((secs--))
done
function graphix()
if [[ -d "$DIR" ]]
then
# shellcheck disable=SC2207
# taken care (through setting IFS)
file_matrix=($(ls "$DIR"))
num_files=($#file_matrix[*])
$imgcat "$DIR/$file_matrix[$((RANDOM%num_files))]"
fi
function homebrew()
echo "$cyan[$reset $blueHomebrew: $reset $yellow$status1$reset $cyan]$reset"
temp0="$(brew update 2>&1)"
if [[ "$temp0" = *"Already"* ]]; then
status4="$greenUpdated!$reset"
img_brew="âÂÂ"
echo "$cyan[$reset $blueHomebrew: $reset $green$status4$reset $cyan]$reset"
else
status4="$orangeMissing!$reset"
echo "$cyan[$reset $blueHomebrew: $reset $green$status4$reset $cyan]$reset"
img_brew="$orangeâÂÂ$reset$cyan"
if [[ "$temp0" = *"Updated"* ]]; then
echo "$cyan[$reset $greenâ $temp0:0:14$reset $cyan]$reset"
img_brew="âÂÂ"
fi
fi
brew_ver="$(brew --version 2>&1)"
# shellcheck disable=SC2206
# taken care (through setting IFS)
brew_ver_num=($brew_ver[@])
echo "$cyan[$reset$cyan $img_brew $brew_ver_num[0]$reset $cyan]$reset"
temp0=""
function macOS()
echo "$cyan[$reset $bluemacOS: $reset $yellow$status1$reset $cyan]$reset"
temp="$(softwareupdate -l 2>&1)"
# temp="No"
temp2="$(echo "$temp"
function network()sed 's/(.*)../1/')
country=$country_raw:14
echo "⢠$blueIP: $reset$green$public_ip$reset"
if [ -s "$city" ]
then
:
else
echo "⢠$blueCity: $reset$green$city$reset"
fi
if [ -s "$region" ]
then
:
else
if [ "$region" == "$city" ]
then
:
else
echo "⢠$blueRegion: $reset$green$region$reset"
fi
fi
if [ "$country" != "US" ]
then
vpn="$cyanâ $reset$greenVPN$reset"
else
vpn="$orangeâ $reset$yellowVPN$reset"
fi
echo "⢠$blueCountry: $reset$green$country$reset $vpn"
function backup()
count="0"
echo "$cyan[$reset $bluedotfiles: $reset$yellow$copying$reset $cyan]$reset"
if [ -f "$dotfile0" ]
then
cp "$dotfile0" "$BDIR" 2>&1
((count++))
else
:
fi
if [ -f "$dotfile1" ]
then
cp "$dotfile1" "$BDIR" 2>&1
((count++))
else
:
fi
if [ -f "$dotfile2" ]
then
cp "$dotfile2" "$BDIR" 2>&1
((count++))
else
:
fi
if [ -f "$dotfile3" ]
then
cp "$dotfile3" "$BDIR" 2>&1
((count++))
else
:
fi
if [ -f "$dotfile4" ]
then
cp "$dotfile4" "$BDIR" 2>&1
((count++))
else
:
fi
if [ -f "$dotfile5" ]
then
cp "$dotfile5" "$BDIR" 2>&1
((count++))
else
:
fi
# if [ -f "$dotfile6" ]
# then
# :
# ((count++))
# else
# :
# fi
if [ $count -eq $many ]
then
img_backup="âÂÂ"
else
img_backup="$orangeâÂÂ$reset"
fi
echo "$cyan[$reset $cyan$img_backup Copied: $reset$green$count$reset/$cyan$many$reset$cyan files!$reset $cyan]$reset"
function system()
cpu2=$(top -l 2 -n 0 -F
function completed()
duration=$(( SECONDS - start ))
echo "$blueâÂÂâÂÂâÂÂâÂÂâÂÂâ¼$reset$purple Completed in: $reset$cyan$duration$reset$cyans$reset"
#Arguments
for ((arg=0;arg<"$#args[@]";arg++)); do
[ "$args[$arg]" == "--version" ] && echo "$version" && exit
[ "$args[$arg]" == "--help" ] && echo "$help" && exit
[ "$args[$arg]" == "--license" ] && echo "$license" && exit
[ "$args[$arg]" == "--about" ] && echo "$about" && exit
#[ "$args[$arg]" == "--" ] && echo $args[$arg]
done
#Activate panel
while [ $endscript = "false" ]
do
panel
done
bash macos
2
what are these funny squares () in your post and your code?
â miracle173
Mar 24 at 16:00
(  ) shows as an apple symbol from macOS, is there a universal unicode for the apple symbol?
â Matt
Mar 24 at 16:07
3
The Unicode Apple logo strikes again!
â Mast
Mar 24 at 16:15
"Please avoid using it on the web" - gotcha.
â Matt
Mar 24 at 16:25
add a comment |Â
up vote
4
down vote
favorite
up vote
4
down vote
favorite
âÂÂâÂÂâ appleseed on GitHub
appleseed v1.0.0 is a command line widget (CLW), I designed for macOS
and iTerm2. Its a flexible platform for process automation and added
eye candy. It utilizes imgcat to view image files inside the terminal
with the help of shell integration. ⢠For best results, launch in a
tall by thin proportioned shell.
To use, you will need:
- macOS (High Sierra)
- Homebrew
- Bash
- iTerm2 (enable shell integration)
- imgcat
That being said, the code has been shellchecked, but please review this code for improvements and/or suggestions. When responding, consider the importance of the aesthetic value. Please only suggest changes that retain the exact appearance of the current functionality.
#!/usr/bin/env bash
# appleseed is a command line widget (CLW), designed for macOS and iTerm2.
#Variables
args=("$@")
endscript="false"
imgcat="/Users/matthew/.iterm2/imgcat"
minutes="10"
status1="Working.. "
copying="Copying.. "
host=$HOSTNAME
DIR="$HOME/git/appleseed/img"
BDIR="$HOME/git/appleseed/backup" #your backup directory
prefix=""
IFS='
'
#What do you want to backup?
dotfile0="$HOME/.zshrc"
dotfile1="$HOME/.oh-my-zsh/themes/trident.zsh-theme"
dotfile2="$HOME/Library/Fonts/Hack-Regular.ttf"
dotfile3="$HOME/.tmux.conf"
dotfile4="/etc/tmux.conf.local"
dotfile5="$HOME/osxui/okeanos/demo/trident.coffee"
#dotfile6=""
#dotfile7=""
#dotfile8=""
many="6"
#Colors
reset="$(tput sgr0)"
#black="$(tput bold; tput setaf 0)"
blue="$(tput bold; tput setaf 4)"
cyan="$(tput bold; tput setaf 6)"
green="$(tput bold; tput setaf 2)"
purple="$(tput bold; tput setaf 5)"
red="$(tput bold; tput setaf 1)"
#white="$(tput bold; tput setaf 7)"
yellow="$(tput bold; tput setaf 3)"
orange=$(tput bold; tput setaf 166);
#violet=$(tput bold; tput setaf 61);
header="$cyan[ $reset$green$reset$cyan appleseed @ $blue$host$reset $cyan]$reset"
backup="$purpleBackup:$reset"
packages="$purplePackages:$reset"
network="$purpleNetwork:$reset"
resources="$purpleResources:$reset"
#Arguments
version=$cyan1.0.0$reset
license="
$cyan$reset appleseed v$version
$purpleCopyright (C) 2018 Matthew A. Brassey$reset
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
"
help="
$cyanUsage:$cyan$green ./appleseed.sh $reset$purple[--help|--version]$reset
$cyan[options]$reset$green
--license Show lisense information.
--about What is appleseed?$reset
"
about="
$cyan$reset appleseed v$version
Is a command line widget (CLW), designed for macOS and iTerm2. For best results,
launch in a tall by thin proportioned shell.
"
#Functions
function panel()
start=$SECONDS
clear
echo "$header"
echo ""
echo "$backup"
backup
echo ""
echo "$packages"
macOS
homebrew
echo ""
echo "$network"
network
echo ""
echo "$resources"
system
echo ""
graphix
#Sleep sequence
completed
secs=$((minutes * 60))
while [ $secs -gt 0 ]; do
echo -ne "$blueâ°âÂÂâÂÂâÂÂâÂÂâ¼$reset$green Re-launch in:$reset $cyan$secs\033[0Ks\r$reset"
sleep 1
: $((secs--))
done
function graphix()
if [[ -d "$DIR" ]]
then
# shellcheck disable=SC2207
# taken care (through setting IFS)
file_matrix=($(ls "$DIR"))
num_files=($#file_matrix[*])
$imgcat "$DIR/$file_matrix[$((RANDOM%num_files))]"
fi
function homebrew()
echo "$cyan[$reset $blueHomebrew: $reset $yellow$status1$reset $cyan]$reset"
temp0="$(brew update 2>&1)"
if [[ "$temp0" = *"Already"* ]]; then
status4="$greenUpdated!$reset"
img_brew="âÂÂ"
echo "$cyan[$reset $blueHomebrew: $reset $green$status4$reset $cyan]$reset"
else
status4="$orangeMissing!$reset"
echo "$cyan[$reset $blueHomebrew: $reset $green$status4$reset $cyan]$reset"
img_brew="$orangeâÂÂ$reset$cyan"
if [[ "$temp0" = *"Updated"* ]]; then
echo "$cyan[$reset $greenâ $temp0:0:14$reset $cyan]$reset"
img_brew="âÂÂ"
fi
fi
brew_ver="$(brew --version 2>&1)"
# shellcheck disable=SC2206
# taken care (through setting IFS)
brew_ver_num=($brew_ver[@])
echo "$cyan[$reset$cyan $img_brew $brew_ver_num[0]$reset $cyan]$reset"
temp0=""
function macOS()
echo "$cyan[$reset $bluemacOS: $reset $yellow$status1$reset $cyan]$reset"
temp="$(softwareupdate -l 2>&1)"
# temp="No"
temp2="$(echo "$temp"
function network()sed 's/(.*)../1/')
country=$country_raw:14
echo "⢠$blueIP: $reset$green$public_ip$reset"
if [ -s "$city" ]
then
:
else
echo "⢠$blueCity: $reset$green$city$reset"
fi
if [ -s "$region" ]
then
:
else
if [ "$region" == "$city" ]
then
:
else
echo "⢠$blueRegion: $reset$green$region$reset"
fi
fi
if [ "$country" != "US" ]
then
vpn="$cyanâ $reset$greenVPN$reset"
else
vpn="$orangeâ $reset$yellowVPN$reset"
fi
echo "⢠$blueCountry: $reset$green$country$reset $vpn"
function backup()
count="0"
echo "$cyan[$reset $bluedotfiles: $reset$yellow$copying$reset $cyan]$reset"
if [ -f "$dotfile0" ]
then
cp "$dotfile0" "$BDIR" 2>&1
((count++))
else
:
fi
if [ -f "$dotfile1" ]
then
cp "$dotfile1" "$BDIR" 2>&1
((count++))
else
:
fi
if [ -f "$dotfile2" ]
then
cp "$dotfile2" "$BDIR" 2>&1
((count++))
else
:
fi
if [ -f "$dotfile3" ]
then
cp "$dotfile3" "$BDIR" 2>&1
((count++))
else
:
fi
if [ -f "$dotfile4" ]
then
cp "$dotfile4" "$BDIR" 2>&1
((count++))
else
:
fi
if [ -f "$dotfile5" ]
then
cp "$dotfile5" "$BDIR" 2>&1
((count++))
else
:
fi
# if [ -f "$dotfile6" ]
# then
# :
# ((count++))
# else
# :
# fi
if [ $count -eq $many ]
then
img_backup="âÂÂ"
else
img_backup="$orangeâÂÂ$reset"
fi
echo "$cyan[$reset $cyan$img_backup Copied: $reset$green$count$reset/$cyan$many$reset$cyan files!$reset $cyan]$reset"
function system()
cpu2=$(top -l 2 -n 0 -F
function completed()
duration=$(( SECONDS - start ))
echo "$blueâÂÂâÂÂâÂÂâÂÂâÂÂâ¼$reset$purple Completed in: $reset$cyan$duration$reset$cyans$reset"
#Arguments
for ((arg=0;arg<"$#args[@]";arg++)); do
[ "$args[$arg]" == "--version" ] && echo "$version" && exit
[ "$args[$arg]" == "--help" ] && echo "$help" && exit
[ "$args[$arg]" == "--license" ] && echo "$license" && exit
[ "$args[$arg]" == "--about" ] && echo "$about" && exit
#[ "$args[$arg]" == "--" ] && echo $args[$arg]
done
#Activate panel
while [ $endscript = "false" ]
do
panel
done
bash macos
âÂÂâÂÂâ appleseed on GitHub
appleseed v1.0.0 is a command line widget (CLW), I designed for macOS
and iTerm2. Its a flexible platform for process automation and added
eye candy. It utilizes imgcat to view image files inside the terminal
with the help of shell integration. ⢠For best results, launch in a
tall by thin proportioned shell.
To use, you will need:
- macOS (High Sierra)
- Homebrew
- Bash
- iTerm2 (enable shell integration)
- imgcat
That being said, the code has been shellchecked, but please review this code for improvements and/or suggestions. When responding, consider the importance of the aesthetic value. Please only suggest changes that retain the exact appearance of the current functionality.
#!/usr/bin/env bash
# appleseed is a command line widget (CLW), designed for macOS and iTerm2.
#Variables
args=("$@")
endscript="false"
imgcat="/Users/matthew/.iterm2/imgcat"
minutes="10"
status1="Working.. "
copying="Copying.. "
host=$HOSTNAME
DIR="$HOME/git/appleseed/img"
BDIR="$HOME/git/appleseed/backup" #your backup directory
prefix=""
IFS='
'
#What do you want to backup?
dotfile0="$HOME/.zshrc"
dotfile1="$HOME/.oh-my-zsh/themes/trident.zsh-theme"
dotfile2="$HOME/Library/Fonts/Hack-Regular.ttf"
dotfile3="$HOME/.tmux.conf"
dotfile4="/etc/tmux.conf.local"
dotfile5="$HOME/osxui/okeanos/demo/trident.coffee"
#dotfile6=""
#dotfile7=""
#dotfile8=""
many="6"
#Colors
reset="$(tput sgr0)"
#black="$(tput bold; tput setaf 0)"
blue="$(tput bold; tput setaf 4)"
cyan="$(tput bold; tput setaf 6)"
green="$(tput bold; tput setaf 2)"
purple="$(tput bold; tput setaf 5)"
red="$(tput bold; tput setaf 1)"
#white="$(tput bold; tput setaf 7)"
yellow="$(tput bold; tput setaf 3)"
orange=$(tput bold; tput setaf 166);
#violet=$(tput bold; tput setaf 61);
header="$cyan[ $reset$green$reset$cyan appleseed @ $blue$host$reset $cyan]$reset"
backup="$purpleBackup:$reset"
packages="$purplePackages:$reset"
network="$purpleNetwork:$reset"
resources="$purpleResources:$reset"
#Arguments
version=$cyan1.0.0$reset
license="
$cyan$reset appleseed v$version
$purpleCopyright (C) 2018 Matthew A. Brassey$reset
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
"
help="
$cyanUsage:$cyan$green ./appleseed.sh $reset$purple[--help|--version]$reset
$cyan[options]$reset$green
--license Show lisense information.
--about What is appleseed?$reset
"
about="
$cyan$reset appleseed v$version
Is a command line widget (CLW), designed for macOS and iTerm2. For best results,
launch in a tall by thin proportioned shell.
"
#Functions
function panel()
start=$SECONDS
clear
echo "$header"
echo ""
echo "$backup"
backup
echo ""
echo "$packages"
macOS
homebrew
echo ""
echo "$network"
network
echo ""
echo "$resources"
system
echo ""
graphix
#Sleep sequence
completed
secs=$((minutes * 60))
while [ $secs -gt 0 ]; do
echo -ne "$blueâ°âÂÂâÂÂâÂÂâÂÂâ¼$reset$green Re-launch in:$reset $cyan$secs\033[0Ks\r$reset"
sleep 1
: $((secs--))
done
function graphix()
if [[ -d "$DIR" ]]
then
# shellcheck disable=SC2207
# taken care (through setting IFS)
file_matrix=($(ls "$DIR"))
num_files=($#file_matrix[*])
$imgcat "$DIR/$file_matrix[$((RANDOM%num_files))]"
fi
function homebrew()
echo "$cyan[$reset $blueHomebrew: $reset $yellow$status1$reset $cyan]$reset"
temp0="$(brew update 2>&1)"
if [[ "$temp0" = *"Already"* ]]; then
status4="$greenUpdated!$reset"
img_brew="âÂÂ"
echo "$cyan[$reset $blueHomebrew: $reset $green$status4$reset $cyan]$reset"
else
status4="$orangeMissing!$reset"
echo "$cyan[$reset $blueHomebrew: $reset $green$status4$reset $cyan]$reset"
img_brew="$orangeâÂÂ$reset$cyan"
if [[ "$temp0" = *"Updated"* ]]; then
echo "$cyan[$reset $greenâ $temp0:0:14$reset $cyan]$reset"
img_brew="âÂÂ"
fi
fi
brew_ver="$(brew --version 2>&1)"
# shellcheck disable=SC2206
# taken care (through setting IFS)
brew_ver_num=($brew_ver[@])
echo "$cyan[$reset$cyan $img_brew $brew_ver_num[0]$reset $cyan]$reset"
temp0=""
function macOS()
echo "$cyan[$reset $bluemacOS: $reset $yellow$status1$reset $cyan]$reset"
temp="$(softwareupdate -l 2>&1)"
# temp="No"
temp2="$(echo "$temp"
function network()sed 's/(.*)../1/')
country=$country_raw:14
echo "⢠$blueIP: $reset$green$public_ip$reset"
if [ -s "$city" ]
then
:
else
echo "⢠$blueCity: $reset$green$city$reset"
fi
if [ -s "$region" ]
then
:
else
if [ "$region" == "$city" ]
then
:
else
echo "⢠$blueRegion: $reset$green$region$reset"
fi
fi
if [ "$country" != "US" ]
then
vpn="$cyanâ $reset$greenVPN$reset"
else
vpn="$orangeâ $reset$yellowVPN$reset"
fi
echo "⢠$blueCountry: $reset$green$country$reset $vpn"
function backup()
count="0"
echo "$cyan[$reset $bluedotfiles: $reset$yellow$copying$reset $cyan]$reset"
if [ -f "$dotfile0" ]
then
cp "$dotfile0" "$BDIR" 2>&1
((count++))
else
:
fi
if [ -f "$dotfile1" ]
then
cp "$dotfile1" "$BDIR" 2>&1
((count++))
else
:
fi
if [ -f "$dotfile2" ]
then
cp "$dotfile2" "$BDIR" 2>&1
((count++))
else
:
fi
if [ -f "$dotfile3" ]
then
cp "$dotfile3" "$BDIR" 2>&1
((count++))
else
:
fi
if [ -f "$dotfile4" ]
then
cp "$dotfile4" "$BDIR" 2>&1
((count++))
else
:
fi
if [ -f "$dotfile5" ]
then
cp "$dotfile5" "$BDIR" 2>&1
((count++))
else
:
fi
# if [ -f "$dotfile6" ]
# then
# :
# ((count++))
# else
# :
# fi
if [ $count -eq $many ]
then
img_backup="âÂÂ"
else
img_backup="$orangeâÂÂ$reset"
fi
echo "$cyan[$reset $cyan$img_backup Copied: $reset$green$count$reset/$cyan$many$reset$cyan files!$reset $cyan]$reset"
function system()
cpu2=$(top -l 2 -n 0 -F
function completed()
duration=$(( SECONDS - start ))
echo "$blueâÂÂâÂÂâÂÂâÂÂâÂÂâ¼$reset$purple Completed in: $reset$cyan$duration$reset$cyans$reset"
#Arguments
for ((arg=0;arg<"$#args[@]";arg++)); do
[ "$args[$arg]" == "--version" ] && echo "$version" && exit
[ "$args[$arg]" == "--help" ] && echo "$help" && exit
[ "$args[$arg]" == "--license" ] && echo "$license" && exit
[ "$args[$arg]" == "--about" ] && echo "$about" && exit
#[ "$args[$arg]" == "--" ] && echo $args[$arg]
done
#Activate panel
while [ $endscript = "false" ]
do
panel
done
bash macos
edited Mar 24 at 20:32
asked Mar 24 at 15:47
Matt
685
685
2
what are these funny squares () in your post and your code?
â miracle173
Mar 24 at 16:00
(  ) shows as an apple symbol from macOS, is there a universal unicode for the apple symbol?
â Matt
Mar 24 at 16:07
3
The Unicode Apple logo strikes again!
â Mast
Mar 24 at 16:15
"Please avoid using it on the web" - gotcha.
â Matt
Mar 24 at 16:25
add a comment |Â
2
what are these funny squares () in your post and your code?
â miracle173
Mar 24 at 16:00
(  ) shows as an apple symbol from macOS, is there a universal unicode for the apple symbol?
â Matt
Mar 24 at 16:07
3
The Unicode Apple logo strikes again!
â Mast
Mar 24 at 16:15
"Please avoid using it on the web" - gotcha.
â Matt
Mar 24 at 16:25
2
2
what are these funny squares () in your post and your code?
â miracle173
Mar 24 at 16:00
what are these funny squares () in your post and your code?
â miracle173
Mar 24 at 16:00
(  ) shows as an apple symbol from macOS, is there a universal unicode for the apple symbol?
â Matt
Mar 24 at 16:07
(  ) shows as an apple symbol from macOS, is there a universal unicode for the apple symbol?
â Matt
Mar 24 at 16:07
3
3
The Unicode Apple logo strikes again!
â Mast
Mar 24 at 16:15
The Unicode Apple logo strikes again!
â Mast
Mar 24 at 16:15
"Please avoid using it on the web" - gotcha.
â Matt
Mar 24 at 16:25
"Please avoid using it on the web" - gotcha.
â Matt
Mar 24 at 16:25
add a comment |Â
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fcodereview.stackexchange.com%2fquestions%2f190375%2fappleseed-command-line-widget-clw%23new-answer', 'question_page');
);
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
2
what are these funny squares () in your post and your code?
â miracle173
Mar 24 at 16:00
(  ) shows as an apple symbol from macOS, is there a universal unicode for the apple symbol?
â Matt
Mar 24 at 16:07
3
The Unicode Apple logo strikes again!
â Mast
Mar 24 at 16:15
"Please avoid using it on the web" - gotcha.
â Matt
Mar 24 at 16:25