Skip to content

A Natural Language Interface to Enhance User-Friendly Command Line Experience #194

@chinarjoshi

Description

@chinarjoshi

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:

  1. Shell command -> natural language description
  2. Natural language -> shell command
  3. No text -> natural language description of previous command
  4. 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

  1. Shell script that is sourced by the users shell rc file that creates a keybinding that toggles the buffer using the sgpt program
  2. 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.

shell_integrations_demo.mp4

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions