Sessions directory is configurable

Close #10
This commit is contained in:
Bruno Sutic 2014-08-26 15:40:50 +02:00
parent 70d78e8d73
commit 5c2853a55f
No known key found for this signature in database
GPG Key ID: 66D96E4F2F7EF26C
3 changed files with 11 additions and 5 deletions

View File

@ -2,6 +2,7 @@
### master
- saving a new session does not remove the previous one
- make the directory where sessions are stored configurable
### v0.0.1, 2014-08-26
- started a project

View File

@ -1,5 +1,6 @@
# constants
SESSIONS_DIR="$HOME/.tmux/sessions"
# configurable constants
default_sessions_dir="$HOME/.tmux/sessions"
sessions_dir_option="@sessions-dir"
# helper functions
get_tmux_option() {
@ -38,11 +39,15 @@ display_message() {
tmux set-option -gq display-time "$saved_display_time"
}
sessions_dir() {
echo $(get_tmux_option "$sessions_dir_option" "$default_sessions_dir")
}
session_path() {
local timestamp="$(date +"%Y-%m-%dT%H:%M:%S")"
echo "${SESSIONS_DIR}/tmux_session_${timestamp}.txt"
echo "$(sessions_dir)/tmux_session_${timestamp}.txt"
}
last_session_path() {
echo "${SESSIONS_DIR}/last"
echo "$(sessions_dir)/last"
}

View File

@ -23,7 +23,7 @@ dump() {
save_all_sessions() {
local session_path="$(session_path)"
mkdir -p "$SESSIONS_DIR"
mkdir -p "$(sessions_dir)"
dump > $session_path
ln -fs "$session_path" "$(last_session_path)"
display_message "Saved all Tmux sessions!"