Unverified Commit 18f4d109 authored by Bruno Sutic's avatar Bruno Sutic
Browse files

Spin a spinner while tmux sessions are restored

Closes #16
parent 655bdb9a
......@@ -2,6 +2,7 @@
### master
- refactor checking if saved tmux session exists
- spinner while tmux sessions are restored
### v0.0.5, 2014-08-28
- restore pane processes
......
......@@ -4,6 +4,7 @@ CURRENT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
source "$CURRENT_DIR/helpers.sh"
source "$CURRENT_DIR/process_restore_helpers.sh"
source "$CURRENT_DIR/spinner_helpers.sh"
is_line_type() {
local line_type="$1"
......@@ -150,6 +151,7 @@ restore_active_and_alternate_sessions() {
main() {
if supported_tmux_version_ok && check_saved_session_exists; then
start_spinner
restore_all_sessions
restore_all_pane_processes
restore_pane_layout_for_each_window >/dev/null 2>&1
......@@ -157,6 +159,7 @@ main() {
restore_active_pane_for_each_window
restore_active_and_alternate_windows
restore_active_and_alternate_sessions
stop_spinner
display_message "Restored all Tmux sessions!"
fi
}
......
start_spinner() {
$CURRENT_DIR/tmux_spinner.sh "Restoring sessions..." "Restored all Tmux sessions!" &
export SPINNER_PID=$!
}
stop_spinner() {
kill $SPINNER_PID
}
#!/usr/bin/env bash
# This script shows tmux spinner with a message. It is intended to be running
# as a background process which should be `kill`ed at the end.
#
# Example usage:
#
# ./tmux_spinner.sh "Working..." "End message!" &
# SPINNER_PID=$!
# ..
# .. execute commands here
# ..
# kill $SPINNER_PID # Stops spinner and displays 'End message!'
MESSAGE="$1"
END_MESSAGE="$2"
SPIN='-\|/'
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"
sleep 0.1
done
}
main
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment