From f7bfb04b3863333dc2c3117d7d7fd8705f5401ab Mon Sep 17 00:00:00 2001 From: Yan Lin Date: Mon, 28 Jul 2025 16:58:28 +0200 Subject: [PATCH] Add session detection and running indicator to project launcher MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Add is_session_running() function to detect active tmux sessions - Update project display to show green "• Running" indicator for active projects - Fix session detection to use correct session names from project config - Improve project listing with real-time status information - Update projects.nix with shortened key names and descriptions Features: - Visual feedback for which projects are currently running - Uses proper tmux session names from project configuration - Clean green indicator that only appears for running sessions - Maintains existing project launcher functionality and layout 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude --- config/projects.nix | 4 ++-- scripts/project-launcher.sh | 21 ++++++++++++++++----- 2 files changed, 18 insertions(+), 7 deletions(-) diff --git a/config/projects.nix b/config/projects.nix index c4d1d05..c7fb8f7 100644 --- a/config/projects.nix +++ b/config/projects.nix @@ -41,7 +41,7 @@ name = "MDShortcut"; codePath = "/Users/yanlin/Documents/Projects/Material Design Shortcut/MDShortcut-dev"; paperPath = "/Users/yanlin/Documents/Projects/Material Design Shortcut/MDShortcut-paper"; - description = "Material Design Shortcut research project"; + description = "Material design shortcut"; server = "aicloud"; remoteDir = "~/MDS"; }; @@ -53,7 +53,7 @@ description = "DAKI3 course Demo code"; }; - diffdismatter = { + ddm = { template = "research"; name = "DiffDisMatter"; codePath = "/Users/yanlin/Documents/Projects/Inverse Design of Disordered Materials/DiffDisMatter-dev"; diff --git a/scripts/project-launcher.sh b/scripts/project-launcher.sh index 50af8e6..82b91ef 100755 --- a/scripts/project-launcher.sh +++ b/scripts/project-launcher.sh @@ -8,6 +8,12 @@ CONFIG_DIR="$(dirname "$0")/../config" PROJECTS_JSON="$CONFIG_DIR/projects.json" TEMPLATES_DIR="$(dirname "$0")/templates" +# Check if tmux session is running +is_session_running() { + local session_name="$1" + tmux has-session -t "$session_name" 2>/dev/null +} + if [ -z "$PROJECT_NAME" ]; then printf "\033[1;36mAvailable Projects:\033[0m\n\n" @@ -19,11 +25,16 @@ if [ -z "$PROJECT_NAME" ]; then fi # Parse and display projects with descriptions - jq -r '.projects | to_entries[] | "\(.key)|\(.value.description)|\(.value.template)"' "$PROJECTS_JSON" 2>/dev/null | \ - while IFS='|' read -r name desc template; do - # Format with consistent spacing - printf " \033[1;32m%-12s\033[0m \033[2m[%-8s]\033[0m %s\n" \ - "$name" "$template" "$desc" + jq -r '.projects | to_entries[] | "\(.key)|\(.value.description)|\(.value.template)|\(.value.name)"' "$PROJECTS_JSON" 2>/dev/null | \ + while IFS='|' read -r name desc template session_name; do + # Check if session is running and format accordingly + if is_session_running "$session_name"; then + printf " \033[1;32m%-12s\033[0m \033[2m[%-8s]\033[0m %s\033[1;32m • Running\033[0m\n" \ + "$name" "$template" "$desc" + else + printf " \033[1;32m%-12s\033[0m \033[2m[%-8s]\033[0m %s\n" \ + "$name" "$template" "$desc" + fi done if [ $? -ne 0 ]; then