Skip to content
/ nelson Public

nelson is a Unix Command Line Tool written in Bash that allows for AI suggestions, error explanations, and more, all straight from the terminal. Currently using OpenAI API (because that's what I know), planning to move into an open source, local LLM in the future.

License

Notifications You must be signed in to change notification settings

sawsent/nelson

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

37 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

nelson

Nelson is a Unix Command Line Tool written in Bash that allows for AI suggestions, error explanations, and more, all straight from the terminal. Currently using OpenAI API (because that's what I know), planning to move into an open source, local LLM in the future.


Important

This tool uses OpenAI's ChatGPT models to generate responses via their API. In order to use this tool, you need to have a valid API key. If you want to test out the tool, feel free to send me a message on Discord @sawsent , I might be able to provide one.


Dependencies

Required:

Recommended:


Instalation

Step 0: install dependencies with your favorite package manager

Step 1: clone repo wherever you'd like

git clone https://github.com/sawsent/nelson.git

Step 2: add your OpenAI key, folder location, and command alias to your shell config file

# .zshrc / .bashrc / .profile / ...
export OPENAI_API_KEY="your-openai-key"
export NELSON_LOCATION="path/to/nelson"
alias nelson="$NELSON_LOCATION/src/main.sh"

Step 3: Change shell HISTFILE in settings.sh

  1. Find out where you Command History file is located
echo $HISTFILE
# My output: /Users/vicente.figueiredo/.zhistory
  1. Replace in settings.sh
# setings.sh

# because we're using bash to run the script, it might be different than your main zsh or fish $HISTFILE (I think) 
export HISTFILE="/Users/vicente.figueiredo/.zhistory" # <- replace with your $HISTFILE

Step 4: Make the script executable!

You need to source your shell config file to access $NELSON_LOCATION

chmod +x $NELSON_LOCATION/src/main.sh

Usage

You can use this tool for as many reasons as you want. It's very easy to extend the functionality with custom system prompts and/or aliases.

Core features:

  1. Choose the model you want to use for the specific request (ex: --model=gpt-4o)
  2. Choose temperature you want to use (ex: --temp=0.5)
  3. Choose the max tokens you want to use (ex: --max-tokens=100)
  4. Choose the mode (System Prompt) to use with --\<mode>
  5. NEW: Choose a one-time System Prompt with --system-prompt="Custom Prompt"
  6. NEW: Ask nelson to explain the last error with nelson --wtf
  7. You can obviously change all defaults (see settings.sh)
  8. Commands run and OpenAI responses (the whole JSON response) can be stored in an history.log file

Core modes

(i didn't check if nelson was right btw, and Im using bat with some style opts for the output (see settings.sh))

  1. --neat (-n): Answers in the most concise way possible

  1. --long (-l): Explains in more detail

  1. --code (-c): Simply codes what's requested. No comments and no explanations

  1. --command (-com): Provides a Shell command based on the given parameters NEW: copy the command to the clipboard with a single click!


Nelson, wtf???

You can ask for clarification on your last command run by simply running nelson --wtf.

Customizability

You can easily change defaults, how the code is printed to the terminal in settings.sh.

You can also easily add more modes (System Prompts) in the system_prompts.sh. Simply follow the pattern that's already there!

case $1 in
  default)
    echo "$DEFAULT_SYSTEM_PROMPT"
    ;;
  # ...
  # ...
  your-custom-mode)
    echo "Your Custom System Prompt"
    ;;
  # ...

Once you do that, it will immediatly be available to use!

nelson --your-custom-mode Your question for nelson

(Keep in mind, you cant use any names that have already been defined as flags like --debug, --max-temperature, etc...). These take precedence in the flag hierarchy (they're evaluated first in the case block)


Upcoming

  • Add A Way to override system prompts directly in the command line: Instead of having to modify system_prompts.sh, you can simply do nelson --system-prompt="Custom System Prompt" question for occasional System Prompt needs.
  • Add Context Support (ex: nelson --explain-error / nelson --wtf): Automatically sends the last command run and the output for nelson to explain.
  • Migrate / add support for locally-hosted LLMs (like Llama): I have an API key because I put 10€ on a project once, but not everyone does so it would be better if you could use other APIs and self-hosted LLMs.

About

nelson is a Unix Command Line Tool written in Bash that allows for AI suggestions, error explanations, and more, all straight from the terminal. Currently using OpenAI API (because that's what I know), planning to move into an open source, local LLM in the future.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages