-
-
Notifications
You must be signed in to change notification settings - Fork 913
Description
Discussed in #173
Originally posted by chinarjoshi April 11, 2023
Natural language to bash is a powerful tool that I believe deserves its own built in interface into the shell rather than a separate program. I propose an interface where users can toggle between natural language and English with a key binding to create a more user-friendly shell. Not to bash bash, but simple tasks should not take research on which program + flag combo will yield the right result with external programs like man and google. It is a more intuitive interface to toggle between a description and its command with a keybinding that invokes the sgpt program, rather than typing sgpt -s "command" every time. This is useful if you forget a flag midway through a command or want to figure out what a command does. Developers of any experience, especially people new to the terminal, frequently face this issue; thus, there must be an interface integrated directly with the shell to save both key presses and the cognitive load of another program.
This interface behaves as such
Makes a key binding that transforms the content of the buffer based on what is currently in it, which has 4 cases:
- Shell command -> natural language description
- Natural language -> shell command
- No text -> natural language description of previous command
- If there is natural language in the buffer and the user presses enter, then the command is translated to shell before executing. If it is a non-destructive command, it is directly executed. Otherwise, the user is prompted before execution, just like the default behavior.
This interface comprises of two changes
- Shell script that is sourced by the users shell rc file that creates a keybinding that toggles the buffer using the sgpt program
- New "--describe-shell" command that produces a single imperative sentence that describes a given shell command. This addresses An option that adds an explanation of the command and/or arguments #118 .
Here is a demonstration of the described behavior. I will make a pull request containing these changes.