feat: add iCloud vault support and launcher command installation
- Add new /install-claudesidian-command to create shell alias for launching vault from anywhere - Add automatic iCloud Drive vault detection in init-bootstrap - Add iCloud-specific search path with maxdepth 5 for nested structure - Add fallback prompt asking about iCloud if vault not found - Update README with launcher command documentation and usage examples - Shell command auto-resumes existing sessions or starts new ones This addresses user feedback about iCloud vault detection and adds convenient shell launcher similar to obsidian-cli pattern. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -51,7 +51,12 @@ Then generate a customized CLAUDE.md file tailored to their needs.
|
||||
|
||||
3. **Gather Vault Information**
|
||||
- Search common locations for existing Obsidian vaults (.obsidian folder)
|
||||
- Check: ~/Documents, ~/Desktop, home directory, current directory parent
|
||||
- Check these paths with appropriate depth limits:
|
||||
- `~/Documents` (maxdepth 3)
|
||||
- `~/Desktop` (maxdepth 3)
|
||||
- `~/Library/Mobile Documents/iCloud~md~obsidian/Documents` (maxdepth 5 - iCloud vaults)
|
||||
- Home directory `~/` (maxdepth 2)
|
||||
- Current directory parent (maxdepth 2)
|
||||
- If found, ask: "Found Obsidian vault at [path]. Is this the vault you want
|
||||
to import?"
|
||||
- Count files correctly: `find [path] -type f -name "*.md" | wc -l` (no depth
|
||||
@@ -64,8 +69,11 @@ Then generate a customized CLAUDE.md file tailored to their needs.
|
||||
- Check for daily notes folder and format
|
||||
- Identify most active folders by file count
|
||||
- Detect if using PARA, Zettelkasten, Johnny Decimal, or custom
|
||||
- If not the right one or none found, ask for path to existing vault
|
||||
- If no existing vault, they're starting fresh
|
||||
- If not the right one or none found:
|
||||
- Ask: "Is your vault stored in iCloud Drive? (yes/no)"
|
||||
- If yes: "Please enter the full path to your vault (e.g., ~/Library/Mobile Documents/iCloud~md~obsidian/Documents/YourVault)"
|
||||
- If no: "Please enter the path to your existing vault, or type 'skip' to start fresh"
|
||||
- If no existing vault or user skips, they're starting fresh
|
||||
|
||||
4. **Ask Configuration Questions**
|
||||
- "What's your name?" (for personalization)
|
||||
@@ -349,6 +357,26 @@ If the user's response is unclear:
|
||||
- Example: "I want to make sure I import the right vault. Please type the number
|
||||
of your choice (1, 2, or 3)."
|
||||
|
||||
### iCloud Vault Search Implementation
|
||||
|
||||
When searching for vaults, use this find command pattern:
|
||||
|
||||
```bash
|
||||
# Standard locations (shallow search)
|
||||
find ~/Documents ~/Desktop -maxdepth 3 -type d -name ".obsidian" 2>/dev/null
|
||||
|
||||
# iCloud location (deeper search needed due to nested structure)
|
||||
find ~/Library/Mobile\ Documents/iCloud~md~obsidian/Documents -maxdepth 5 -type d -name ".obsidian" 2>/dev/null
|
||||
|
||||
# Home directory (shallow to avoid deep recursion)
|
||||
find ~ -maxdepth 2 -type d -name ".obsidian" 2>/dev/null
|
||||
```
|
||||
|
||||
The iCloud path requires:
|
||||
- Higher maxdepth (5) due to nested folder structure
|
||||
- Escaped spaces in path name
|
||||
- Silent error handling (2>/dev/null) as many users won't have iCloud
|
||||
|
||||
## Interactive Example
|
||||
|
||||
````
|
||||
@@ -407,8 +435,8 @@ First-run marker removed
|
||||
|
||||
Now let me ask you a few questions to customize your setup:
|
||||
|
||||
🔍 **Searching for existing Obsidian vaults...** [Searches ~/Documents,
|
||||
~/Desktop, ~/, and parent directories]
|
||||
🔍 **Searching for existing Obsidian vaults...**
|
||||
[Searches ~/Documents, ~/Desktop, iCloud Drive, home directory, and parent directories]
|
||||
|
||||
### Case 1: Single Vault Found
|
||||
|
||||
@@ -457,6 +485,26 @@ User: yes
|
||||
Great! I'll import your vault to OLD_VAULT/ where it will be safely preserved.
|
||||
You can migrate files to the PARA folders at your own pace.
|
||||
|
||||
### Case 3: No Vaults Found (iCloud Check)
|
||||
|
||||
🔍 **No Obsidian vaults found in common locations.**
|
||||
|
||||
Is your vault stored in iCloud Drive? (yes/no)
|
||||
|
||||
User: yes
|
||||
|
||||
Please enter the full path to your vault:
|
||||
(Example: ~/Library/Mobile Documents/iCloud~md~obsidian/Documents/YourVault)
|
||||
|
||||
User: ~/Library/Mobile Documents/iCloud~md~obsidian/Documents/MyVault
|
||||
|
||||
[Validates path and shows vault stats]
|
||||
|
||||
Found vault at: ~/Library/Mobile Documents/iCloud~md~obsidian/Documents/MyVault
|
||||
📊 Vault stats: 1,248 markdown files, 523MB total size
|
||||
|
||||
Would you like to import this vault? (yes/skip)
|
||||
|
||||
📦 **Analyzing your vault structure...** [Running tree to see folder hierarchy]
|
||||
[Sampling notes to understand content] [Detecting naming patterns from recent
|
||||
files]
|
||||
|
||||
@@ -0,0 +1,131 @@
|
||||
---
|
||||
allowed-tools: [Read, Write, Bash]
|
||||
description: Install claudesidian shell command to launch Claude Code from anywhere
|
||||
argument-hint: (optional shell: bash/zsh/fish)
|
||||
---
|
||||
|
||||
# Install Claudesidian Command
|
||||
|
||||
Creates a shell alias/function that allows you to run `claudesidian` from anywhere
|
||||
to open your vault in Claude Code.
|
||||
|
||||
## Task
|
||||
|
||||
Install a shell command that:
|
||||
1. Changes to your claudesidian vault directory
|
||||
2. Launches Claude Code
|
||||
3. Works from any directory in your terminal
|
||||
|
||||
Similar to having a quick launcher for your vault.
|
||||
|
||||
## Process
|
||||
|
||||
### 1. **Detect Current Setup**
|
||||
|
||||
- Check which shell the user is using (bash/zsh/fish)
|
||||
- Find the current working directory (vault path)
|
||||
- Determine the appropriate config file
|
||||
|
||||
### 2. **Create the Command**
|
||||
|
||||
The command will be an alias that:
|
||||
- Changes to the vault directory: `cd /path/to/your/vault`
|
||||
- Tries to resume existing session: `claude --resume 2>/dev/null`
|
||||
- Falls back to new session if no existing one: `|| claude`
|
||||
- All in one command: `(cd /path/to/vault && (claude --resume 2>/dev/null || claude))`
|
||||
|
||||
This automatically enters resume mode if there's an existing session, or starts a new one if not.
|
||||
|
||||
### 3. **Install to Shell Config**
|
||||
|
||||
Add the alias to the appropriate config file:
|
||||
- **Bash**: `~/.bashrc` or `~/.bash_profile`
|
||||
- **Zsh**: `~/.zshrc`
|
||||
- **Fish**: `~/.config/fish/config.fish`
|
||||
|
||||
### 4. **Verify Installation**
|
||||
|
||||
- Show the added line
|
||||
- Remind user to reload their shell or source the config
|
||||
- Provide test command
|
||||
|
||||
## Shell Detection
|
||||
|
||||
```bash
|
||||
# Detect current shell
|
||||
if [ -n "$ZSH_VERSION" ]; then
|
||||
SHELL_TYPE="zsh"
|
||||
CONFIG_FILE="$HOME/.zshrc"
|
||||
elif [ -n "$BASH_VERSION" ]; then
|
||||
SHELL_TYPE="bash"
|
||||
# Prefer .bashrc on Linux, .bash_profile on macOS
|
||||
if [ -f "$HOME/.bashrc" ]; then
|
||||
CONFIG_FILE="$HOME/.bashrc"
|
||||
else
|
||||
CONFIG_FILE="$HOME/.bash_profile"
|
||||
fi
|
||||
elif [ -n "$FISH_VERSION" ]; then
|
||||
SHELL_TYPE="fish"
|
||||
CONFIG_FILE="$HOME/.config/fish/config.fish"
|
||||
fi
|
||||
```
|
||||
|
||||
## Installation Steps
|
||||
|
||||
1. **Get vault path**: Use `pwd` to get current directory
|
||||
2. **Check if already installed**: Search config file for existing `claudesidian` alias
|
||||
3. **Add alias**: Append to config file if not present
|
||||
4. **Show success message**: With instructions to reload shell
|
||||
|
||||
## Example Output
|
||||
|
||||
```
|
||||
🔧 Installing claudesidian command...
|
||||
|
||||
📁 Vault path: /home/user/my-vault
|
||||
🐚 Shell detected: zsh
|
||||
📝 Config file: /home/user/.zshrc
|
||||
|
||||
✅ Installed! Added to /home/user/.zshrc:
|
||||
alias claudesidian='(cd /home/user/my-vault && (claude --resume 2>/dev/null || claude))'
|
||||
|
||||
🔄 To activate, run:
|
||||
source ~/.zshrc
|
||||
|
||||
Or start a new terminal session.
|
||||
|
||||
✨ Test it: Type 'claudesidian' from any directory!
|
||||
```
|
||||
|
||||
## Important Notes
|
||||
|
||||
- The command uses a subshell `()` so it returns to your original directory after
|
||||
- Automatically tries to resume existing sessions, falls back to new session
|
||||
- If alias already exists, ask user if they want to replace it
|
||||
- Always show what will be added before modifying config files
|
||||
- Create backup of config file before modifying
|
||||
|
||||
## Usage Examples
|
||||
|
||||
Install for current shell:
|
||||
```
|
||||
/install-claudesidian-command
|
||||
```
|
||||
|
||||
Install for specific shell:
|
||||
```
|
||||
/install-claudesidian-command zsh
|
||||
/install-claudesidian-command bash
|
||||
```
|
||||
|
||||
## How It Works
|
||||
|
||||
The alias uses a clever pattern:
|
||||
```bash
|
||||
alias claudesidian='(cd /path/to/vault && (claude --resume 2>/dev/null || claude))'
|
||||
```
|
||||
|
||||
1. `(cd /path/to/vault && ...)` - Subshell that changes directory temporarily
|
||||
2. `claude --resume 2>/dev/null` - Tries to resume existing session, suppresses error
|
||||
3. `|| claude` - If resume fails (no session), starts new session
|
||||
4. After Claude exits, returns to original directory automatically
|
||||
@@ -152,6 +152,7 @@ Pre-configured AI assistants ready to use:
|
||||
- `de-ai-ify` - Remove AI writing patterns from text
|
||||
- `upgrade` - Update to the latest claudesidian version
|
||||
- `init-bootstrap` - Re-run the setup wizard
|
||||
- `install-claudesidian-command` - Install shell command to launch vault from anywhere
|
||||
|
||||
Run with: `/[command-name]` in Claude Code
|
||||
|
||||
@@ -263,6 +264,31 @@ Run these with `pnpm`:
|
||||
|
||||
## Advanced Setup
|
||||
|
||||
### Quick Launch from Anywhere
|
||||
|
||||
Install a shell command to launch your vault from any directory:
|
||||
|
||||
```bash
|
||||
# In Claude Code, run:
|
||||
/install-claudesidian-command
|
||||
```
|
||||
|
||||
This creates a `claudesidian` alias that:
|
||||
- Changes to your vault directory automatically
|
||||
- Tries to resume your existing session (if one exists)
|
||||
- Falls back to starting a new session
|
||||
- Returns to your original directory when done
|
||||
|
||||
**Usage:**
|
||||
```bash
|
||||
# From anywhere in your terminal:
|
||||
claudesidian
|
||||
|
||||
# It will automatically resume your last session or start a new one
|
||||
```
|
||||
|
||||
The command is added to your shell config (~/.zshrc, ~/.bashrc, etc.) so it persists across terminal sessions.
|
||||
|
||||
### Git Integration
|
||||
|
||||
Initialize Git for version control:
|
||||
|
||||
Reference in New Issue
Block a user