Git Product home page Git Product logo

cmd's Introduction

cmd

Most common usage is to pass your message as an argument (wrap it in quotes if it contains special shell modifiers like * or ?): cmd hi or cmd "what's up?". Addtionally, you can pipe content to it:

cat README.md | cmd briefly describe functionality
Cmd is a versatile command-line tool that leverages AI to understand natural language input and generate shell commands or even entire scripts. It offers various flags to enhance its functionality. You can use `-run` to execute the generated command and display the output, while `-exec` executes the command without showing the generation process or output. For multi-turn interactions, there's `-chat`, and you can configure the model, connectors, and other settings with `-config` and related flags. Additionally, content can be piped into cmd for quick processing.

Install

$ brew tap daulet/cmd && brew install cmd

run code

If you'd like to run the generated shell command or code, use -run:

$ cmd -run print third last commit hash
To print the third last commit hash, you can use the following Git command:

bash
git log --pretty=format:"%H" -n 1 --skip 2

This command will display the commit hash of the commit that is two commits before the most recent one. The `--pretty=format:"%H"` option specifies that you want to display the commit hash in the output, and the `-n 1` option limits the output to only one commit. The `--skip 2` option skips the two most recent commits and displays the hash of the third last commit.
a200e6d429e2888344d7254ac02a00618ab432a2

Supported languages include Go, Bash, Python and HTML. The language is assumed from identifier immediately following backticks of fenced code blocks, hence it could be error prone if no language is specified, or if code is broken down into multiple blocks (common for HTML).

execute code

To just execute generated command or a script (like -run), but without actually outputing it (useful for piping), use -exec, which will not output generation hence be patient:

$ cmd -exec print shell command to brief description for last five commits
27a6a07 add an option to execute generate command
ac88d6a parse code blocks as we stream, not after the fact
a200e6d simplify now that code parsing is async
6d36937 rename Buffer to Code
d42893c (HEAD -> main, origin/main) simplify code parser, make exec truly optional

chat

To start a multi turn chat session use -chat:

$ cmd -chat
User> (your message)

Which is also compatible with other flags, like -run, that can be used to iterate on a solution:

$ cmd -run -chat
User> html for a bouncing ball

Configure

You can check current configuration using cmd -config, and to change it use:

  • -model to set the model (use -list-models to see your options);
  • -connectors to set comma delimited connectors (use -list-connectors to see your options);
  • -temperature to set the temperature;
  • -top-p to set the top P;
  • -top-k to set the top K;
  • -frequency-penalty to set the frequency penalty;
  • -presence-penalty to set the presence penalty;
$ cmd -connectors web-search

Cool use cases

Read PDF document

Pipe with xpdf (brew install xpdf) or similar:

$ pdftotext -nopgbrk -eol unix -q document.pdf - | cmd tldr

Use web search

Seemingly unrelated tasks could benefit from web search, e.g. here is a result of cmd -run html for a bouncing ball:

gif of a bouncing ball

and here is the result with web search enabled (cmd -connectors web-search):

gif of a bouncing ball

Data transformation

A common mundane task that this tool could simplify is transforming or otherwise parsing data from one format to another. However, there are multiple ways to approach this, e.g. you could ask LLM to transform the data directly, or you could ask cmd to write a program to transform the data. The better solution depends on the amount of data you have, and the complexity of the transformation.

cat house-prices.csv | cmd convert to json
```json
[
    {
        "Home": 1,
        "Price": 114300,
        "SqFt": 1790,
        "Bedrooms": 2,
        "Bathrooms": 2,
        "Offers": 2,
        "Brick": "No",
        "Neighborhood": "East"
    },
    { ...

Programmatic approach (program is still written by LLM):

cat house-prices.csv | cmd -exec write python program to convert this to json and read the data from house-prices.csv
[
    {
        "Home": "1",
        "Price": "114300",
        "SqFt": "1790",
        "Bedrooms": "2",
        "Bathrooms": "2",
        "Offers": "2",
        "Brick": "No",
        "Neighborhood": "East"
    },
    { ...

Of course whichever approach you choose, you can always pipe the output to another command to further process it.

cat house-prices.csv | cmd -exec write python program to convert this to json and print it out, read the data from house-prices.csv | cmd -run run python program to plot this data

cmd's People

Contributors

daulet avatar

Stargazers

 avatar jeremyp avatar adrien... avatar

Watchers

 avatar

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.