config/zsh: implement aichat

This commit is contained in:
xeruf 2024-06-28 22:33:31 +03:00
parent 3b40c16b0c
commit d1ef716aa4
2 changed files with 56 additions and 36 deletions

View File

@ -189,8 +189,13 @@ source_existing() {
done done
} }
source_existing $CONFIG_ZSH/.p10k.zsh # To customize prompt, run `p10k configure` or edit .p10k.zsh. # To customize p10k prompt, run `p10k configure` or edit .p10k.zsh.
source_existing $CONFIG_ZSH/sgpt.zsh source $CONFIG_ZSH/.p10k.zsh
source $CONFIG_ZSH/aichat.zsh
for file in $(find "$CONFIG_ZSH" -name '*.zsh')
do #echo "sourcing $file"
# . $file
done
source_existing /usr/share/fzf/key-bindings.zsh /usr/share/fzf/completion.zsh source_existing /usr/share/fzf/key-bindings.zsh /usr/share/fzf/completion.zsh
source_existing "$NVM_DIR/nvm.sh" source_existing "$NVM_DIR/nvm.sh"
@ -205,3 +210,4 @@ source_existing $HOME/.nix-profile/etc/profile.d/nix.sh
which direnv >/dev/null && eval "$(direnv hook zsh)" which direnv >/dev/null && eval "$(direnv hook zsh)"
true true
l

14
.config/zsh/aichat.zsh Normal file
View File

@ -0,0 +1,14 @@
# https://github.com/sigoden/aichat/blob/main/scripts/shell-integration/integration.zsh
_aichat_zsh() {
if [[ -n "$BUFFER" ]]; then
local _old=$BUFFER
BUFFER+="⌛"
zle -I && zle redisplay
BUFFER=$(aichat -e "$_old")
zle end-of-line
fi
}
zle -N _aichat_zsh
# bindkey '\ee' _aichat_zsh
# Original above, this inspired by jsgpt
bindkey '^o' _aichat_zsh