Skip to content
/ zut Public

Zut is a fast, simple, and effective CLI tool for storing, retrieving, and executing frequently used or complex shell commands.

License

Notifications You must be signed in to change notification settings

geekloper/zut

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

8 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸš€ Zut - Command Storage CLI

Zut is a fast, simple, and effective CLI tool for storing, retrieving, and executing frequently used or complex shell commands. Never forget that complicated command again!

✨ Features

  • Save Commands: Store commands with unique aliases and descriptive tags
  • Quick Retrieval: Instantly find and execute saved commands
  • Smart Search: Search commands by alias, tag, or command content
  • Easy Management: Edit and delete commands with simple commands
  • Fast & Lightweight: Built in Go for maximum performance
  • Persistent Storage: All commands saved in a simple JSON file

πŸ“¦ Installation

Build from Source

git clone <your-repo-url>
cd zut
go build -o zut .
sudo mv zut /usr/local/bin/  # Optional: Install globally

Download Binary

Download the latest release from the releases page and add it to your PATH.

πŸš€ Quick Start

Add a command

zut add -a "git-push-f" -c "git push --force-with-lease origin main" -t "Safe force push"

List all commands

zut list

Search for commands

zut find git
# or
zut list -s docker

Retrieve a command

zut run git-push-f
# Output: git push --force-with-lease origin main

Edit a command

zut edit git-push-f -c "git push --force" -t "Updated description"

Delete a command

zut delete git-push-f

πŸ“– Commands Reference

add - Add a new command

zut add -a <alias> -c <command> -t <tag>

Flags:

  • -a, --alias: Unique alias for the command (required)
  • -c, --command: The command to save (required)
  • -t, --tag: Optional tag/description

Example:

zut add -a "docker-clean" -c "docker system prune -af" -t "Clean up Docker"

list - List all saved commands

zut list [flags]

Flags:

  • -s, --search: Filter commands by search term

Example:

zut list
zut list -s "git"

find - Search for commands

zut find <search-term>

Example:

zut find docker
zut find "force push"

run - Retrieve a command

zut run <alias>

Example:

zut run git-push-f

edit - Edit an existing command

zut edit <alias> [flags]

Flags:

  • -c, --command: New command string
  • -t, --tag: New tag/description

Example:

zut edit git-push-f -c "git push --force"
zut edit git-push-f -t "New description"
zut edit git-push-f -c "new command" -t "new tag"

delete - Delete a command

zut delete <alias>

Example:

zut delete git-push-f

πŸ”§ Shell Integration

To execute commands directly in your shell, add this function to your shell configuration file:

Zsh (~/.zshrc)

zut-exec() {
    eval "$(zut run "$1")"
}

Bash (~/.bashrc)

zut-exec() {
    eval "$(zut run "$1")"
}

After adding the function and reloading your shell (source ~/.zshrc), you can execute commands directly:

zut-exec git-push-f
# This will execute: git push --force-with-lease origin main

πŸ“ Storage Location

Commands are stored in a JSON file at:

  • Linux/macOS: ~/.config/zut/commands.json
  • Windows: %APPDATA%/zut/commands.json

You can customize the storage location by setting the ZUT_CONFIG_DIR environment variable:

export ZUT_CONFIG_DIR="/path/to/custom/config"

🎯 Use Cases

Common Git Commands

zut add -a "git-undo" -c "git reset --soft HEAD~1" -t "Undo last commit"
zut add -a "git-clean-branches" -c "git branch | grep -v 'main' | xargs git branch -D" -t "Delete all local branches except main"

Docker Commands

zut add -a "docker-stop-all" -c "docker stop \$(docker ps -aq)" -t "Stop all containers"
zut add -a "docker-rm-all" -c "docker rm \$(docker ps -aq)" -t "Remove all containers"

System Administration

zut add -a "disk-usage" -c "du -sh * | sort -h" -t "Show disk usage sorted"
zut add -a "port-check" -c "netstat -tuln | grep" -t "Check which ports are listening"

Development

zut add -a "npm-fresh" -c "rm -rf node_modules package-lock.json && npm install" -t "Clean npm install"
zut add -a "go-test-v" -c "go test -v ./..." -t "Run all Go tests verbosely"

πŸ—οΈ Project Structure

zut/
β”œβ”€β”€ cmd/                    # CLI commands
β”‚   β”œβ”€β”€ root.go            # Root command
β”‚   β”œβ”€β”€ add.go             # Add command
β”‚   β”œβ”€β”€ list.go            # List command
β”‚   β”œβ”€β”€ delete.go          # Delete command
β”‚   β”œβ”€β”€ edit.go            # Edit command
β”‚   β”œβ”€β”€ run.go             # Run command
β”‚   └── find.go            # Find/search command
β”œβ”€β”€ internal/core/         # Core business logic
β”‚   └── core.go           # Command management
β”œβ”€β”€ pkg/storage/          # Data persistence
β”‚   └── storage.go        # File I/O operations
β”œβ”€β”€ main.go               # Entry point
β”œβ”€β”€ go.mod                # Go module file
└── README.md             # This file

πŸ§ͺ Testing

Run the test suite:

go test ./...

Run tests with coverage:

go test -cover ./...

🀝 Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

πŸ™ Acknowledgments

Built with:

  • Cobra - CLI framework
  • Go standard library

About

Zut is a fast, simple, and effective CLI tool for storing, retrieving, and executing frequently used or complex shell commands.

Resources

License

Contributing

Stars

Watchers

Forks

Packages

No packages published