From c91921a1259c28bb67a932bec5602a1628d9ea97 Mon Sep 17 00:00:00 2001 From: Yan Lin Date: Mon, 28 Jul 2025 13:46:03 +0200 Subject: [PATCH] Add note project and improve directory creation MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Add Obsidian notes project configuration - Enhance project launcher with automatic directory creation for local and remote paths 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude --- config/projects.nix | 7 +++++++ scripts/project-launcher.sh | 33 +++++++++++++++++++++++++++++++++ 2 files changed, 40 insertions(+) diff --git a/config/projects.nix b/config/projects.nix index aaa8243..ee2a00d 100644 --- a/config/projects.nix +++ b/config/projects.nix @@ -14,6 +14,13 @@ description = "Homelab Deployment"; }; + note = { + template = "basic"; + name = "note"; + codePath = "/Users/yanlin/Obsidian/Personal"; + description = "Obsidian notes"; + }; + blog = { template = "content"; name = "blog"; diff --git a/scripts/project-launcher.sh b/scripts/project-launcher.sh index 38e8d33..50af8e6 100755 --- a/scripts/project-launcher.sh +++ b/scripts/project-launcher.sh @@ -59,6 +59,39 @@ PAPER_PATH=$(echo "$PROJECT_CONFIG" | jq -r '.paperPath // empty') SERVER=$(echo "$PROJECT_CONFIG" | jq -r '.server // empty') REMOTE_DIR=$(echo "$PROJECT_CONFIG" | jq -r '.remoteDir // empty') +# Create directories if they don't exist +create_directory() { + local dir_path="$1" + local dir_name="$2" + + if [ -n "$dir_path" ] && [ "$dir_path" != "null" ]; then + if [ ! -d "$dir_path" ]; then + if mkdir -p "$dir_path" 2>/dev/null; then + printf "\033[2mCreated %s directory: %s\033[0m\n" "$dir_name" "$dir_path" + else + echo "Warning: Could not create $dir_name directory: $dir_path" + echo "Please check permissions or create it manually." + fi + fi + fi +} + +# Ensure required directories exist +create_directory "$CODE_PATH" "code" +create_directory "$CONTENT_PATH" "content" +create_directory "$PAPER_PATH" "paper" + +# Create remote directory if server connection is configured +if [ -n "$SERVER" ] && [ -n "$REMOTE_DIR" ]; then + printf "\033[2mEnsuring remote directory exists: %s:%s\033[0m\n" "$SERVER" "$REMOTE_DIR" + if ssh "$SERVER" "mkdir -p \"$REMOTE_DIR\"" 2>/dev/null; then + printf "\033[2mRemote directory ready: %s:%s\033[0m\n" "$SERVER" "$REMOTE_DIR" + else + echo "Warning: Could not create or verify remote directory: $SERVER:$REMOTE_DIR" + echo "Please check SSH connection and permissions." + fi +fi + # Launch appropriate template case "$TEMPLATE" in "basic")