Nutshell is an enhanced Unix shell that provides a simplified command language, package management, and AI-powered assistance.
- Friendly command aliases (e.g.,
peekabooforls,hopforcd) - Built-in package management system
- Dynamic package installation without rebuilding
- Debug logging for development
- Interactive Git commit helper (gitify package)
- Shell command history
- Redirection and background process support
- AI-powered command assistance (NEW)
- C compiler (clang or gcc)
- readline library
- OpenSSL
- libcurl
- Jansson (optional, for package management)
git clone https://github.com/chandralegend/nutshell.git
cd nutshell
make# If using the formula directly
brew install --build-from-source ./nutshell.rb
# If using the tap (Note: This tap is not yet available)
brew tap chandralegend/nutshell
brew install nutshellsudo make installmake install-userThen add $HOME/bin to your PATH if it's not already there:
echo 'export PATH=$PATH:$HOME/bin' >> ~/.bashrc # or ~/.zshrc or ~/.bash_profile| Nutshell command | Unix equivalent | Description |
|---|---|---|
peekaboo |
ls |
List directory contents |
hop |
cd |
Change directory |
roast |
exit |
Exit the shell |
Commands work just like in a standard Unix shell:
π₯ ~/projects β peekaboo -la
π₯ ~/projects β hop nutshell
π₯ ~/projects/nutshell β command arg1 arg2Nutshell includes AI features to help with shell commands:
-
Get an OpenAI API key from OpenAI Platform
-
Set your API key:
π₯ ~ β set-api-key YOUR_API_KEYAlternatively, set it as an environment variable:
export OPENAI_API_KEY=your_api_key
Convert natural language to shell commands:
π₯ ~ β ask find all PDF files modified in the last weekThe shell will return the proper command and ask if you want to execute it.
Get explanations for complex commands:
π₯ ~ β explain find . -name "*.txt" -mtime -7 -exec grep -l "important" {} \;Automatically fix common command errors:
π₯ ~ β torch apple.txt
π₯ ~ β fix # Will suggest to use touch apple.txt instead.The shell will suggest corrections for common mistakes and ask if you want to apply them.
Enable AI debugging with environment variables:
# Run with AI debugging enabled
NUT_DEBUG_AI=1 ./nutshell
# Run with verbose API response logging
NUT_DEBUG_AI=1 NUT_DEBUG_AI_VERBOSE=1 ./nutshell
# Use the debug script
./scripts/debug_ai.shNutshell has a built-in package system for extending functionality.
π₯ ~/projects β install-pkg gitify
You can also install from a local directory:
π₯ ~/projects β install-pkg /path/to/package
The gitify package provides an interactive Git commit helper:
π₯ ~/projects/my-git-repo β gitify
Follow the prompts to stage files and create semantic commit messages.
Nutshell comes with a customizable theme system:
π₯ ~ β themeThis will show all available themes, with the current theme marked with an asterisk (*).
π₯ ~ β theme minimalThis will switch to the "minimal" theme.
- Create a new JSON file in
~/.nutshell/themes/namedmytheme.json - Use the following template:
{
"name": "mytheme",
"description": "My custom theme",
"colors": {
"reset": "\u001b[0m",
"primary": "\u001b[1;35m", // Purple
"secondary": "\u001b[1;33m", // Yellow
"error": "\u001b[1;31m",
"warning": "\u001b[0;33m",
"info": "\u001b[0;34m",
"success": "\u001b[0;32m"
},
"prompt": {
"left": {
"format": "{primary}{icon} {directory}{reset} ",
"icon": "π"
},
"right": {
"format": "{git_branch}"
},
"multiline": false,
"prompt_symbol": "β ",
"prompt_symbol_color": "primary"
},
"segments": {
"git_branch": {
"enabled": true,
"format": "{secondary}git:({branch}){reset} ",
"command": "git branch --show-current 2>/dev/null"
},
"directory": {
"format": "{directory}",
"command": "pwd | sed \"s|$HOME|~|\""
}
}
}- Switch to your theme with
theme mytheme
Nutshell now supports project-specific configurations through directory-level config files:
- Nutshell searches for a
.nutshell.jsonconfiguration file in the current directory - If not found, it looks in parent directories until reaching your home directory
- Directory configs take precedence over user configs which take precedence over system configs
- Configurations are automatically reloaded when you change directories using
cd
Create a .nutshell.json file in your project directory:
{
"theme": "minimal",
"aliases": {
"build": "make all",
"test": "make test",
"deploy": "scripts/deploy.sh"
},
"packages": ["gitify"]
}- Project-specific aliases and settings
- Different themes for different projects
- Shared configurations for team projects (add
.nutshell.jsonto version control) - Hierarchical configuration (team settings in parent dir, personal tweaks in subdirs)
For development or troubleshooting, run the debug script:
./scripts/debug-nutshell.shThis enables detailed logging of command parsing and execution.
Nutshell supports the following debug environment variables:
NUT_DEBUG=1- Enable general debug outputNUT_DEBUG_THEME=1- Enable theme system debuggingNUT_DEBUG_PKG=1- Enable package system debuggingNUT_DEBUG_PARSER=1- Enable command parser debuggingNUT_DEBUG_EXEC=1- Enable command execution debuggingNUT_DEBUG_REGISTRY=1- Enable command registry debuggingNUT_DEBUG_AI=1- Enable AI integration debuggingNUT_DEBUG_AI_SHELL=1- Enable AI shell integration debuggingNUT_DEBUG_AI_VERBOSE=1- Enable verbose API response logging
Example:
# Run with theme debugging enabled
NUT_DEBUG_THEME=1 ./nutshell
# Run with all debugging enabled
NUT_DEBUG=1 NUT_DEBUG_THEME=1 NUT_DEBUG_PARSER=1 NUT_DEBUG_EXEC=1 NUT_DEBUG_REGISTRY=1 ./nutshellPackages are directories containing:
manifest.json: Package metadata[package-name].sh: Main executable script- Additional files as needed
Example manifest.json:
{
"name": "mypackage",
"version": "1.0.0",
"description": "My awesome package",
"author": "Your Name",
"dependencies": [],
"sha256": "checksum"
}Generate a checksum for your package with:
./scripts/generate_checksum.sh mypackagemake test # Run all tests
make test-pkg # Test package installation
make test-ai # Test AI integrationContributions are welcome! Please read the contributing guidelines before submitting a pull request.
nutshell/
βββ src/
β βββ core/
β β βββ shell.c # Main shell loop
β β βββ parser.c # Command parsing
β β βββ executor.c # Command execution
β βββ ai/
β β βββ openai.c # OpenAI integration
β β βββ local_ml.c # On-device ML
β βββ pkg/
β β βββ nutpkg.c # Package manager core
β β βββ registry.c # Package registry handling
β βββ utils/
β β βββ security.c # Security features
β β βββ autocomplete.c # Tab completion
β β βββ helpers.c # Utility functions
β βββ plugins/ # Loadable plugins
βββ include/
β βββ nutshell/
β β βββ core.h
β β βββ ai.h
β β βββ pkg.h
β β βββ utils.h
βββ lib/ # 3rd party libs
βββ scripts/ # Build/install scripts
βββ packages/ # Local package cache
βββ tests/ # Test suite
βββ Makefile
βββ README.md