Skip to main content
ClaudeWave
Skill2.5k repo starsupdated 2mo ago

install-claudesidian-command

This Claude Code skill installs a shell command that enables launching claudesidian from any terminal directory. Use it when a user wants to set up a convenient launcher alias that automatically navigates to their vault and opens Claude Code, either resuming an existing session or starting a new one.

Install in Claude Code
Copy
git clone --depth 1 https://github.com/heyitsnoah/claudesidian /tmp/install-claudesidian-command && cp -r /tmp/install-claudesidian-command/.agents/skills/install-claudesidian-command ~/.claude/skills/install-claudesidian-command
Then start a new Claude Code session; the skill loads automatically.

SKILL.md

# 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 with properly escaped path:
  `(cd "/path/to/vault" && (claude --resume 2>/dev/null || claude))`

**Important:** The path must be properly escaped to handle spaces and special
characters.

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

Detects the user's default shell, with support for command-line override:

```bash
# Check if shell specified as argument (/install-claudesidian-command zsh)
if [ -n "$1" ]; then
  # User provided shell type as argument
  SHELL_TYPE="$1"
else
  # Auto-detect from $SHELL (user's default shell, not current shell)
  SHELL_TYPE=$(basename "$SHELL")
fi

# Validate shell type and set appropriate config file
case "$SHELL_TYPE" in
  zsh)
    CONFIG_FILE="$HOME/.zshrc"
    ;;
  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
    ;;
  fish)
    CONFIG_FILE="$HOME/.config/fish/config.fish"
    ;;
  *)
    echo "❌ Unsupported shell: $SHELL_TYPE"
    echo "   Supported shells: bash, zsh, fish"
    echo "   Usage: /install-claudesidian-command [bash|zsh|fish]"
    exit 1
    ;;
esac

echo "🐚 Installing for: $SHELL_TYPE"
echo "📝 Config file: $CONFIG_FILE"
```

**Key improvements:**

- Uses `$SHELL` to detect default shell (not `$ZSH_VERSION`/`$BASH_VERSION`
  which detect current session)
- Supports command-line argument to override auto-detection
- Shows detected shell and config file for transparency
- Validates shell type and provides clear error message for unsupported shells

## Installation Steps

1. **Detect shell**: Use argument if provided, otherwise auto-detect from
   `$SHELL`
2. **Get vault path**: Use `pwd` to get current directory
3. **Escape the path**: Properly escape quotes and special characters for shell
   safety
   ```bash
   # Escape backslashes FIRST (so we don't double-escape ones we add later)
   ESCAPED_PATH="${VAULT_PATH//\\/\\\\}"
   # Then escape double quotes
   ESCAPED_PATH="${ESCAPED_PATH//\"/\\\"}"
   ```
4. **Check if already installed**: Search config file for existing
   `claudesidian` alias/function
   ```bash
   # Check for existing alias/function
   if grep -q "alias claudesidian\|function claudesidian" "$CONFIG_FILE"; then
     echo "⚠️  Found existing claudesidian command:"
     grep -A 3 "claudesidian" "$CONFIG_FILE"
     echo ""
     read -p "Replace it? (yes/no): " replace_answer
     if [[ ! "$replace_answer" =~ ^[Yy] ]]; then
       echo "Installation cancelled. Existing command preserved."
       exit 0
     fi
     # Mark for replacement (will remove before adding new one)
     REPLACING=true
   fi
   ```
5. **Get user confirmation**: Show what will be added and get final confirmation
6. **Create backup**: Only if proceeding with modification
   ```bash
   # Create backup with timestamp
   BACKUP_FILE="$CONFIG_FILE.backup-$(date +%Y%m%d-%H%M%S)"
   cp "$CONFIG_FILE" "$BACKUP_FILE"
   echo "💾 Backup created: $BACKUP_FILE"
   ```
7. **Build the safe alias/function command**: Use the escaped path from step 3
   ```bash
   # CRITICAL: Use $ESCAPED_PATH in the command (not raw $VAULT_PATH)
   if [ "$SHELL_TYPE" = "fish" ]; then
     # Fish uses function syntax, not alias
     COMMAND_TEXT="function claudesidian
    cd \"$ESCAPED_PATH\" && (claude --resume 2>/dev/null; or claude)
    cd -
   end"
   else
     # Bash/Zsh use alias syntax
     # IMPORTANT: Use double quotes around $ESCAPED_PATH to preserve escaping
     COMMAND_TEXT="alias claudesidian='(cd \"$ESCAPED_PATH\" && (claude --resume 2>/dev/null || claude))'"
   fi
   ```
8. **Remove old command if replacing**:
   ```bash
   if [ "$REPLACING" = true ]; then
     # Bash/Zsh: alias is a single line — delete just that line
     sed -i.tmp '/^alias claudesidian/d' "$CONFIG_FILE"
     # Fish: function spans multiple lines — delete from `function claudesidian`
     # to the matching `end`
     sed -i.tmp '/^function claudesidian/,/^end$/d' "$CONFIG_FILE"
     rm -f "$CONFIG_FILE.tmp"
   fi
   ```

   **Why two separate sed calls:** A combined range like
   `/alias claudesidian\|function claudesidian/,/^end$/d` would, for the alias
   case, keep eating lines until it found the next `^end$` somewhere else in
   the file (or EOF). That could nuke unrelated config below. Single-line
   delete for the alias, range delete for the function — never combine them.
9. **Add command to config file**: Append using the escaped command text
   ```bash
   echo "$COMMAND_TEXT" >> "$CONFIG_FILE"
   ```
10. **Show success message**: With instructions to reload shell

## Example Output

**Bash/Zsh Example (with spaces in path to demonstrate escaping):**

```
🔧 Installing claudesidian command...

📁 Vault path: /home/user/My Obsidian Vault
🐚 Shell detected:
add-frontmatterSkill

Add or update YAML frontmatter properties to enhance Obsidian note organization. Use when the user asks to add, fix, normalize, or improve frontmatter, properties, metadata, tags, or YAML on a note or folder of notes.

daily-reviewSkill

Conduct an end-of-day review to capture progress and set up tomorrow. Use when the user asks for a daily review, end of day wrap-up, EOD note, what they did today, or wants to reflect on the day and plan tomorrow.

de-ai-ifySkill

Remove AI-generated jargon and restore human voice to text. Use when the user asks to de-AI-ify, humanize, remove AI tone, or make text sound less machine-generated.

download-attachmentSkill

Download files from URLs to the Obsidian attachments folder and organize them with descriptive names. Use when the user provides URLs to download, asks to save files from the web, or wants to add web content as attachments.

git-worktreesSkill

Work with git worktrees for isolated parallel development. Use when starting feature work in isolation, when need separate workspace without branch switching, or when cleaning up worktrees after PR merge.

inbox-processorSkill

Help organize and process items in the 00_Inbox folder according to the PARA method. Use when the user asks to process, clear, sort, triage, or organize their inbox.

init-bootstrapSkill

Interactive setup wizard that helps new users create a personalized CLAUDE.md file based on their Obsidian workflow preferences. Use when the user wants to set up claudesidian, onboard a new vault, or run the bootstrap/init/setup wizard.

json-canvasSkill

Create and edit JSON Canvas files (.canvas) with nodes, edges, groups, and connections. Use when working with .canvas files, creating visual canvases, mind maps, flowcharts, or when the user mentions Canvas files in Obsidian.