mirror of
https://github.com/tmux-plugins/tmux-resurrect.git
synced 2024-11-22 04:18:48 +00:00
parent
1280e659d5
commit
70d78e8d73
@ -1,6 +1,7 @@
|
||||
# Changelog
|
||||
|
||||
### master
|
||||
- saving a new session does not remove the previous one
|
||||
|
||||
### v0.0.1, 2014-08-26
|
||||
- started a project
|
||||
|
@ -1,3 +1,7 @@
|
||||
# constants
|
||||
SESSIONS_DIR="$HOME/.tmux/sessions"
|
||||
|
||||
# helper functions
|
||||
get_tmux_option() {
|
||||
local option="$1"
|
||||
local default_value="$2"
|
||||
@ -33,3 +37,12 @@ display_message() {
|
||||
# restores original 'display-time' value
|
||||
tmux set-option -gq display-time "$saved_display_time"
|
||||
}
|
||||
|
||||
session_path() {
|
||||
local timestamp="$(date +"%Y-%m-%dT%H:%M:%S")"
|
||||
echo "${SESSIONS_DIR}/tmux_session_${timestamp}.txt"
|
||||
}
|
||||
|
||||
last_session_path() {
|
||||
echo "${SESSIONS_DIR}/last"
|
||||
}
|
||||
|
@ -70,7 +70,7 @@ restore_pane() {
|
||||
restore_all_sessions() {
|
||||
while read line; do
|
||||
restore_pane "$line"
|
||||
done < $HOME/.tmux/session
|
||||
done < $(last_session_path)
|
||||
display_message "Restored all Tmux sessions!"
|
||||
}
|
||||
|
||||
|
@ -22,8 +22,10 @@ dump() {
|
||||
}
|
||||
|
||||
save_all_sessions() {
|
||||
mkdir -p $HOME/.tmux
|
||||
dump > $HOME/.tmux/session
|
||||
local session_path="$(session_path)"
|
||||
mkdir -p "$SESSIONS_DIR"
|
||||
dump > $session_path
|
||||
ln -fs "$session_path" "$(last_session_path)"
|
||||
display_message "Saved all Tmux sessions!"
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user