From 7dd2b998e7e1b4c1a3e472a1e42a335767114d89 Mon Sep 17 00:00:00 2001 From: 7000pctAUTO Date: Sat, 31 Jan 2026 08:30:22 +0000 Subject: [PATCH] Add shell integration files --- .shell/setup.sh | 53 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 .shell/setup.sh diff --git a/.shell/setup.sh b/.shell/setup.sh new file mode 100644 index 0000000..e211bc1 --- /dev/null +++ b/.shell/setup.sh @@ -0,0 +1,53 @@ +#!/bin/bash +# CLI Command Memory - Shell Integration Setup +# Run this script to set up shell integration for auto-recording + +set -e + +SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" +CLI_MEMORY_HOME="${CLI_MEMORY_HOME:-$HOME/.cli_memory}" +SHELL_DIR="$CLI_MEMORY_HOME/shell" + +echo "Setting up CLI Command Memory shell integration..." +echo "=================================================" + +mkdir -p "$SHELL_DIR" + +cp "$SCRIPT_DIR/bash_completion.sh" "$SHELL_DIR/" + +PROFILE_FILE="" +if [[ -f "$HOME/.bashrc" ]]; then + PROFILE_FILE="$HOME/.bashrc" +elif [[ -f "$HOME/.bash_profile" ]]; then + PROFILE_FILE="$HOME/.bash_profile" +elif [[ -f "$HOME/.profile" ]]; then + PROFILE_FILE="$HOME/.profile" +fi + +COMPLETION_LINE="source $SHELL_DIR/bash_completion.sh" +PROMPT_COMMAND_LINE='export PROMPT_COMMAND="${PROMPT_COMMAND}:$(cm-prompt)"' + +if [[ -n "$PROFILE_FILE" ]]; then + if ! grep -q "cli-memory" "$PROFILE_FILE" 2>/dev/null; then + echo "" >> "$PROFILE_FILE" + echo "# CLI Command Memory" >> "$PROFILE_FILE" + echo "$COMPLETION_LINE" >> "$PROFILE_FILE" + echo "$PROMPT_COMMAND_LINE" >> "$PROFILE_FILE" + echo "Added shell integration to $PROFILE_FILE" + else + echo "Shell integration already configured in $PROFILE_FILE" + fi +else + echo "Could not find shell profile file. Please add the following to your shell profile:" + echo "" + echo "$COMPLETION_LINE" + echo "$PROMPT_COMMAND_LINE" +fi + +echo "" +echo "Setup complete!" +echo "" +echo "To use the shell integration:" +echo " 1. Restart your shell: source ~/.bashrc" +echo " 2. Start recording: cli-memory record start" +echo " 3. Commands will be automatically captured"