From 03e42c0bd0b564fd4d215511cd293573a74949bf Mon Sep 17 00:00:00 2001 From: Matt Koscica Date: Mon, 3 Jun 2024 14:37:51 +0200 Subject: [PATCH] Add new option @resurrect-spinner-chars to customise spinner chars MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Example: Add something like the following to your .tmux.conf: set-option -g @resurrect-spinner-chars '⠋⠙⠹⠸⠼⠴⠦⠧⠇⠏' (Note that using Unicode characters in your configuration also requires the use of a supporting terminal locale.) --- scripts/tmux_spinner.sh | 13 ++++++++++--- scripts/variables.sh | 2 ++ 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/scripts/tmux_spinner.sh b/scripts/tmux_spinner.sh index 9b1b9792..e1bdaab7 100755 --- a/scripts/tmux_spinner.sh +++ b/scripts/tmux_spinner.sh @@ -12,17 +12,24 @@ # .. # kill $SPINNER_PID # Stops spinner and displays 'End message!' +CURRENT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" + +source "$CURRENT_DIR/helpers.sh" +source "$CURRENT_DIR/variables.sh" + MESSAGE="$1" END_MESSAGE="$2" -SPIN='-\|/' +DEFAULT_SPIN_CHARS='-\|/' +SPIN_CHARS=$( get_tmux_option "$spinner_chars_option" "$DEFAULT_SPIN_CHARS" ) +SPIN_CHARS_LENGTH=$( echo -n "$SPIN_CHARS" | wc -m ) trap "tmux display-message '$END_MESSAGE'; exit" SIGINT SIGTERM main() { local i=0 while true; do - i=$(( (i+1) %4 )) - tmux display-message " ${SPIN:$i:1} $MESSAGE" + i=$(( (i+1) % $SPIN_CHARS_LENGTH )) + tmux display-message " ${SPIN_CHARS:$i:1} $MESSAGE" sleep 0.1 done } diff --git a/scripts/variables.sh b/scripts/variables.sh index 9d42e02a..7d0727db 100644 --- a/scripts/variables.sh +++ b/scripts/variables.sh @@ -46,3 +46,5 @@ hook_prefix="@resurrect-hook-" delete_backup_after_option="@resurrect-delete-backup-after" default_delete_backup_after="30" # days + +spinner_chars_option="@resurrect-spinner-chars"