Replies: 1 comment
-
As an alternative fix, I made this shell function: function sgpt-edit
set file $argv[1]
set string $argv[2]
set temp_file (mktemp -p /tmp)
cat $file | sgpt $string > $temp_file && mv $temp_file $file
end Used like this: |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
When doing something like:
cat foo.py | sgpt --code "add docstring to this code" > foo.py
Linux first empties
foo.py
beforesgpt
can read it, so it eventually reads an empty file and writes garbage.This is due to how Linux orders the actions between
|
and>
and it was confusing to me, at first.This works:
cat foo.py | sgpt --code "add docstring to this code" > foo_new.py
Which you can follow by:
mv foo_new.py foo.py
But what about introducing this:
sgpt --edit foo.py --code "add docstring to this code"
It could also be used for non-code tasks, like:
sgpt --edit essay.txt "find and correct grammar errors"
Beta Was this translation helpful? Give feedback.
All reactions