diff --git a/scripts/new_session.sh b/scripts/new_session.sh index 4e8e5f3..7046cbc 100755 --- a/scripts/new_session.sh +++ b/scripts/new_session.sh @@ -4,6 +4,7 @@ CURRENT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" # global variable SESSION_NAME="$1" +SESSION_START_DIR="$2" source "$CURRENT_DIR/helpers.sh" @@ -18,7 +19,7 @@ create_new_tmux_session() { switch_to_session "$SESSION_NAME" display_message "Switched to existing session ${SESSION_NAME}" "2000" else - TMUX="" tmux -S "$(tmux_socket)" new-session -d -s "$SESSION_NAME" + TMUX="" tmux -S "$(tmux_socket)" new-session -d -s "$SESSION_NAME" -c "$SESSION_START_DIR" switch_to_session "$SESSION_NAME" fi } diff --git a/scripts/new_session_prompt.sh b/scripts/new_session_prompt.sh index f4eb603..53b8088 100755 --- a/scripts/new_session_prompt.sh +++ b/scripts/new_session_prompt.sh @@ -1,8 +1,9 @@ #!/usr/bin/env bash CURRENT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" +SESSION_START_DIR="$1" main() { - tmux command -p "new session name:" "run '$CURRENT_DIR/new_session.sh \"%1\"'" + tmux command -p "new session name:" "run '$CURRENT_DIR/new_session.sh \"%1\" \"$SESSION_START_DIR\"'" } main diff --git a/sessionist.tmux b/sessionist.tmux index 25aae7d..8d34fa2 100755 --- a/sessionist.tmux +++ b/sessionist.tmux @@ -10,6 +10,7 @@ tmux_option_alternate="@sessionist-alternate" default_key_bindings_new="C" tmux_option_new="@sessionist-new" +starting_directory="@sessionist-start-directory" default_key_bindings_promote_pane="@" tmux_option_promote_pane="@sessionist-promote-pane" @@ -44,9 +45,10 @@ set_alternate_session_binding() { # it will switch to existing session. set_new_session_binding() { local key_bindings=$(get_tmux_option "$tmux_option_new" "$default_key_bindings_new") + local start_directory=$(get_tmux_option "$starting_directory" "$HOME") local key for key in $key_bindings; do - tmux bind "$key" run "$CURRENT_DIR/scripts/new_session_prompt.sh" + tmux bind "$key" run "$CURRENT_DIR/scripts/new_session_prompt.sh '$start_directory'" done }