Git Product home page Git Product logo

englizsh's Introduction

englizsh

A zsh plugin that defines 4 keybindings to intuitively interface with any command-line GPT program. The idea is to toggle the contents of the shell buffer bidirectionally between natural language and shell command, and directly execute natural language using GPT as the translator. This means it can fully replace google for looking up the right command, and replace man/tldr for learning what a command does.

Usage

  1. Control + Space: Toggles the buffer between English and command. Assumes the buffer contains a command if the first word is a valid command according to command -v.
Control+Space.mp4
  1. Alt + Space: Explicitly translates the buffer from English to command. Useful when the first word is a command, for instance when you're typing a command but forgot some flags.
Alt+Space.mp4
  1. Enter: Executes commands normally, but if command is not found and there appears to be English in the buffer, then it is translated to shell before executing.
Enter.mp4
  1. Control + Enter: Explicitly translates the buffer from English to command and executes it. Useful when you know you're executing English but it doesn't appear like it.
Control+Enter.mp4

Installation

Manually

  1. Download/update the script to ~/.englizsh with curl:

curl https://raw.githubusercontent.com/chinarjoshi/englizsh/main/englizsh > ~/.englizsh

  1. Source the script in your zshrc, assuming it is in your home directory.

echo '. ~/.englizsh' >> ~/.zshrc

Configuration

Englizsh can be configured through the following environmental variables before the script is sourced:

  • ENGLISH_TO_SHELL_CMD: Command that translates natural language to shell command. Default: sgpt --shell. Note: the command can be anything, not just shell_gpt.
  • SHELL_TO_ENGLISH_CMD: Command that translates shell command to natural language. Default: sgpt --describe-shell
  • ENGLIZSH_SAFE_CMD_NO_CONFIRM: If true, executes non-destructive commands without prompting for confirmation
  • ENGLIZSH_DEFAULT_EXECUTE: If true, entering nothing when prompted for confirmation executes the command by default
  • TOGGLE_BUFFER_KEYBINDING: Keycode for function 1. Default: ^@
  • TOGGLE_ENGLISH_KEYBINDING: Keycode for function 2. Default: ^[@
  • EXECUTE_ENGLISH_KEYBINDING: Keycode for function 4. Default: ^[[27;5;13~

Tip: If your GPT program does not already have options to produce or describe shell commands, you can use the following prompts:

English to shell prompt
Provide only {YOUR SHELL} commands for {YOUR OS} without any description. If there is a lack of details, provide most logical solution. Ensure the output is a valid shell command. If multiple steps required try to combine them together.
Shell to English prompt
Provide a terse, single sentence description of the given shell command. IMPORTANT: Do NOT start with 'This command ...', instead start with a verb. Use the following example: Command: du -cks Answer: List the total disk usage of the current directory and its subdirectories in kilobytes

Tip: To find the keycode for the keybinding you wish to use, enter Control + v in zsh followed by the keybinding.


Special thanks to @TheR1D for feedback while developing this.

englizsh's People

Contributors

chinarjoshi avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

englizsh's Issues

Idea: Include last few lines of history in the prompt

This could provide it with context of what you're doing, and carry on the same "chain of thought".

Perhaps even have a "chat" scoped per shell session, so you could so something like

Record my screen for a minute

Convert that recording to mp4 and save it in /tmp

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.