Skip to content

Commit 0527e9e

Browse files
committed
fix(claude-code): guard fish function overwrite and narrow chown scope
Skip writing yolo.fish if it already exists to match bash/zsh behavior. Chown only the specific file instead of the entire functions directory. Update docs to reflect the skip-if-exists behavior.
1 parent f7f18e5 commit 0527e9e

2 files changed

Lines changed: 9 additions & 4 deletions

File tree

src/claude-code/NOTES.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ When `yoloAlias` is set to `true`, a `yolo` shell alias is created that expands
1919

2020
> **Warning:** `--allow-dangerously-skip-permissions` disables Claude Code's normal permission checks and confirmation prompts for potentially sensitive actions. This meaningfully reduces safety and may allow unintended or unsafe changes, so only enable `yoloAlias` if you understand and accept the security implications.
2121
>
22-
> Creating this alias may also override an existing `yolo` alias in your shell configuration.
22+
> If a `yolo` alias or function already exists in your shell configuration, the installer will skip adding it to avoid overwriting your setup.
2323
2424
## Auto-Updates
2525

src/claude-code/install.sh

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,17 +81,22 @@ if [ "${YOLOALIAS:-false}" = "true" ]; then
8181

8282
# fish — create a function file (idiomatic for fish)
8383
FISH_FUNC_DIR="$TARGET_HOME/.config/fish/functions"
84-
mkdir -p "$FISH_FUNC_DIR"
85-
cat > "$FISH_FUNC_DIR/yolo.fish" << 'FISHEOF'
84+
FISH_FUNC_FILE="$FISH_FUNC_DIR/yolo.fish"
85+
if [ -f "$FISH_FUNC_FILE" ]; then
86+
echo "Skipping $FISH_FUNC_FILE: function already exists."
87+
else
88+
mkdir -p "$FISH_FUNC_DIR"
89+
cat > "$FISH_FUNC_FILE" << 'FISHEOF'
8690
function yolo --description "claude --allow-dangerously-skip-permissions"
8791
claude --allow-dangerously-skip-permissions $argv
8892
end
8993
FISHEOF
94+
fi
9095

9196
# Fix ownership if installing for non-root user
9297
if [ -n "$_REMOTE_USER" ] && [ "$_REMOTE_USER" != "root" ]; then
9398
chown "$_REMOTE_USER" "$TARGET_HOME/.bashrc" "$TARGET_HOME/.zshrc"
94-
chown -R "$_REMOTE_USER" "$FISH_FUNC_DIR"
99+
chown "$_REMOTE_USER" "$FISH_FUNC_FILE"
95100
fi
96101

97102
echo "yolo alias configured for bash, zsh, and fish."

0 commit comments

Comments
 (0)