Add shell integration files
Some checks failed
CI / test (push) Failing after 4s

This commit is contained in:
2026-01-31 08:30:22 +00:00
parent 222dcb72bd
commit 7dd2b998e7

53
.shell/setup.sh Normal file
View File

@@ -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"