tmux-sessionist
tmux-sessionist copied to clipboard
Should set session start-diretory to current working directory.
If you are concerned about making this the default behavior, then maybe make it opt-in using a variable set in ~/.tmux.conf
Hi, I'm curious, why do you need this feature? I usually start new sessions in directories that are different than the current working dir.
@bruno- by default the behavior of <prefix>, C is to use the same start-directory as whatever the current session's start-directory is--regardless of what directory your pane happens to be in at the time <prefix>, C is invoked.
Most of the time when when I create new sessions I am doing so because I want to be working in an entirely different context--I want new panes & windows to start off in a specific directory.
As a shortcut, the create named session feature doesn't have much practical value for me if the new named session always has the same start-directory as the old.`
In the past I have simply created a new terminal window and started my tmux sessions after navigating to the specific project directory that I wanted to be the start directory.
Hi.
I was bothered by this issue as well and solved it by making the following changes to new_session_promt.sh:
#!/usr/bin/env bash
CURRENT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
main() { tmux command -p "new session name:" "run '$CURRENT_DIR/new_session.sh "%1" #{pane_current_path}'" } main
and then to use the current pane directory I have added this in new_session.sh:
#!/usr/bin/env bash
CURRENT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
#global variable SESSION_NAME="$1" SESSION_PATH="$2"
source "$CURRENT_DIR/helpers.sh"
session_name_not_provided() { [ -z "$SESSION_NAME" ] }
create_new_tmux_session() { if session_name_not_provided; then exit 0 elif session_exists; then 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" -c "$SESSION_PATH" switch_to_session "$SESSION_NAME" fi }
main() { create_new_tmux_session } main
This will always use the directory of the current pane when a new session is created. Please let me know if you can include this in the current plugin.
Best Fab
NB: It is just a quick hack, the checks for provided session names etc. should be modified in a release version