Skip to content

Instantly share code, notes, and snippets.

@mate-h
Last active April 1, 2023 02:52
Show Gist options
  • Save mate-h/26b49ec65897db1796bf2070930907fd to your computer and use it in GitHub Desktop.
Save mate-h/26b49ec65897db1796bf2070930907fd to your computer and use it in GitHub Desktop.
Fish completions for gpt-cli: https://github.com/kharvd/gpt-cli
# gpt.fish - Fish shell completions for gpt.py
set -Ux OPENAI_API_KEY <API KEY>
fish_add_path ~/github/gpt-cli
alias gpt="gpt.py"
function __fish_gpt_no_subcommand -d "Test if gpt has been given no subcommand"
not set -q argv[1]
or string match -qr -- '^-' $argv[1]
end
complete -c gpt -f -n "__fish_gpt_no_subcommand" -a "dev" -d "Software development assistant with shorter responses"
complete -c gpt -f -n "__fish_gpt_no_subcommand" -a "general" -d "Generally helpful assistant (default)"
complete -c gpt -f -n "__fish_gpt_no_subcommand" -a "bash" -d "Bash scripting assistant"
complete -c gpt -s h -l help -d "Show this help message and exit"
complete -c gpt -l no_markdown -d "Disable markdown formatting in the chat session"
complete -c gpt -l model -d "The model to use for the chat session" -r
complete -c gpt -l temperature -d "The temperature to use for the chat session" -r
complete -c gpt -l top_p -d "The top_p to use for the chat session" -r
complete -c gpt -s p -l prompt -d "Print the response to standard output and exit" -r
complete -c gpt -s e -l execute -d "Edit and execute the produced shell command" -r
complete -c gpt -l no_stream -d "Do not stream the response to standard output"
@mate-h
Copy link
Author

mate-h commented Apr 1, 2023

Install with:

wget https://gist.githubusercontent.com/mate-h/26b49ec65897db1796bf2070930907fd/raw/46eb2644a8a91550649f74ff82aa7a04ca59e688/gpt.fish && mv gpt.fish ~/.config/fish/completions/gpt.fish

Edit the file with vim and paste the API Key from https://platform.openai.com/account/api-keys.

vim ~/.config/fish/completions/gpt.fish

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment