mirror of
https://github.com/tmux-plugins/tmux-resurrect.git
synced 2025-09-09 15:43:31 +00:00
Compare commits
3 Commits
Author | SHA1 | Date | |
---|---|---|---|
ee1ab0c728 | |||
18f4d1099e | |||
655bdb9a75 |
@ -2,6 +2,10 @@
|
||||
|
||||
### master
|
||||
|
||||
### v0.1.0, 2014-08-28
|
||||
- refactor checking if saved tmux session exists
|
||||
- spinner while tmux sessions are restored
|
||||
|
||||
### v0.0.5, 2014-08-28
|
||||
- restore pane processes
|
||||
- user option for disabling pane process restoring
|
||||
|
@ -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"
|
||||
@ -15,8 +16,8 @@ is_line_type() {
|
||||
check_saved_session_exists() {
|
||||
local saved_session="$(last_session_path)"
|
||||
if [ ! -f $saved_session ]; then
|
||||
display_message "Saved session not found!"
|
||||
exit
|
||||
display_message "Saved tmux session not found!"
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
@ -149,8 +150,8 @@ restore_active_and_alternate_sessions() {
|
||||
}
|
||||
|
||||
main() {
|
||||
if supported_tmux_version_ok; then
|
||||
check_saved_session_exists
|
||||
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
|
||||
@ -158,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
|
||||
}
|
||||
|
8
scripts/spinner_helpers.sh
Normal file
8
scripts/spinner_helpers.sh
Normal file
@ -0,0 +1,8 @@
|
||||
start_spinner() {
|
||||
$CURRENT_DIR/tmux_spinner.sh "Restoring sessions..." "Restored all Tmux sessions!" &
|
||||
export SPINNER_PID=$!
|
||||
}
|
||||
|
||||
stop_spinner() {
|
||||
kill $SPINNER_PID
|
||||
}
|
29
scripts/tmux_spinner.sh
Executable file
29
scripts/tmux_spinner.sh
Executable file
@ -0,0 +1,29 @@
|
||||
#!/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
|
Reference in New Issue
Block a user