diff --git a/scripts/project-launcher.sh b/scripts/project-launcher.sh index b68c23c..ea4fa27 100755 --- a/scripts/project-launcher.sh +++ b/scripts/project-launcher.sh @@ -103,6 +103,16 @@ if [ -n "$SERVER" ] && [ -n "$REMOTE_DIR" ]; then fi fi +# Check if session already exists and attach if it does +if is_session_running "$SESSION_NAME"; then + printf "\033[1;32mAttaching to existing session: %s\033[0m\n" "$SESSION_NAME" + tmux attach-session -t "$SESSION_NAME" + exit 0 +fi + +# Update papis cache +papis cache reset > /dev/null 2>&1 + # Launch appropriate template case "$TEMPLATE" in "basic") @@ -123,4 +133,4 @@ case "$TEMPLATE" in echo "Error: Unknown template '$TEMPLATE'" exit 1 ;; -esac \ No newline at end of file +esac diff --git a/scripts/templates/basic.sh b/scripts/templates/basic.sh index 4314958..2315974 100755 --- a/scripts/templates/basic.sh +++ b/scripts/templates/basic.sh @@ -11,11 +11,6 @@ if [ -z "$SESSION_NAME" ] || [ -z "$CODE_PATH" ]; then exit 1 fi -if tmux has-session -t $SESSION_NAME 2>/dev/null; then - tmux attach-session -t $SESSION_NAME - exit 0 -fi - tmux new-session -d -s $SESSION_NAME -c "$CODE_PATH" tmux rename-window -t $SESSION_NAME:1 "nvim" tmux send-keys -t $SESSION_NAME:1 "nvim" C-m diff --git a/scripts/templates/research.sh b/scripts/templates/research.sh index e5475e6..18b7ece 100755 --- a/scripts/templates/research.sh +++ b/scripts/templates/research.sh @@ -14,11 +14,6 @@ if [ -z "$SESSION_NAME" ] || [ -z "$CODE_PATH" ] || [ -z "$PAPER_PATH" ]; then exit 1 fi -if tmux has-session -t $SESSION_NAME 2>/dev/null; then - tmux attach-session -t $SESSION_NAME - exit 0 -fi - # Create windows for code tmux new-session -d -s $SESSION_NAME -c "$CODE_PATH" tmux rename-window -t $SESSION_NAME:1 "code"