Add session detection and running indicator to project launcher

- 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 <noreply@anthropic.com>
This commit is contained in:
Yan Lin 2025-07-28 16:58:28 +02:00
parent a6162712e3
commit f7bfb04b38
2 changed files with 18 additions and 7 deletions

View file

@ -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";

View file

@ -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
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