config/zsh: implement aichat
This commit is contained in:
parent
3b40c16b0c
commit
d1ef716aa4
|
@ -1,6 +1,6 @@
|
||||||
GITSTATUS_LOG_LEVEL=DEBUG
|
GITSTATUS_LOG_LEVEL=DEBUG
|
||||||
# Commands
|
# Commands
|
||||||
if test "$PWD" = "$HOME" && test "$0" != "$SHELL"; then
|
if test "$PWD" = "$HOME" && test "$0" != "$SHELL"; then
|
||||||
neofetch --config $XDG_CONFIG_HOME/neofetch/config-$(test -z "$DISPLAY" && test "$XDG_VTNR" -eq 1 && echo short || echo server).conf
|
neofetch --config $XDG_CONFIG_HOME/neofetch/config-$(test -z "$DISPLAY" && test "$XDG_VTNR" -eq 1 && echo short || echo server).conf
|
||||||
timew | head -3
|
timew | head -3
|
||||||
fi 2>/dev/null || return 0
|
fi 2>/dev/null || return 0
|
||||||
|
@ -52,43 +52,43 @@ source $ZSH/oh-my-zsh.sh
|
||||||
## Functions
|
## Functions
|
||||||
|
|
||||||
tab_list_files() {
|
tab_list_files() {
|
||||||
if [[ $#BUFFER == 0 ]]; then
|
if [[ $#BUFFER == 0 ]]; then
|
||||||
BUFFER="ls "
|
BUFFER="ls "
|
||||||
CURSOR=3
|
CURSOR=3
|
||||||
zle list-choices
|
zle list-choices
|
||||||
zle backward-kill-word
|
zle backward-kill-word
|
||||||
elif [[ $BUFFER =~ ^[[:space:]][[:space:]].*$ ]]; then
|
elif [[ $BUFFER =~ ^[[:space:]][[:space:]].*$ ]]; then
|
||||||
BUFFER="./"
|
BUFFER="./"
|
||||||
CURSOR=2
|
CURSOR=2
|
||||||
zle list-choices
|
zle list-choices
|
||||||
[ -z ${TAB_LIST_FILES_PREFIX+x} ] && BUFFER=" " CURSOR=2
|
[ -z ${TAB_LIST_FILES_PREFIX+x} ] && BUFFER=" " CURSOR=2
|
||||||
elif [[ $BUFFER =~ ^[[:space:]]*$ ]]; then
|
elif [[ $BUFFER =~ ^[[:space:]]*$ ]]; then
|
||||||
BUFFER="cd "
|
BUFFER="cd "
|
||||||
CURSOR=3
|
CURSOR=3
|
||||||
zle list-choices
|
zle list-choices
|
||||||
[ -z ${TAB_LIST_FILES_PREFIX+x} ] && BUFFER=" " CURSOR=1
|
[ -z ${TAB_LIST_FILES_PREFIX+x} ] && BUFFER=" " CURSOR=1
|
||||||
else
|
else
|
||||||
BUFFER_=$BUFFER
|
BUFFER_=$BUFFER
|
||||||
CURSOR_=$CURSOR
|
CURSOR_=$CURSOR
|
||||||
zle expand-or-complete || zle expand-or-complete || {
|
zle expand-or-complete || zle expand-or-complete || {
|
||||||
BUFFER="ls "
|
BUFFER="ls "
|
||||||
CURSOR=3
|
CURSOR=3
|
||||||
zle list-choices
|
zle list-choices
|
||||||
BUFFER=$BUFFER_
|
BUFFER=$BUFFER_
|
||||||
CURSOR=$CURSOR_
|
CURSOR=$CURSOR_
|
||||||
}
|
}
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
zle -N tab_list_files
|
zle -N tab_list_files
|
||||||
bindkey '^I' tab_list_files
|
bindkey '^I' tab_list_files
|
||||||
|
|
||||||
fancy-ctrl-z() {
|
fancy-ctrl-z() {
|
||||||
if [[ $#BUFFER -eq 0 ]]; then
|
if [[ $#BUFFER -eq 0 ]]; then
|
||||||
bg
|
bg
|
||||||
zle redisplay
|
zle redisplay
|
||||||
else
|
else
|
||||||
zle push-input
|
zle push-input
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
zle -N fancy-ctrl-z
|
zle -N fancy-ctrl-z
|
||||||
bindkey '^z' fancy-ctrl-z
|
bindkey '^z' fancy-ctrl-z
|
||||||
|
@ -159,7 +159,7 @@ setopt hist_save_no_dups
|
||||||
setopt hist_reduce_blanks
|
setopt hist_reduce_blanks
|
||||||
unsetopt hist_ignore_space
|
unsetopt hist_ignore_space
|
||||||
zshaddhistory() {
|
zshaddhistory() {
|
||||||
[[ $1 != netkeeper* ]] && [[ $1 != killm* ]] && [[ $1 != "stretchly reset" ]]
|
[[ $1 != netkeeper* ]] && [[ $1 != killm* ]] && [[ $1 != "stretchly reset" ]]
|
||||||
}
|
}
|
||||||
|
|
||||||
setopt sh_word_split # https://github.com/zsh-users/zsh-history-substring-search/issues/154
|
setopt sh_word_split # https://github.com/zsh-users/zsh-history-substring-search/issues/154
|
||||||
|
@ -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
|
||||||
|
|
|
@ -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
|
Loading…
Reference in New Issue