-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathchatgptsearchascript
executable file
·37 lines (29 loc) · 2.17 KB
/
chatgptsearchascript
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#!/bin/bash
if [ "$#" -eq 0 ] || [ "$1" = "-h" ] || [ "$1" = "--help" ]; then
echo "Usage: $(basename $0) [options] [task description]"
echo ""
echo "Options:"
echo " -h, --help Show this help message and exit"
echo ""
echo "Description:"
echo " This script searches for a suitable ChatGPT related command line utility to perform a task"
echo " whose description is given in the command line arguments."
exit 0
fi
_makeusagetxt
prompt="$*"
script_dir="$(dirname "$(realpath "$0")")"
usages_file="${script_dir}/_usages.txt"
if [ ! -f "$usages_file" ]; then
echo "Error: '_usages.txt' file not found in the script directory."
exit 1
fi
additional_prompt="\n\n#Instructions\nThese are the usage descriptions of several command line utilities. Please tell me which script I could use to perform the following task and print it's usage comment:\n"
cat "$usages_file" | sed -e 's/promptlib:/promptlib(colon)/g' | chatgpt - "$additional_prompt $prompt"
# This script was generated using ChatGPT with the following prompt, and then manually edited slightly:
# Please generate a script for the command line for the following task, runnable on a MacBook Pro with Apple M1 Max, that is, arm64 architecture, and MacOS Ventura 13.3.1 . It can be either a bash script using any of the normally present MacOS command line tools or what is installable with homebrew, or a NodeJS script for version 19.5.0 . If NodeJS, it should not require installing any additional libraries. If called without arguments or with the argument
# --help, the script should describe it's usage and exit - including what options and arguments it expects, and (important!) a short description what it does.
# The name of the script is chatgptsearchscript. If the option --help wasn't given, it should collect all command line arguments into the variable prompt. Then it should take the file _usages.txt in the directory containing the script, pipe that into the program chatgpt with the arguments
# chatgpt - $additionalprompt $prompt
# where additionalprompt is as follows:
# "These are the usage descriptions of several command line utilities. Please tell me which script I could use to perform the following task:"