Here are Zsh Completions for shell_gpt #468
eiger8
started this conversation in
Show and tell
Replies: 3 comments 10 replies
-
I've uploaded archive with fix for the '_sgpt' completion script that should fix typo in for get-role list function. |
Beta Was this translation helpful? Give feedback.
0 replies
-
Thanks @eiger8! This inspired me to roll the dice to fix this nagging missing feature for me as well. $ sgpt --code "Convert this zsh completion file to bash completion" < _sgpt | tee sgpt.bash
_sgpt()
{
local cur prev opts
COMPREPLY=()
cur="${COMP_WORDS[COMP_CWORD]}"
prev="${COMP_WORDS[COMP_CWORD-1]}"
opts="--model --temperature --top-p --editor --no-editor --cache --no-cache --version --help --shell --interaction --no-interaction --describe-shell --code --functions --no-functions --chat --repl --show-chat --list-chats --role --create-role --show-role --list-roles --install-integration"
case "${prev}" in
--model)
COMPREPLY=( $(compgen -W "$(curl -s https://api.openai.com/v1/models -H "Content-Type: application/json" -H "Authorization: Bearer $(grep '^OPENAI_API_KEY=' ~/.config/shell_gpt/.sgptrc | cut -d '=' -f2)" | jq -r '.data[].id')" -- "${cur}") )
return 0
;;
--chat|--show-chat)
COMPREPLY=( $(compgen -W "$(sgpt --list-chats | sed -E 's|.*/chat_cache/(.*)|\1|')" -- "${cur}") )
return 0
;;
--role|--show-role)
COMPREPLY=( $(compgen -W "$(sgpt --list-roles | sed -E 's|.*/roles/(.*)\.json|\1|')" -- "${cur}") )
return 0
;;
*)
;;
esac
if [[ ${cur} == -* ]] ; then
COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
return 0
fi
}
complete -F _sgpt sgpt $ cp sgpt.bash ~/.local/share/bash-completion/completions/ Result There's some things broken but this already saves a lot of typing! recording-2024-02-22_23.37.49.mp4 |
Beta Was this translation helpful? Give feedback.
5 replies
-
Here is an updated reflecting changes in shell_gpt v1.4 (added --md, --no-md option) |
Beta Was this translation helpful? Give feedback.
5 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hello, sgpt community!
I'm excited to share developed Zsh completions for the sgpt, aiming to enhance our command-line experience. You can find mentioned modules in attached files.
Key Features
TAB
suggestion--model, --chat, --show-chat, --role, -- show-role
have interactive arguments suggestion (press TAB after option)Installation
Copy the
_sgpt
into the default zsh or zsh's framework completion folders:- default one is
~/.zsh/completion
- Oh-My-Zsh framework's one
~/.oh-my-zsh/cache/completions
Copy the
sgpt.sh
to the engine comletion folder../argc-completions/completions
- if yo followed installation instructions it should be here
$ARGC_COMPLETIONS_ROOT/completions
Usage
Once installed, the completions will automatically activate as you type sgpt command follower by
--
and pressingTAB
in your terminal aap . You'll see suggestions for command options and arguments, making it easier to construct your commands.NOTE: for the
--model
suggestion to work correctly you should have the env varOPENAI_API_KEY
configured in~/.config/shell_gpt/.sgptrc
sgpt-shell-comletions-v0.2.zip
UPD with fix for '_sgpt' file so the role function will work corectly:
sgpt-shell-comletions-v0.3.zip
Beta Was this translation helpful? Give feedback.
All reactions