Skip to content

Commit

Permalink
Merge pull request #10 from AndersSteenNilsen/zplug
Browse files Browse the repository at this point in the history
Make installable with zplug
  • Loading branch information
AndersSteenNilsen authored Jul 25, 2023
2 parents 1318fac + 920e193 commit 5c72e24
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 4 deletions.
41 changes: 37 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,17 +37,38 @@ If asked a question that will not resolve in a command, GPT is instructed to use
```

## Prerequisite
### Must have
* Python >= 3.7
* ZSH + Oh-my-zsh
* Valid Openai API-key
* make sure to save under `OPENAI_API_KEY` env.
* `export OPENAI_API_KEY='sk-...'`
* **`export OPENAI_API_KEY='sk-...'`**

### Nice to have
* pipx
* Oh-my-zsh
* zplug

## Installation
⚠️All installations needs to have OPEN_API_KEY set⚠️.

With zshgpt alone, you can ask questions with `zshgpt # Show me all my drives` and it will return an answer from GPT. But the true performance boost comes when you also add the zsh plugin.
```bash
pip install zshgpt # Or preferably install with pipx
`~/.zshrc`
```
export OPEN_API_KEY="sk-..."
```

### Standalone python package
With zshgpt alone `pipx install zshgpt` , you can ask questions with `zshgpt # Show me all my drives` and it will return an answer from GPT. But the true ✨magic✨ comes when you also add the zsh plugin.

### Manually with zsh
```zsh
curl https://raw.githubusercontent.com/AndersSteenNilsen/zshgpt/main/zshgpt.plugin.zsh -o ~ # Copy plugin
echo "source ~/zshgpt.plugin.zsh" >> ~/.zshrc # Add to zshrc
exec zsh # Reload zsh
```

### Manually with oh-my-zsh
```zsh
mkdir $ZSH_CUSTOM/plugins/zshgpt
curl https://raw.githubusercontent.com/AndersSteenNilsen/zshgpt/main/zsh_plugin/zsh_plugin.zsh -o $ZSH_CUSTOM/plugins/zshgpt/zshgpt.plugin.zsh
```
Expand All @@ -61,6 +82,18 @@ plugins(
)
```

```zsh
omz reload
```

### With zplug
`~/.zshrc`
```
...
zplug "AndersSteenNilsen/zshgpt"
zplug load
```

## Future plans

### Functionaliy
Expand Down
11 changes: 11 additions & 0 deletions zsh_plugin/zsh_plugin.zsh → zshgpt.plugin.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,17 @@
# This ZSH plugin reads the text from the current buffer
# and uses a Python script to complete the text.

# If zshgpt is not installed...
if (( $+commands[zshgpt] )) then
echo "zshgpt already installed"
# ...try to install with pipx...
elif (( $+commands[pipx] )) then
pipx install zshgpt
else
# ... or normal pip.
python -m pip install zshgpt
fi

create_completion() {
# Get the text typed until now.
text=${BUFFER}
Expand Down

0 comments on commit 5c72e24

Please sign in to comment.