Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions scripts/tmux_spinner.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
2 changes: 2 additions & 0 deletions scripts/variables.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"