From d275c33632271bf9cdbc01ef005deb9ff851370b Mon Sep 17 00:00:00 2001 From: sigoden Date: Sat, 2 Mar 2024 08:07:06 +0000 Subject: chore: move integration scripts --- README.md | 15 +++------------ scripts/integration.bash | 7 ------- scripts/integration.fish | 9 --------- scripts/integration.ps1 | 10 ---------- scripts/integration.zsh | 11 ----------- scripts/shell-integration/integration.bash | 7 +++++++ scripts/shell-integration/integration.fish | 9 +++++++++ scripts/shell-integration/integration.ps1 | 10 ++++++++++ scripts/shell-integration/integration.zsh | 11 +++++++++++ 9 files changed, 40 insertions(+), 49 deletions(-) delete mode 100644 scripts/integration.bash delete mode 100644 scripts/integration.fish delete mode 100644 scripts/integration.ps1 delete mode 100644 scripts/integration.zsh create mode 100644 scripts/shell-integration/integration.bash create mode 100644 scripts/shell-integration/integration.fish create mode 100644 scripts/shell-integration/integration.ps1 create mode 100644 scripts/shell-integration/integration.zsh diff --git a/README.md b/README.md index 9048e91..3e8b67a 100644 --- a/README.md +++ b/README.md @@ -53,7 +53,7 @@ Download it from [GitHub Releases](https://github.com/sigoden/aichat/releases), - VertexAI (paid, vision) - Ernie (paid) - Qianwen (paid, vision) -- Support [REPL Mode](#chat-repl) and [Command Mode][#command] +- Support [REPL Mode](#chat-repl) and [Command Mode](#command) - Support [Roles](#roles) - Support context-aware conversation (session) - Support multimodal models (vision) @@ -62,7 +62,7 @@ Download it from [GitHub Releases](https://github.com/sigoden/aichat/releases), - Save messages/sessions - Stream/Non-stream output - With proxy -- With Dark/light theme +- With dark/light theme ## Config @@ -399,16 +399,7 @@ This is a **very handy feature**, which allows you to use `aichat` shell complet ![aichat-integration](https://github.com/sigoden/aichat/assets/4012553/873ebf23-226c-412e-a34f-c5aaa7017524) -To install shell integration, run the following code: - -```sh -sh_ext=bash # possible values: bash, fish, zsh, ps1 -sh_url=https://raw.githubusercontent.com/sigoden/aichat/main/scripts/integration.$sh_ext -curl -o aichat-integration.$sh_ext $sh_url -source aichat-integration.$sh_ext -``` - -After that restart your shell. You can invoke the completion with `alt+e` hotkey. +To install shell integration, go to [./scripts/shell-integration](./scripts/shell-integration/) to download the script and source the script in rc file. After that restart your shell. You can invoke the completion with `alt+e` hotkey. ## License diff --git a/scripts/integration.bash b/scripts/integration.bash deleted file mode 100644 index 572c7be..0000000 --- a/scripts/integration.bash +++ /dev/null @@ -1,7 +0,0 @@ -_aichat_bash() { - if [[ -n "$READLINE_LINE" ]]; then - READLINE_LINE=$(aichat -e "$READLINE_LINE") - READLINE_POINT=${#READLINE_LINE} - fi -} -bind -x '"\ee": _aichat_bash' \ No newline at end of file diff --git a/scripts/integration.fish b/scripts/integration.fish deleted file mode 100644 index 2d4dfb9..0000000 --- a/scripts/integration.fish +++ /dev/null @@ -1,9 +0,0 @@ -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 \ No newline at end of file diff --git a/scripts/integration.ps1 b/scripts/integration.ps1 deleted file mode 100644 index 6a94189..0000000 --- a/scripts/integration.ps1 +++ /dev/null @@ -1,10 +0,0 @@ -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) - } -} \ No newline at end of file diff --git a/scripts/integration.zsh b/scripts/integration.zsh deleted file mode 100644 index 2328bd6..0000000 --- a/scripts/integration.zsh +++ /dev/null @@ -1,11 +0,0 @@ -_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 \ No newline at end of file diff --git a/scripts/shell-integration/integration.bash b/scripts/shell-integration/integration.bash new file mode 100644 index 0000000..572c7be --- /dev/null +++ b/scripts/shell-integration/integration.bash @@ -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' \ No newline at end of file diff --git a/scripts/shell-integration/integration.fish b/scripts/shell-integration/integration.fish new file mode 100644 index 0000000..2d4dfb9 --- /dev/null +++ b/scripts/shell-integration/integration.fish @@ -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 \ No newline at end of file diff --git a/scripts/shell-integration/integration.ps1 b/scripts/shell-integration/integration.ps1 new file mode 100644 index 0000000..6a94189 --- /dev/null +++ b/scripts/shell-integration/integration.ps1 @@ -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) + } +} \ No newline at end of file diff --git a/scripts/shell-integration/integration.zsh b/scripts/shell-integration/integration.zsh new file mode 100644 index 0000000..2328bd6 --- /dev/null +++ b/scripts/shell-integration/integration.zsh @@ -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 \ No newline at end of file -- cgit v1.2.3