From 569c9a18a34793f46ed0d11e92b4f9c1848aa6ba Mon Sep 17 00:00:00 2001 From: flu0r1ne Date: Sat, 6 May 2023 18:04:53 -0500 Subject: Add more tricks --- README.md | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) diff --git a/README.md b/README.md index f7ad16d..ec929e4 100644 --- a/README.md +++ b/README.md @@ -208,6 +208,56 @@ sorting an array of pointers to `dl_entry` structures based on the `access_time` [#] ``` +Create a bash alias for a particular model: + +``` +$ alias gpt3='gpt-chat-cli -m gpt-3.5-turbo' +$ gpt3 +[#] ... +``` + +Of course, custom scripting can extend the capabilities. For example, this `bash` function will suggest commands to accomplish tasks on the command line: + +```bash +function cmd { + local request="$1" + local shell=$(basename "${SHELL}") + + local os="" + + if command -v lsb_release >/dev/null 2>&1; then + os="$ lsb_release -a\n$(lsb_release -a)\n" + fi + + local kernel="" + + if command -v uname >/dev/null 2>&1; then + kernel="$ uname -s -r\n$(uname -s -r)\n" + fi + + local prompt="" + + prompt="${prompt}Suggest a command to be run in the $shell to accomplish the following task:\n" + prompt="${prompt}$request\n" + prompt="${prompt}Please output the command and a short description\n" + + if [ -n "${os}" ] || [ -n "${kernel}" ]; then + prompt="${prompt}Here is some additional info about the system:${os}${kernel}" + fi + + printf "$prompt" | gpt-chat-cli +} +``` + +``` +$ cmd "test if ip forwarding is enabled" +[gpt-3.5-turbo-0301] You can use the `sysctl` command to test if IP forwarding is enabled. Here's the command you can run in your zsh shell: + +sysctl net.ipv4.ip_forward + +This command will return `net.ipv4.ip_forward = 0` if IP forwarding is disabled and `net.ipv4.ip_forward = 1` if IP forwarding is enabled. +``` + #### Known Issues There are a couple known issues. PRs are accepted: -- cgit v1.2.3