A CLI tool for managing commands like bookmarks
Project description
cmdmark
A CLI tool for managing commands like bookmarks. This Python script provides a simple way to manage and execute frequently used commands via YAML configuration files. Think of it like a bookmark manager, but for your terminal commands.
Features
- Categorized Commands: Organize your commands into categories stored in subfolders.
- YAML Configuration: Define commands and their descriptions in easy-to-read YAML files.
- Interactive Selection: Choose categories, files, and commands interactively from the terminal.
- Direct Execution: Execute selected commands directly within the script.
- Git-Aware: Git metadata files (e.g.,
.gitfolders) are ignored when listing categories and YAML files. - Verbose Mode: Pass
-vto show each command's description when listing commands.
Setup
-
Installation:
The preferred way to install
cmdmarkis via pipx (recommended) or pip:pipx install cmdmark # recommended way. # OR pip install cmdmark
This will install
cmdmarkand its dependency,PyYAML. This project requires Python 3.12 or higher. -
Configuration Directory: The script uses a configuration directory located at
~/.command_bookmarks. Make sure that the directory exists. You may create some sub-directories in~/.command_bookmarksto categorize your commands, and create yml files to store the relative commands. You can override this location by setting the environment variableCMDMARK_CONFIG_DIR.For example, in your shell configuration (e.g.
~/.bashrcor~/.zshrc):export CMDMARK_CONFIG_DIR="$HOME/my_cmdmarks"
-
YAML Files: Create YAML files within the configuration directory (or its subdirectories) to define your commands. The structure of the YAML file is as follows:
commands: alias1: command: "your_command_here" description: "A short description of the command" alias2: command: "another_command" description: "Another description"
commands: The top-level key.alias1,alias2, etc.: Short, user-friendly aliases for your commands. These are displayed in the selection menu.command: The actual command to be executed.description: (Optional) A brief description of the command.
Usage
-
Run the script:
cmdmark
Use
-vor--verboseto also show each command's description when listing commands. -
Interactive Navigation:
- The script will first list the available categories (subfolders) within
~/.command_bookmarks. - Select a category by entering its number.
- The script will then list the YAML files within the selected category.
- Select a YAML file by entering its number.
- Finally, the script will list the commands defined in the selected YAML file. When
-vis used, each command's description is shown alongside the command itself. - Select a command by entering its number.
- The script will first list the available categories (subfolders) within
-
Command Execution: The selected command will be executed in your terminal.
Example
Let's say you have the following structure (see tests/samples). For example, the directory might look like:
~/.command_bookmarks/
├── git/
│ ├── basic.yml
│ └── branch.yml
└── sys/
└── disk.yml
The files under tests/sample/ provide ready-made examples you can copy into your configuration directory.
tests/sample/git/basic.yml includes common git commands:
commands:
status:
command: "git status"
description: "Show the working tree status"
add_all:
command: "git add ."
description: "Add all changes to staging"
commit:
command: "git commit -m"
description: "Commit changes (requires message)"
tests/sample/sys/disk.yml defines a couple of useful system commands:
commands:
check_disk:
command: "df -h"
description: "Check disk space usage"
disk_usage:
command: "du -sh ~"
description: "Show disk usage of home directory"
Quick demo
cp -r tests/sample/* ~/.command_bookmarks/
cmdmark
Select a category (e.g. git), choose a YAML file such as basic.yml, and then pick a command like status. cmdmark will run git status right away.
Docker
The repository includes a Dockerfile so you can build a containerized
environment for running the tests or invoking the CLI.
# Build the image
docker build -t cmdmark .
# Run the test suite
docker run --rm cmdmark
# Or start the CLI (override the default command)
docker run --rm -it cmdmark cmdmark
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file cmdmark-0.0.6.tar.gz.
File metadata
- Download URL: cmdmark-0.0.6.tar.gz
- Upload date:
- Size: 4.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
da387af596ac0095b3dec85acc33a83b4da0da16ef44f3182bf05f2e13c0adbd
|
|
| MD5 |
2709eb51d718c2c6124f6e93b091325a
|
|
| BLAKE2b-256 |
d5a45778715eda9bdc823c1aa87a0be04058fc4ab81704f33827c5cfbccab4f1
|
File details
Details for the file cmdmark-0.0.6-py3-none-any.whl.
File metadata
- Download URL: cmdmark-0.0.6-py3-none-any.whl
- Upload date:
- Size: 5.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c7c6b6cf2b389f27362361a0c67be0302602c9f224cec055ff6469ef3afc260e
|
|
| MD5 |
5f290f4b0a2aacac3048e76d8af5e9fc
|
|
| BLAKE2b-256 |
1a1a7cdd9f6a9b09404f46af826a9a97ff935b5126c6b4530d679153f1dd634e
|