commit 9e5299d47a4290feb8aee9cd7757e9973dab8e7a
parent 3c405a6dbb33cc01bd08f012363af655b6d19208
Author: Daniel Moch <daniel@danielmoch.com>
Date: Sat, 2 Jun 2018 20:16:40 -0400
Remove use of non-standard bc for arithmetic
Diffstat:
3 files changed, 13 insertions(+), 16 deletions(-)
diff --git a/.local/bin/my b/.local/bin/my
@@ -257,7 +257,7 @@ case $command in
exit 0
;;
percent)
- echo "`my battery remaining`/`my battery total` * 100" | bc -l | cut -d '.' -f 1
+ echo "$((`my battery remaining` * 100 / `my battery total`))"
exit 0
;;
esac
@@ -359,8 +359,8 @@ case $command in
;;
login_async)
starttime=`date '+%s'`
- current=`date '+%s'`
- while [ `echo "$current - $starttime" | bc` -le 120 ]
+ runningtime=0
+ while [ $runningtime -le 120 ]
do
if ping -c 1 danielmoch.com > /dev/null 2>&1
then
@@ -368,7 +368,7 @@ case $command in
break
fi
sleep 1
- current=`date '+%s'`
+ runningtime=$((`date '+%s'` - $starttime))
done
if [ -n "$connected" ]
then
diff --git a/.local/bin/tmux-session b/.local/bin/tmux-session
@@ -7,14 +7,11 @@ then
columns=`tput cols`
echo $session
case $session in
- iterm)
- width=`echo "$columns - 80" | bc`
- ;;
- code)
- width=`echo "$columns - 80" | bc`
+ iterm|code)
+ width=$(($columns - 80))
;;
chat)
- width=`echo "$columns - 30" | bc`
+ width=$(($columns - 30))
;;
*)
unset width
@@ -39,7 +36,7 @@ if echo $1 | grep iterm > /dev/null 2>&1
then
name=iterm
columns=`tput cols`
- width=`echo "$columns - 80" | bc`
+ width=$(($columns - 80))
tmux new-session -d -x $columns -y `tput lines` -s $name vim
tmux rename-window -t $name:1 code
tmux setw main-pane-width $width
@@ -47,7 +44,7 @@ then
tmux selectl main-vertical
if echo $1 | grep chat > /dev/null 2>&1
then
- width=`echo "$columns - 30" | bc`
+ width=$(($columns - 30))
tmux new-window -t $name -n "chat" irssi
tmux setw main-pane-width $width
tmux splitw -h cat ~/.irssi/nicklistfifo
@@ -79,7 +76,7 @@ elif [ $1 = "code" ]
then
name=code
columns=`tput cols`
- width=`echo "$columns - 80" | bc`
+ width=$(($columns - 80))
tmux new-session -d -x $columns -y `tput lines` -s $name vim
tmux rename-window -t $name:1 code
tmux setw main-pane-width $width
@@ -93,7 +90,7 @@ elif [ $1 = "chat" ]
then
name=chat
columns=`tput cols`
- width=`echo "$columns - 30" | bc`
+ width=$(($columns - 30))
tmux new-session -d -x $columns -y `tput lines` -s $name irssi
tmux setw main-pane-width $width
tmux splitw -h cat ~/.irssi/nicklistfifo
diff --git a/.local/lib/tmux/battery_indicator.sh b/.local/lib/tmux/battery_indicator.sh
@@ -5,7 +5,7 @@
SMILE='☻ '
battery_percent=`my battery percent`
-charged_slots=`echo "$battery_percent/30+1" | bc -l | cut -d '.' -f 1`
+charged_slots=$(($battery_percent/30+1))
[ $charged_slots -gt 3 ] && charged_slots=3
echo -n '#[fg=colour108]'
@@ -13,6 +13,6 @@ for i in `seq 1 $charged_slots`; do echo -n "$SMILE"; done
if [ $charged_slots -lt 3 ]; then
echo -n '#[fg=colour131]'
- uncharged_slots=`echo "3-$charged_slots" | bc`
+ uncharged_slots=$((3-$charged_slots))
for i in `seq 1 $uncharged_slots`; do echo -n "$SMILE"; done
fi