From b0f5fe18d83f55cc73d45a177a624bc46ae715ea Mon Sep 17 00:00:00 2001 From: Bruno Sutic Date: Tue, 26 Aug 2014 12:24:31 +0200 Subject: [PATCH] Create a session saver script --- scripts/session_saver.sh | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100755 scripts/session_saver.sh diff --git a/scripts/session_saver.sh b/scripts/session_saver.sh new file mode 100755 index 0000000..639b0d8 --- /dev/null +++ b/scripts/session_saver.sh @@ -0,0 +1,33 @@ +#!/usr/bin/env bash + +CURRENT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" + +source "$CURRENT_DIR/helpers.sh" + +dump_format() { + local delimiter=$'\t' + local format + format+="#{session_name}" + format+="${delimiter}" + format+="#{window_index}" + format+="${delimiter}" + format+="#{window_name}" + format+="${delimiter}" + format+="#{pane_current_path}" + echo "$format" +} + +dump() { + tmux list-panes -a -F "$(dump_format)" +} + +save_all_sessions() { + mkdir -p $HOME/.tmux + dump > $HOME/.tmux/session + display_message "Saved all Tmux sessions!" +} + +main() { + save_all_sessions +} +main