aboutsummaryrefslogtreecommitdiffstats
path: root/tmux
diff options
context:
space:
mode:
authorterminaldweller <thabogre@gmail.com>2021-05-14 18:14:50 +0000
committerterminaldweller <thabogre@gmail.com>2021-05-14 18:14:50 +0000
commit6e528248414e330c9e25e81596ab47b8b8a5b701 (patch)
treee1aa41a7f3198eeac187e6177ec7d4a33db229d3 /tmux
downloadscripts-master.tar.gz
scripts-master.zip
first commitmaster
Diffstat (limited to 'tmux')
-rw-r--r--tmux/common.sh7
-rwxr-xr-xtmux/date.sh16
-rwxr-xr-xtmux/jdat.sh5
-rwxr-xr-xtmux/vcs_info.sh66
4 files changed, 94 insertions, 0 deletions
diff --git a/tmux/common.sh b/tmux/common.sh
new file mode 100644
index 0000000..2c637ce
--- /dev/null
+++ b/tmux/common.sh
@@ -0,0 +1,7 @@
+#!/usr/bin/env bash
+
+SEPARATOR_LEFT_BOLD=""
+SEPARATOR_LEFT_THIN=""
+SEPARATOR_RIGHT_BOLD=""
+SEPARATOR_RIGHT_THIN=""
+
diff --git a/tmux/date.sh b/tmux/date.sh
new file mode 100755
index 0000000..1c08e47
--- /dev/null
+++ b/tmux/date.sh
@@ -0,0 +1,16 @@
+#!/usr/bin/env bash
+
+# source common.sh
+SEPARATOR_LEFT_BOLD=""
+SEPARATOR_LEFT_THIN=""
+
+RESULT=$(date +"%a %D %H:%M")
+
+DAY="#[fg=colour255 bg=colour31]"$(echo $RESULT | gawk '{print $1}')
+DATE="#[fg=colour255 bg=colour31]"$(echo $RESULT | gawk '{print $2}')
+TIME="#[fg=colour255 bg=colour31]"$(echo $RESULT | gawk '{print $3}')
+UTC_TIME="#[fg=colour255 bg=colour75]"$(date -u +"%H:%I")
+# JDATE="#[fg=colour255 bg=colour29]"$(jdate | gawk '{print $2" "$3}')
+JDATE="#[fg=colour255 bg=colour29]"$(jdate | gawk '{print $2" "$3}')
+
+echo "#[fg=colour29 bg=colour16]$SEPARATOR_LEFT_BOLD$JDATE #[fg=colour31 bg=colour29]$SEPARATOR_LEFT_BOLD$DAY $SEPARATOR_LEFT_THIN $DATE $SEPARATOR_LEFT_THIN $TIME #[fg=colour75 bg=colour31]$SEPARATOR_LEFT_BOLD$UTC_TIME "
diff --git a/tmux/jdat.sh b/tmux/jdat.sh
new file mode 100755
index 0000000..3f8f378
--- /dev/null
+++ b/tmux/jdat.sh
@@ -0,0 +1,5 @@
+#!/usr/bin/env bash
+
+JDATE=$(jdate | gawk '{print $2" "$3}')
+
+echo $JDATE
diff --git a/tmux/vcs_info.sh b/tmux/vcs_info.sh
new file mode 100755
index 0000000..1369b3d
--- /dev/null
+++ b/tmux/vcs_info.sh
@@ -0,0 +1,66 @@
+#!/usr/bin/env bash
+
+source common.sh
+SEPARATOR_RIGHT_BOLD=""
+SEPARATOR_RIGHT_THIN=""
+
+MIN_MAJOR_VERSION="2"
+MIN_MINOR_VERSION="1"
+TMUX_VERSION="$(tmux -V)"
+
+get_tmux_cwd() {
+ tmux display -p -F "#{pane_current_path}"
+}
+tmux_path=$(get_tmux_cwd)
+cd $tmux_path
+IFS='/' read -ra tmux_path_array <<< "$tmux_path"
+pos=$(( ${#tmux_path_array[*]} - 1 ))
+last=${tmux_path_array[$pos]}
+for i in "${tmux_path_array[@]}"
+do
+ if [[ $i == $last ]]; then
+ shortened_path+=$i
+ else
+ shortened_path+=${i:0:1}/
+ fi
+done
+
+function gitadditions {
+ git rev-parse --git-dir > /dev/null 2>&1
+ if [[ $? == 0 ]]; then
+ insertions=$(git --no-pager diff --numstat | awk '{sum1+=$1}END{print sum1}')
+ echo + $insertions
+ fi
+}
+
+function gitdeletions {
+ git rev-parse --git-dir > /dev/null 2>&1
+ if [[ $? == 0 ]]; then
+ deletions=$(git --no-pager diff --numstat | awk '{sum2+=$2}END{print sum2}')
+ echo - $deletions
+ fi
+}
+
+function git_untracked_info {
+ git rev-parse --git-dir > /dev/null 2>&1
+ if [[ $? == 0 ]]; then
+ untracked=$(git ls-files --others --exclude-standard | wc -w)
+ echo ⋯ $untracked
+ fi
+}
+
+function git_branch_info {
+ git rev-parse --git-dir > /dev/null 2>&1
+ if [[ $? == 0 ]]; then
+ branch=$(git rev-parse --abbrev-ref HEAD)
+ echo " "$branch
+ fi
+}
+
+tmux_session_info=" #S:#I.#P"
+branch_info="#[fg=colour24]#[fg=colour255 bg=colour65]"$(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)
+
+echo "#[fg=colour255 bg=colour61]$shortened_path #[fg=colour61 bg=colour26]$SEPARATOR_RIGHT_BOLD#[fg=colour255 bg=colour26]$tmux_session_info #[fg=colour26 bg=colour65]$SEPARATOR_RIGHT_BOLD $branch_info #[fg=colour65 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=colour16]$SEPARATOR_RIGHT_BOLD"