aboutsummaryrefslogtreecommitdiffstats
path: root/tmux
diff options
context:
space:
mode:
authorterminaldweller <devi@terminaldweller.com>2023-07-13 18:10:26 +0000
committerterminaldweller <devi@terminaldweller.com>2023-07-13 18:10:26 +0000
commitb595ac2150e42a22e92b954188ae374d290b3f53 (patch)
treeb5e9d5e421c6d266e669476e2a1dfa4e89383953 /tmux
parentupdate (diff)
downloadscripts-main.tar.gz
scripts-main.zip
updateHEADmain
Diffstat (limited to 'tmux')
-rwxr-xr-xtmux/date.sh2
-rwxr-xr-xtmux/vcs_info.sh74
2 files changed, 45 insertions, 31 deletions
diff --git a/tmux/date.sh b/tmux/date.sh
index ca8f1d5..a97a9ea 100755
--- a/tmux/date.sh
+++ b/tmux/date.sh
@@ -91,7 +91,7 @@ ${SEPARATOR_LEFT_BOLD}#[fg=colour0 bg=colour24]${HEADSET_BATTERY}\
${CPU_SECTION}#[fg=colour32 bg=colour36]\
${SEPARATOR_LEFT_BOLD}${WEATHER}#[fg=colour29 bg=colour32]\
${SEPARATOR_LEFT_BOLD}${JDATE} #[fg=colour31 bg=colour29]\
-${SEPARATOR_LEFT_BOLD}${DAY} ${SEPARATOR_LEFT_THIN} ${DATE} ${SEPARATOR_LEFT_THIN} ${TIME} #[fg=colour214 bg=colour31]\
+${SEPARATOR_LEFT_BOLD}${DAY}#[fg=colour16]${SEPARATOR_LEFT_THIN}#[fg=colour255]${DATE}#[fg=colour16]${SEPARATOR_LEFT_THIN}#[fg=colour255]${TIME}#[fg=colour214 bg=colour31]\
${SEPARATOR_LEFT_BOLD}#[fg=colour0 bg=colour214]${BATTERY} #[fg=colour25 bg=colour214]\
${SEPARATOR_LEFT_BOLD}${UTC_TIME}\
$(ping_4_status)$(ping_6_status)"
diff --git a/tmux/vcs_info.sh b/tmux/vcs_info.sh
index 88c9e92..fadbc18 100755
--- a/tmux/vcs_info.sh
+++ b/tmux/vcs_info.sh
@@ -1,4 +1,4 @@
-#!/usr/bin/env bash
+#!/bin/sh
# source common.sh
SEPARATOR_RIGHT_BOLD=""
@@ -23,40 +23,43 @@ tmux_path=$(get_tmux_cwd)
# fi
# done
-cd "${tmux_path}"
-function gitadditions {
+gitadditions() {
if cd "${tmux_path}" && git rev-parse --git-dir >/dev/null 2>&1; then
- insertions=$(git --no-pager diff --numstat | awk '{sum1+=$1}END{print sum1}')
+ insertions=$(cd "${tmux_path}" && git --no-pager diff --numstat | awk '{sum1+=$1}END{print sum1}')
echo +"$insertions"
fi
}
-function gitdeletions {
+gitdeletions() {
if cd "${tmux_path}" && git rev-parse --git-dir >/dev/null 2>&1; then
- deletions=$(git --no-pager diff --numstat | awk '{sum2+=$2}END{print sum2}')
+ deletions=$(cd "${tmux_path}" && git --no-pager diff --numstat | awk '{sum2+=$2}END{print sum2}')
echo -"$deletions"
fi
}
-function git_untracked_info {
+git_untracked_info() {
if cd "${tmux_path}" && git rev-parse --git-dir >/dev/null 2>&1; then
- untracked=$(git ls-files --others --exclude-standard | wc -w)
+ untracked=$(cd "${tmux_path}" && git ls-files --others --exclude-standard | wc -w)
echo ⋯"$untracked"
fi
}
-function git_branch_info {
+git_branch_info() {
if cd "${tmux_path}" && git rev-parse --git-dir >/dev/null 2>&1; then
- branch=$(git rev-parse --abbrev-ref HEAD)
+ branch=$(cd "${tmux_path}" && git rev-parse --abbrev-ref HEAD)
echo " $branch"
fi
}
-function repo_info {
+repo_info() {
if cd "${tmux_path}" && git rev-parse --git-dir >/dev/null 2>&1; then
- insertions=$(git --no-pager diff --numstat | awk '{sum1+=$1}END{print sum1}')
- if git remote -v | grep github >/dev/null 2>&1; then
+ insertions=$(cd "${tmux_path}" && git --no-pager diff --numstat | awk '{sum1+=$1}END{print sum1}')
+ if cd "${tmux_path}" && git remote -v | grep github.com >/dev/null 2>&1; then
echo  
+ elif cd "${tmux_path}" && git remote -v | grep gitlab.com >/dev/null 2>&1; then
+ echo  
+ elif cd "${tmux_path}" && git remote -v | grep bitbucket.org >/dev/null 2>&1; then
+ echo  
else
echo 
fi
@@ -65,56 +68,67 @@ function repo_info {
fi
}
-function get_eth_price {
+get_eth_price() {
PRICE_TIME_CACHE=60
PRICE_CACHE_OUTPUT_ETH=/tmp/tmux_PRICE_CACHE_ETH
PRICE_CACHE_OUTPUT_XMR=/tmp/tmux_PRICE_CACHE_XMR
- PRICE_CACHE_OUTPUT_CAKE=/tmp/tmux_PRICE_CACHE_CAKE
+ # PRICE_CACHE_OUTPUT_CAKE=/tmp/tmux_PRICE_CACHE_CAKE
# eth_price=$(proxychains4 -q -f ~/proxies/ice/proxychains.conf curl -s -X GET "https://api.terminaldweller.com/crypto/v1/price?name=ETH&unit=USD" | jq ".price")
# cake_price=$(proxychains4 -q -f ~/proxies/ice/proxychains.conf curl -s -X GET "https://api.terminaldweller.com/crypto/v1/price?name=CAKE&unit=USD" | jq ".price")
# monero_price=$(proxychains4 -q -f ~/proxies/ice/proxychains.conf curl -s -X GET "https://api.terminaldweller.com/crypto/v1/price?name=XMR&unit=USD" | jq ".price")
if [ $(($(stat --format=%Y $PRICE_CACHE_OUTPUT_ETH) + PRICE_TIME_CACHE)) -gt "$(date +%s)" ]; then
:
else
- if ETH_OUTPUT=$(proxychains4 -q -f ~/proxies/ice/proxychains.conf curl -s -X GET "https://api.terminaldweller.com/crypto/v1/price?name=ETH&unit=USD" | jq ".price"); then
+ if ETH_OUTPUT=$(proxychains4 -q -f ~/proxies/ice/proxychains.conf curl -s -X GET "https://api.terminaldweller.com/crypto/v1/price?name=ETH&unit=USD" | jq ".price" | cut -d. -f1); then
if [ -n "${ETH_OUTPUT}" ]; then
echo "${ETH_OUTPUT}" >${PRICE_CACHE_OUTPUT_ETH}
fi
fi
fi
- if [ $(($(stat --format=%Y $PRICE_CACHE_OUTPUT_CAKE) + PRICE_TIME_CACHE)) -gt "$(date +%s)" ]; then
- :
- else
- if CAKE_OUTPUT=$(proxychains4 -q -f ~/proxies/ice/proxychains.conf curl -s -X GET "https://api.terminaldweller.com/crypto/v1/price?name=CAKE&unit=USD" | jq ".price"); then
- if [ -n "${CAKE_OUTPUT}" ]; then
- echo "${CAKE_OUTPUT}" >${PRICE_CACHE_OUTPUT_CAKE}
- fi
- fi
- fi
+ # if [ $(($(stat --format=%Y $PRICE_CACHE_OUTPUT_CAKE) + PRICE_TIME_CACHE)) -gt "$(date +%s)" ]; then
+ # :
+ # else
+ # if CAKE_OUTPUT=$(proxychains4 -q -f ~/proxies/ice/proxychains.conf curl -s -X GET "https://api.terminaldweller.com/crypto/v1/price?name=CAKE&unit=USD" | jq ".price"); then
+ # if [ -n "${CAKE_OUTPUT}" ]; then
+ # echo "${CAKE_OUTPUT}" >${PRICE_CACHE_OUTPUT_CAKE}
+ # fi
+ # fi
+ # fi
if [ $(($(stat --format=%Y $PRICE_CACHE_OUTPUT_XMR) + PRICE_TIME_CACHE)) -gt "$(date +%s)" ]; then
:
else
- if XMR_OUTPUT=$(proxychains4 -q -f ~/proxies/ice/proxychains.conf curl -s -X GET "https://api.terminaldweller.com/crypto/v1/price?name=XMR&unit=USD" | jq ".price"); then
+ if XMR_OUTPUT=$(proxychains4 -q -f ~/proxies/ice/proxychains.conf curl -s -X GET "https://api.terminaldweller.com/crypto/v1/price?name=XMR&unit=USD" | jq ".price" | cut -d. -f1); then
if [ -n "${XMR_OUTPUT}" ]; then
echo "${XMR_OUTPUT}" >${PRICE_CACHE_OUTPUT_XMR}
fi
fi
fi
- result="$(cat ${PRICE_CACHE_OUTPUT_ETH})"/"$(cat ${PRICE_CACHE_OUTPUT_CAKE})"/"$(cat ${PRICE_CACHE_OUTPUT_XMR})"
+ # result="$(cat ${PRICE_CACHE_OUTPUT_ETH})"/"$(cat ${PRICE_CACHE_OUTPUT_CAKE})"/"$(cat ${PRICE_CACHE_OUTPUT_XMR})"
+ result="$(cat ${PRICE_CACHE_OUTPUT_ETH})"/"$(cat ${PRICE_CACHE_OUTPUT_XMR})"
echo "${result}"
}
-tmux_session_info=" #S:#I.#P"
+user_service_status() {
+ if sv status ~/service/* | grep -v -E "^run:" >/dev/null 2>&1; then
+ echo DOWN
+ else
+ echo UP
+ fi
+}
+
+tmux_session_info=" #S:#I.#P:#D"
branch_info="#[fg=colour16]$(repo_info)#[fg=colour0 bg=colour39]"$(git_branch_info)
untracked_info="#[fg=colour255 bg=colour244]"$(git_untracked_info)
deletions_info="#[fg=colour255 bg=colour1]"$(gitdeletions)
additions_info="#[fg=colour255 bg=colour22]"$(gitadditions)
eth_price="#[fg=colour16 bg=colour37]"$(get_eth_price)
+service_status_info="#[fg=colour16 bg=colour65, bold]"$(user_service_status)
-echo "#[fg=colour255 bg=colour26]$tmux_session_info #[fg=colour26 bg=colour39]$SEPARATOR_RIGHT_BOLD \
+echo "#[fg=colour255 bg=colour26]${tmux_session_info} #[fg=colour26 bg=colour39]$SEPARATOR_RIGHT_BOLD \
$branch_info #[fg=colour39 bg=colour22]$SEPARATOR_RIGHT_BOLD \
$additions_info #[fg=colour22 bg=colour1]$SEPARATOR_RIGHT_BOLD \
$deletions_info #[fg=colour1 bg=colour244]$SEPARATOR_RIGHT_BOLD \
$untracked_info #[fg=colour244 bg=colour37]$SEPARATOR_RIGHT_BOLD \
-$eth_price #[fg=colour37 bg=colour16]$SEPARATOR_RIGHT_BOLD"
+$eth_price #[fg=colour37 bg=colour65]$SEPARATOR_RIGHT_BOLD \
+$service_status_info #[fg=colour65 bg=colour16]$SEPARATOR_RIGHT_BOLD"