mirror of https://github.com/sigoden/aichat
feat: add shell integration (#323)
parent
aec1b707af
commit
ff0ec15e06
@ -0,0 +1,7 @@
|
||||
_aichat_bash() {
|
||||
if [[ -n "$READLINE_LINE" ]]; then
|
||||
READLINE_LINE=$(aichat -e "$READLINE_LINE")
|
||||
READLINE_POINT=${#READLINE_LINE}
|
||||
fi
|
||||
}
|
||||
bind -x '"\ee": _aichat_bash'
|
@ -0,0 +1,9 @@
|
||||
function _aichat_fish
|
||||
set -l _old (commandline)
|
||||
if test -n $_old
|
||||
echo -n "⌛"
|
||||
commandline -f repaint
|
||||
commandline (aichat -e $_old)
|
||||
end
|
||||
end
|
||||
bind \ee _aichat_fish
|
@ -0,0 +1,10 @@
|
||||
Set-PSReadLineKeyHandler -Chord "alt+e" -ScriptBlock {
|
||||
$_old = $null
|
||||
[Microsoft.PowerShell.PSConsoleReadline]::GetBufferState([ref]$_old, [ref]$null)
|
||||
if ($_old) {
|
||||
[Microsoft.PowerShell.PSConsoleReadLine]::Insert('⌛')
|
||||
$_new = (aichat -e $_old)
|
||||
[Microsoft.PowerShell.PSConsoleReadLine]::DeleteLine()
|
||||
[Microsoft.PowerShell.PSConsoleReadline]::Insert($_new)
|
||||
}
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
_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
|
Loading…
Reference in New Issue