You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: chatgpt.sh
+24-24Lines changed: 24 additions & 24 deletions
Original file line number
Diff line number
Diff line change
@@ -5,7 +5,7 @@ CHAT_INIT_PROMPT="You are ChatGPT, a Large Language Model trained by OpenAI. You
5
5
6
6
SYSTEM_PROMPT="You are ChatGPT, a large language model trained by OpenAI. Answer as concisely as possible. Current date: $(date +%d/%m/%Y). Knowledge cutoff: 9/1/2021."
7
7
8
-
COMMAND_GENERATION_PROMPT="Return a one-line bash command with the functionality I will describe. Your output must follow this format \`command: the-actual-command\` and should be only the command, no quotes or other text. The command should do the following:"
8
+
COMMAND_GENERATION_PROMPT="Return a one-line bash command with the functionality I will describe. Return ONLY the command ready to run in the terminal. The command should do the following:"
9
9
10
10
EXPLAIN_CODE_PROMPT="Explain in great detail, step by step the following code. Identify any dependencies, libraries, software packages. If you find any errors suggest a solution. Try to guess the context and application it is used on. This is the code:"
11
11
@@ -215,20 +215,21 @@ CONTEXT=${CONTEXT:-false}
215
215
# create history file
216
216
if [ !-f~/.chatgpt_history ];then
217
217
touch ~/.chatgpt_history
218
-
chmod a+rw~/.chatgpt_history
218
+
chmod 600~/.chatgpt_history
219
219
fi
220
220
221
221
running=true
222
-
# check input source
223
-
# if prompt already entered, run on pipe mode (run once, no chat)
224
-
# prompt from pipe
225
-
if [ -p /dev/stdin ];then
226
-
pipe_mode_prompt+=$(cat -)
227
-
# prompt from argument
228
-
elif [ -n"$prompt" ];then
222
+
# check input source and determine run mode
223
+
224
+
# prompt from argument, run on pipe mode (run once, no chat)
225
+
if [ -n"$prompt" ];then
229
226
pipe_mode_prompt=${prompt}
230
-
else
227
+
# if input file_descriptor is a terminal, run on chat mode
228
+
elif [ -t 0 ];then
231
229
echo -e "Welcome to chatgpt. You can quit with '\033[36mexit\033[0m' or '\033[36mq\033[0m'."
230
+
# prompt from pipe or redirected stdin, run on pipe mode
if [[ "$response_data"==*"$dangerous_command"* ]];then
301
+
echo"Warning! This command can change your file system or download external scripts & data. Please do not execute code that you don't understand completely."
0 commit comments