-
Notifications
You must be signed in to change notification settings - Fork 22
#37: Add current OS #44
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -184,8 +184,24 @@ get_key_from_keychain() { | |
| OPENAI_API_KEY="${key}" | ||
| } | ||
|
|
||
| get_os() { | ||
| unameOut=$(uname -s) | ||
| case "$unameOut" in | ||
| Darwin) | ||
| os="MacOS" | ||
| ;; | ||
| Linux) | ||
| ;& | ||
| *) | ||
| # Any windows solutions are assumed to be Linux compatibla | ||
| os="Linux" | ||
| ;; | ||
| esac | ||
| } | ||
|
|
||
| get_command() { | ||
| role="You translate the given input into a Linux command. You may not use natural language, but only a Linux shell command as an answer. | ||
| os=get_os | ||
| role="You translate the given input into a bash command for $os. You may not use natural language, but only a bash command as an answer. | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would suggest not to use
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Alternatively one may retrieve information about the shell in use, e.g. from the
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @heiderich @xenia-lang I'd like to get this PR merged—the idea seems useful to me. e.g. using and the adapting the prompt to: There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sounds good |
||
| Do not use markdown. Do not quote the whole output. If you do not know the answer, answer with \\\"${fail_msg}\\\"." | ||
|
|
||
| payload=$(printf %s "$commandDescription" | jq --slurp --raw-input --compact-output '{ | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does the assignment to os in
os=get_oshave any effect at all?If I read the definition of
get_oscorrectly, then it doesn't actually return any value, but directly assign the OS name to theosvariable.To return something, shouldn't it be:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And then the function call would be
os=$(get_os)