Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Christian Salzmann-Jaeckel
tmux-resurrect
Commits
18f4d109
Unverified
Commit
18f4d109
authored
Aug 28, 2014
by
Bruno Sutic
Browse files
Spin a spinner while tmux sessions are restored
Closes #16
parent
655bdb9a
Changes
4
Hide whitespace changes
Inline
Side-by-side
CHANGELOG.md
View file @
18f4d109
...
...
@@ -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
...
...
scripts/session_restorer.sh
View file @
18f4d109
...
...
@@ -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
}
...
...
scripts/spinner_helpers.sh
0 → 100644
View file @
18f4d109
start_spinner
()
{
$CURRENT_DIR
/tmux_spinner.sh
"Restoring sessions..."
"Restored all Tmux sessions!"
&
export
SPINNER_PID
=
$!
}
stop_spinner
()
{
kill
$SPINNER_PID
}
scripts/tmux_spinner.sh
0 → 100755
View file @
18f4d109
#!/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
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment