Crazy! Added support for ALT+\
This commit is contained in:
135
README.md
135
README.md
@@ -1,7 +1,7 @@
|
||||
```markdown
|
||||
# finish.sh
|
||||
# finish
|
||||
|
||||
AI-powered shell completion that runs 100 % on your machine.
|
||||
AI-powered shell completion that runs 100% on your machine.
|
||||
|
||||
One command and your terminal learns what you type next.
|
||||
|
||||
@@ -12,65 +12,56 @@ curl -sSL https://git.appmodel.nl/tour/finish/raw/branch/main/docs/install.sh |
|
||||
source ~/.bashrc # or ~/.zshrc
|
||||
```
|
||||
|
||||
Press `Tab` twice on any partial command and finish.sh suggests the rest—no cloud, no data leak, no latency.
|
||||
Press **Alt+\\** after typing any command to get intelligent completions—no cloud, no data leak, instant results.
|
||||
|
||||
## How it works
|
||||
|
||||
1. Captures your current directory, recent history, env vars.
|
||||
2. Builds a concise prompt for a local LLM (LM-Studio, Ollama, or any OpenAI-compatible endpoint).
|
||||
3. Returns ranked completions in <200 ms, cached for instant replay.
|
||||
1. Captures your current directory, recent history, env vars, and available tools
|
||||
2. Analyzes your intent and builds a context-aware prompt
|
||||
3. Queries your local LLM (LM Studio, Ollama, or any OpenAI-compatible endpoint)
|
||||
4. Returns 2-5 ranked completions with an interactive picker
|
||||
5. Results are cached for instant replay
|
||||
|
||||
## Use
|
||||
## Usage
|
||||
|
||||
Type a command, then press **Alt+\\**:
|
||||
|
||||
```bash
|
||||
docker <Tab><Tab> # → docker run -it --rm ubuntu bash
|
||||
git commit <Tab><Tab> # → git commit -m "feat: add finish.sh"
|
||||
# large files <Tab><Tab> # → find . -type f -size +100M
|
||||
# Natural language commands
|
||||
show gpu status # → nvidia-smi
|
||||
resolve title of website google.com # → curl -s https://google.com | grep -oP '<title>\K[^<]+'
|
||||
make file about dogs # → echo "About Dogs" > dogs.md
|
||||
|
||||
# Partial commands
|
||||
git commit # → git commit -m "..."
|
||||
docker run # → docker run -it --rm ubuntu bash
|
||||
find large files # → find . -type f -size +100M
|
||||
```
|
||||
|
||||
Dry-run mode:
|
||||
|
||||
```bash
|
||||
finish --dry-run "tar czf backup.tar.gz"
|
||||
```
|
||||
Navigate with ↑↓, press Enter to accept, Esc to cancel.
|
||||
|
||||
## Configure
|
||||
|
||||
```bash
|
||||
finish config set endpoint http://plato.lan:11434/v1/chat/completions
|
||||
finish config set model codellama:13b
|
||||
finish model # interactive picker
|
||||
```
|
||||
|
||||
## Providers
|
||||
|
||||
| Provider | Auth | URL | Notes |
|
||||
|-----------|------|-----------------------------|---------|
|
||||
| LM-Studio | none | `http://localhost:1234/v1` | default |
|
||||
| Ollama | none | `http://localhost:11434` | |
|
||||
| OpenAI | key | `https://api.openai.com/v1` | |
|
||||
|
||||
Add others by editing `~/.finish/config`.
|
||||
|
||||
## Commands
|
||||
View current configuration:
|
||||
|
||||
```bash
|
||||
finish install # hook into shell
|
||||
finish remove # uninstall
|
||||
finish clear # wipe cache & logs
|
||||
finish usage # tokens & cost
|
||||
finish config
|
||||
```
|
||||
|
||||
## Requirements
|
||||
Edit configuration file:
|
||||
|
||||
Bash ≥4 or Zsh ≥5, curl, jq, bc.
|
||||
Optional: bash-completion.
|
||||
```bash
|
||||
nano ~/.finish/finish.json
|
||||
```
|
||||
|
||||
## Configuration Examples
|
||||
|
||||
### Local Ollama
|
||||
```json
|
||||
{
|
||||
"provider": "lmstudio",
|
||||
"model": "darkidol-llama-3.1-8b-instruct-1.3-uncensored_gguf:2",
|
||||
"endpoint": "http://plato.lan:1234/v1/chat/completions",
|
||||
"provider": "ollama",
|
||||
"model": "llama3:latest",
|
||||
"endpoint": "http://localhost:11434/api/chat",
|
||||
"temperature": 0.0,
|
||||
"api_prompt_cost": 0.0,
|
||||
"api_completion_cost": 0.0,
|
||||
@@ -79,12 +70,14 @@ Optional: bash-completion.
|
||||
"cache_size": 100
|
||||
}
|
||||
```
|
||||
|
||||
### LM Studio
|
||||
```json
|
||||
{
|
||||
"provider": "ollama",
|
||||
"model": "llama3:latest",
|
||||
"endpoint": "http://localhost:11434/api/chat",
|
||||
"temperature": 0.2,
|
||||
"provider": "lmstudio",
|
||||
"model": "dolphin3.0-llama3.1-8b@q4_k_m",
|
||||
"endpoint": "http://localhost:1234/v1/chat/completions",
|
||||
"temperature": 0.0,
|
||||
"api_prompt_cost": 0.0,
|
||||
"api_completion_cost": 0.0,
|
||||
"max_history_commands": 20,
|
||||
@@ -92,6 +85,56 @@ Optional: bash-completion.
|
||||
"cache_size": 100
|
||||
}
|
||||
```
|
||||
|
||||
### OpenAI (or compatible API)
|
||||
```json
|
||||
{
|
||||
"provider": "lmstudio",
|
||||
"model": "gpt-4",
|
||||
"endpoint": "https://api.openai.com/v1/chat/completions",
|
||||
"api_key": "sk-...",
|
||||
"temperature": 0.0,
|
||||
"api_prompt_cost": 0.03,
|
||||
"api_completion_cost": 0.06,
|
||||
"max_history_commands": 20,
|
||||
"max_recent_files": 20,
|
||||
"cache_size": 100
|
||||
}
|
||||
```
|
||||
|
||||
## Requirements
|
||||
|
||||
- Python 3.7+
|
||||
- Bash ≥4 or Zsh ≥5
|
||||
- A local LLM running (Ollama, LM Studio, etc.) or API access
|
||||
|
||||
Python dependencies (installed automatically):
|
||||
- httpx
|
||||
- prompt_toolkit
|
||||
- rich
|
||||
|
||||
## Commands
|
||||
|
||||
```bash
|
||||
finish install # Set up Alt+\ keybinding
|
||||
finish config # Show current configuration
|
||||
finish command "text" # Test completions manually
|
||||
```
|
||||
|
||||
## Advanced
|
||||
|
||||
### Debug mode
|
||||
```bash
|
||||
export FINISH_DEBUG=1
|
||||
finish command "your command here"
|
||||
cat ~/.finish/finish.log
|
||||
```
|
||||
|
||||
### Clear cache
|
||||
```bash
|
||||
rm -rf ~/.finish/cache/*.json
|
||||
```
|
||||
|
||||
## License
|
||||
|
||||
BSD 2-Clause.
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user