Skip to content

Instantly share code, notes, and snippets.

@WolframRavenwolf
Created December 21, 2023 22:09
Show Gist options
  • Save WolframRavenwolf/fb68cdda54193b154a3016d2626e152b to your computer and use it in GitHub Desktop.
Save WolframRavenwolf/fb68cdda54193b154a3016d2626e152b to your computer and use it in GitHub Desktop.
ShellGPT Aliases/Functions for Bash and Zsh
# ==============================================================================
# ShellGPT
# ==============================================================================
# ------------------------------------------------------------------------------
if which sgpt >/dev/null 2>&1; then
# ------------------------------------------------------------------------------
alias sgpt-chat="sgpt --repl chat"
alias sgpt-code="sgpt --repl code --code"
alias sgpt-describe-shell="sgpt --repl describe-shell --describe-shell"
alias sgpt-shell="sgpt --repl shell --shell"
alias sgpt-temp-chat="sgpt --repl temp"
alias sgpt-temp-code="sgpt --repl temp --code"
alias sgpt-temp-describe-shell="sgpt --repl temp --describe-shell"
alias sgpt-temp-shell="sgpt --repl temp --shell"
sgpt-clear-all() { (source ${XDG_CONFIG_HOME:-"$HOME"/.config}/shell_gpt/.sgptrc && find "${CACHE_PATH:?}" "${CHAT_CACHE_PATH:?}" -maxdepth 1 -mindepth 1 -type f -delete); }
sgpt-clear-cache() { (source ${XDG_CONFIG_HOME:-"$HOME"/.config}/shell_gpt/.sgptrc && find "${CACHE_PATH:?}" -maxdepth 1 -mindepth 1 -type f -delete); }
sgpt-clear-chats() { (source ${XDG_CONFIG_HOME:-"$HOME"/.config}/shell_gpt/.sgptrc && find "${CHAT_CACHE_PATH:?}" -maxdepth 1 -mindepth 1 -type f -delete); }
# chat (q = gpt-4-1106-preview | Q = gpt-4 | QQ = gpt-4-32k | - = clear chat | -- = clear cache | --- = clear all)
q:() { if [ -z "$*" ]; then sgpt --repl chat; else sgpt --chat chat "$*"; fi; }
q:-() { (source ${XDG_CONFIG_HOME:-"$HOME"/.config}/shell_gpt/.sgptrc && find "${CHAT_CACHE_PATH:?}" -maxdepth 1 -mindepth 1 -name chat -type f -delete); }
q:--() { (source ${XDG_CONFIG_HOME:-"$HOME"/.config}/shell_gpt/.sgptrc && find "${CACHE_PATH:?}" -maxdepth 1 -mindepth 1 -type f -delete); }
q:---() { q:-; q:--; }
Q:() { if [ -z "$*" ]; then sgpt --model gpt-4 --repl chat; else sgpt --model gpt-4 --chat chat "$*"; fi; }
Q:-() { q:-; }
Q:--() { q:--; }
Q:---() { q:---; }
QQ:() { if [ -z "$*" ]; then sgpt --model gpt-4-32k --repl chat; else sgpt --model gpt-4-32k --chat chat "$*"; fi; }
QQ:-() { q:-; }
QQ:--() { q:--; }
QQ:---() { q:---; }
# shell (s = gpt-4-1106-preview | S = gpt-4 | SS = gpt-4-32k | - = clear chat | -- = clear cache | --- = clear all)
s:() { if [ -z "$*" ]; then sgpt --shell --repl shell; else sgpt --shell --chat shell "$*"; fi; }
s:-() { (source ${XDG_CONFIG_HOME:-"$HOME"/.config}/shell_gpt/.sgptrc && find "${CHAT_CACHE_PATH:?}" -maxdepth 1 -mindepth 1 -name shell -type f -delete); }
s:--() { (source ${XDG_CONFIG_HOME:-"$HOME"/.config}/shell_gpt/.sgptrc && find "${CACHE_PATH:?}" -maxdepth 1 -mindepth 1 -type f -delete); }
s:---() { s:-; s:--; }
S:() { if [ -z "$*" ]; then sgpt --model gpt-4 --shell --repl shell; else sgpt --model gpt-4 --shell --chat shell "$*"; fi; }
S:-() { s:-; }
S:--() { s:--; }
S:---() { s:---; }
SS:() { if [ -z "$*" ]; then sgpt --model gpt-4-32k --shell --repl shell; else sgpt --model gpt-4-32k --shell --chat shell "$*"; fi; }
SS:-() { s:-; }
SS:--() { s:--; }
SS:---() { s:---; }
# describe-shell (d = gpt-4-1106-preview | D = gpt-4 | DD = gpt-4-32k | - = clear chat | -- = clear cache | --- = clear all)
d:() { if [ -z "$*" ]; then sgpt --describe-shell --repl describe-shell; else sgpt --describe-shell --chat describe-shell "$*"; fi; }
d:-() { (source ${XDG_CONFIG_HOME:-"$HOME"/.config}/shell_gpt/.sgptrc && find "${CHAT_CACHE_PATH:?}" -maxdepth 1 -mindepth 1 -name describe-shell -type f -delete); }
d:--() { (source ${XDG_CONFIG_HOME:-"$HOME"/.config}/shell_gpt/.sgptrc && find "${CACHE_PATH:?}" -maxdepth 1 -mindepth 1 -type f -delete); }
d:---() { d:-; d:--; }
D:() { if [ -z "$*" ]; then sgpt --model gpt-4 --describe-shell --repl describe-shell; else sgpt --model gpt-4 --describe-shell --chat describe-shell "$*"; fi; }
D:-() { d:-; }
D:--() { d:--; }
D:---() { d:---; }
DD:() { if [ -z "$*" ]; then sgpt --model gpt-4-32k --describe-shell --repl describe-shell; else sgpt --model gpt-4-32k --describe-shell --chat describe-shell "$*"; fi; }
DD:-() { d:-; }
DD:--() { d:--; }
DD:---() { d:---; }
# code (c = gpt-4-1106-preview | C = gpt-4 | CC = gpt-4-32k | - = clear chat | -- = clear cache | --- = clear all)
c:() { if [ -z "$*" ]; then sgpt --code --repl code; else sgpt --code --chat code "$*"; fi; }
c:-() { (source ${XDG_CONFIG_HOME:-"$HOME"/.config}/shell_gpt/.sgptrc && find "${CHAT_CACHE_PATH:?}" -maxdepth 1 -mindepth 1 -name code -type f -delete); }
c:--() { (source ${XDG_CONFIG_HOME:-"$HOME"/.config}/shell_gpt/.sgptrc && find "${CACHE_PATH:?}" -maxdepth 1 -mindepth 1 -type f -delete); }
c:---() { c:-; c:--; }
C:() { if [ -z "$*" ]; then sgpt --model gpt-4 --code --repl code; else sgpt --model gpt-4 --code --chat code "$*"; fi; }
C:-() { c:-; }
C:--() { c:--; }
C:---() { c:---; }
CC:() { if [ -z "$*" ]; then sgpt --model gpt-4-32k --code --repl code; else sgpt --model gpt-4-32k --code --chat code "$*"; fi; }
CC:-() { c:-; }
CC:--() { c:--; }
CC:---() { c:---; }
# ------------------------------------------------------------------------------
fi
# ------------------------------------------------------------------------------
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment