blob: b8b542da3c586875335518d0437834fe94a16ebd (
plain)
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
|
#!/bin/sh
set -e
# Check if input is piped
if [ -t 0 ]; then
input="$1"
else
input=$(cat | sed -E "s/\x1b\[[0-9;]*m//g")
fi
# Use a temporary file for the processed content
tmpfile=$(mktemp /tmp/nvim_buffer_cleaned.XXXXXX)
# Save the input to the temporary file
echo "$input" >"$tmpfile"
# Process the input and open Neovim directly, ensuring it doesn't suspend
nvim -c "GpChatNew" \
-c "call append(line('$'), readfile('$tmpfile'))" \
-c "normal iKeep your responses short and simple, when asked to provide command, provide only one. Do not provide explanations unless explicitly asked for." \
-c "normal o" \
-c "call timer_start(100, {-> feedkeys('A', 'n')})"
# Remove the temporary file after usage
rm "$tmpfile"
|