Crazy! Added support for ALT+\
Some checks failed
Docker Build and Push / build-and-push (push) Failing after 10s
Tests / test (bash) (push) Failing after 8s
Tests / test (zsh) (push) Failing after 8s
Tests / lint (push) Successful in 7s
Tests / docker (push) Successful in 6s

This commit is contained in:
mike
2025-12-11 16:23:40 +01:00
parent 54d265067e
commit 66034eda34
2 changed files with 150 additions and 57 deletions

View File

@@ -97,11 +97,9 @@ main() {
SHELL_TYPE=$(detect_shell)
case "$SHELL_TYPE" in
zsh)
SCRIPT_NAME="finish.zsh"
RC_FILE="$HOME/.zshrc"
;;
bash)
SCRIPT_NAME="finish.sh"
RC_FILE="$HOME/.bashrc"
;;
*)
@@ -112,6 +110,18 @@ main() {
echo "Detected shell: $SHELL_TYPE"
# Check Python
echo "Checking Python installation..."
if ! command -v python3 > /dev/null 2>&1; then
echo_error "Python 3 is required but not found"
echo "Install it with:"
echo " Ubuntu/Debian: sudo apt-get install python3 python3-pip python3-venv"
echo " macOS: brew install python3"
exit 1
fi
echo_green "✓ Python 3 found: $(python3 --version)"
echo ""
# Check dependencies
echo "Checking dependencies..."
if ! check_dependencies; then
@@ -144,17 +154,49 @@ main() {
exit 1
fi
# Create directory if needed
# Create directories if needed
mkdir -p "$(dirname "$INSTALL_LOCATION")"
mkdir -p "$HOME/.venvs"
# Download script
echo "Downloading finish.sh..."
URL="$REPO_URL/$BRANCH_OR_VERSION/src/$SCRIPT_NAME"
# Download Python script
echo "Downloading finish.py..."
URL="$REPO_URL/$BRANCH_OR_VERSION/src/finish.py"
if ! download_file "$URL" "$INSTALL_LOCATION"; then
echo_error "Failed to download from $URL"
exit 1
fi
# Download requirements.txt
echo "Downloading requirements.txt..."
TEMP_REQ="/tmp/finish_requirements.txt"
REQ_URL="$REPO_URL/$BRANCH_OR_VERSION/requirements.txt"
if ! download_file "$REQ_URL" "$TEMP_REQ"; then
echo_error "Failed to download requirements.txt from $REQ_URL"
exit 1
fi
# Create virtualenv and install dependencies
echo "Creating virtual environment..."
VENV_PATH="$HOME/.venvs/finish"
if [ ! -d "$VENV_PATH" ]; then
python3 -m venv "$VENV_PATH"
fi
echo_green "✓ Virtual environment created at $VENV_PATH"
echo "Installing Python dependencies..."
"$VENV_PATH/bin/pip" install --quiet --upgrade pip
"$VENV_PATH/bin/pip" install --quiet -r "$TEMP_REQ"
echo_green "✓ Dependencies installed"
rm -f "$TEMP_REQ"
# Update shebang to use venv python (compatible with macOS and Linux)
if sed --version >/dev/null 2>&1; then
# GNU sed (Linux)
sed -i "1s|.*|#!$VENV_PATH/bin/python3|" "$INSTALL_LOCATION"
else
# BSD sed (macOS)
sed -i '' "1s|.*|#!$VENV_PATH/bin/python3|" "$INSTALL_LOCATION"
fi
chmod +x "$INSTALL_LOCATION"
echo_green "✓ Installed to $INSTALL_LOCATION"
echo ""
@@ -183,8 +225,8 @@ main() {
fi
fi
# Run finish install
echo "Running finish installation..."
# Run finish install to set up keybinding
echo "Setting up shell keybinding..."
if "$INSTALL_LOCATION" install; then
echo ""
echo_green "=========================================="
@@ -195,10 +237,18 @@ main() {
echo " 1. Reload your shell configuration:"
echo " source $RC_FILE"
echo ""
echo " 2. Select a language model:"
echo " finish model"
echo " 2. Configure your LLM endpoint:"
echo " finish config"
echo ""
echo " 3. Start using by pressing Tab twice after any command"
echo " 3. Edit config if needed:"
echo " nano ~/.finish/finish.json"
echo ""
echo " 4. Start using by pressing Alt+\\ after typing a command"
echo ""
echo "Example:"
echo " Type: show gpu status"
echo " Press: Alt+\\"
echo " Select completion with ↑↓ arrows, Enter to accept"
echo ""
echo "Documentation: https://git.appmodel.nl/tour/finish"
else