This project provides a unified system for managing, organizing, and executing complex shell commands. Instead of maintaining a messy .bashrc or remembering obscure command flags, you define your commands once in a structured YAML file.
This "Source of Truth" drives two interfaces:
- Interactive Menu (
commander.py): A visual, scrollable terminal window to browse commands, input arguments (with defaults/dropdowns), and execute them immediately. - Native Shell Aliases (
generate_alias_file.py): A generator that converts your YAML config into a standard.bash_aliasesfile for native shell usage.
This is the master configuration file. It contains command categories, descriptions, the actual shell commands, and structured arguments.
Features:
- Categories: Organize commands (e.g., "Networking", "Docker").
- Arguments: Define inputs (
$1,$2) with optional defaults and distinct choice lists. - Documentation: Every command has a description that appears in the menu.
An optional configuration file for your personal commands that won't be tracked in version control. This file follows the same format as commands.yaml.
How it works:
- Commands from
custom.yamlare automatically merged withcommands.yamlat runtime. - If a category exists in both files, the commands are combined.
- If a category only exists in
custom.yaml, it's added as a new category. - The file is already added to
.gitignore, so your personal commands stay private.
Example custom.yaml:
Personal:
- name: myserver
cmd: "ssh user@myserver.com"
desc: "Connect to my server"
Network Stuff:
- name: ping_home
cmd: "ping 192.168.1.100"
desc: "Ping my home server"In this example, "Personal" would be a new category, while "ping_home" would be added to the existing "Network Stuff" category.
A Python script utilizing simple-term-menu to create a "window-like" experience inside the terminal.
Key Functions:
- Category Navigation: Browse commands by group.
- Dynamic Prompts: Detects if a command needs arguments.
- If
choicesare defined: Opens a sub-menu to pick an option. - If
defaultis defined: Pre-fills the prompt (press Enter to accept). - If neither: Forces the user to type input.
- If
- Clean Output: Uses ANSI escape codes to erase prompts after entry, keeping the terminal history clean.
A utility script that parses commands.yaml and exports a standard Bash alias file.
Operation:
- Converts
type: functionentries into Bash functions (name() { ... }). - Converts simple commands into Bash aliases (
alias name='...'). - Embeds descriptions as comments in the generated file.
The system relies on a specific YAML structure.
System:
- name: updates
cmd: "sudo apt update && sudo apt upgrade -y"
desc: "Update system packages"Use $1, $2, etc., in the cmd string to mark where arguments go.
Networking:
- name: ping_host
cmd: "ping -c $1 $2"
desc: "Ping a remote host"
args:
- name: "Count"
default: 3 # Pressing Enter uses "3"
- name: "Target" # No default; user must type inputIf you provide choices, the menu will force the user to pick from a list.
Docker:
- name: container_log
cmd: "docker logs $1"
desc: "View logs for a specific container"
args:
- name: "Container"
choices: ["web_app", "db_server", "redis_cache"]This project requires Python 3 and the following libraries:
pip install pyyaml simple-term-menuNote: simple-term-menu supports Linux and macOS only.
To launch the interactive window:
python commander.pyYou can also run commands directly without the menu:
# Run a command by name (will prompt for any required arguments)
python commander.py ipaddr
# Provide all arguments on the command line (no prompts)
python commander.py ping google.com
# Provide some arguments (will prompt for missing ones)
python commander.py ddcopy /dev/sda1
# (will then prompt for "Output File")Add the -c or --continuous flag to stay in interactive mode after command execution:
# Interactive menu with continuous mode
python commander.py -c
# Direct command with continuous mode
python commander.py -c ping 8.8.8.8Command Line Syntax:
python commander.py [-c] [command_name] [arg1] [arg2] ...Enable tab completion for command names to speed up command execution:
python commander.py --generate-completionThis creates ~/.commander-completion.bash in your home directory. The script includes all commands from both commands.yaml and custom.yaml.
Add this line to your ~/.bashrc:
source ~/.commander-completion.bashThen reload your bash configuration:
source ~/.bashrcNow you can use tab completion:
python commander.py pi<TAB>
# Auto-completes to: python commander.py ping
python commander.py ip<TAB>
# Shows: ipaddr iplink iproute ipshowWhen you add new commands to commands.yaml or custom.yaml, regenerate the completion script:
python commander.py --generate-completionThen reload it in your current shell (or just open a new terminal):
source ~/.commander-completion.bashGenerate a traditional bash aliases file from your commands:
python commander.py --generate-aliasesThis creates ~/.bash_aliascore in your home directory with all commands from both commands.yaml and custom.yaml. Commands with arguments ($1, $2, etc.) are created as bash functions, while simple commands become aliases.
Add this line to your ~/.bashrc:
source ~/.bash_aliascoreThen reload:
source ~/.bashrcNow you can use the commands directly in your shell:
ll # Lists files
ping google.com # Pings GoogleWhen you add new commands, regenerate:
python commander.py --generate-aliases
source ~/.bash_aliascore # or open a new terminalTo generate both completion and aliases in one command:
python commander.py --generate-allThis will create both ~/.commander-completion.bash and ~/.bash_aliascore.
One-time setup: Add both to your ~/.bashrc:
source ~/.commander-completion.bash
source ~/.bash_aliascoreCommander commands use various system tools and utilities. Package dependencies are managed through packages.yaml.
To install required packages:
- Run the installation script:
python install_packages.py
# or
./install_packages.py- The script will:
- Scan
commands.yamlandcustom.yamlto find which commands are used - Check which packages are already installed
- Show what needs to be installed and ask for confirmation
- Install apt packages automatically
- Provide instructions for custom/manual installations
- Scan
Package Configuration (packages.yaml):
This file maps command names to their installation packages. You can edit it to add new mappings or change installation methods.
Example structure:
commands:
exa:
package: exa
method: apt
youtube-dl:
package: yt-dlp
method: custom
commands:
- "sudo curl -L https://github.com/yt-dlp/yt-dlp/releases/latest/download/yt-dlp -o /usr/local/bin/yt-dlp"
- "sudo chmod a+rx /usr/local/bin/yt-dlp"
notes: "Replaces deprecated youtube-dl"
pet:
package: pet
method: manual
url: "https://github.com/knqyf263/pet"
notes: "Manual installation required"Installation methods:
apt: Installed via apt-getcustom: Executed via custom shell commandsmanual: Requires manual installation (instructions provided)
[ commands.yaml ] <-- YOU EDIT THIS
Terminal Menu |
| v
Executes Cmds Native Shell
Directly (alias name=...)