Skip to main content

One stop shop for command line help.

Project description

Halp

Changelog PyPI version PyPI - Python Version Tests codecov

Halp is a command line tool that reminds you how to use your custom shell commands. It finds aliases and functions from your dotfiles and indexes them so you can query them later. Simply type halp <command> to see what it does or halp --list to see all your custom commands.

Point Halp at the appropriate dotfiles and it will index all your custom commands and add them to categories you specify. Then you can query it to find your commands and their usage.

Key features:

  • Understands your aliases, functions, and exported environment variables
  • Customizable categories
  • Uses your inline comments to describe your commands
  • Customizable regexes for matching commands
  • SQLite database used for fast querying
  • Explains builtin commands with TLDR pages
  • Explains builtin commands with options from mankier.com

Note: To enable TLDR integration, you must have a TLDR client installed and in your PATH. I recommend TealDeer

Usage

Remind yourself what a command does (Your own aliases and functions or TLDR pages)

halp <command>

See full output of a command

halp --full <command>

List all your custom commands

halp --list

View all commands in a particular category

halp --category <category>

Index your dotfiles

halp --index

Hide commands that you don't want to see

halp --hide <command ID>,<command ID>,...

Customize the description of a command

halp --description <command ID>

Edit the configuration file

halp --edit-config

Search for commands who's code matches a regex pattern

halp --search-code <regex pattern>

See all options

halp --help

Installation

Note: Halp requires Python 3.10 or higher.

Install with pipx

pipx install halper

If pipx is not an option, you can install Halp in your Python user directory.

python -m pip install --user halper

First run

Before you can use Halp, you must first

  1. Create a configuration file by running `halp --edit-config``.
  2. Index your commands. You can do this by running `halp --index``.

File locations

Halp uses the XDG specification for determining the locations of configuration files, logs, and caches.

  • Configuration file: ~/.config/halp/config.toml
  • Database: ~/.local/share/halp/halp.sqlite

Known issues

  • Does not associate comments with a command on the following line
  • If your function is written with parentheses instead of curly braces, it will not be parsed. ie func command() (some code)
  • Does not resolve if statements. ie if [ -n "$BASH_VERSION" ]; then. Consequently, if a command is wrapped in an if statement, it will still be indexed. Use --hide to hide unwanted commands.
  • Does not follow source or . directives within files
  • Tested on Bash and ZSH files only. Dotfiles for other shells may not work as expected.

Configuration

On first run, a TOML configuration file will be created for you.

IMPORTANT: You must add at least one path to the file_globs list and then run halp --index. Otherwise, no commands will be indexed.

case_sensitive            = false           # Whether or not to match case sensitively with regexes
command_name_ignore_regex = ''              # Exclude commands who's names match this regex
comment_placement         = "BEST"          # Where you place comments to describe your code. One of "BEST", "ABOVE", "INLINE"
file_exclude_regex        = ''              # Exclude files who's paths match this regex
file_globs                = []              # Absolute path globs to files to parse for commands
uncategorized_name        = "uncategorized" # The name of the uncategorized category

[categories] # Commands are matched against these categories
    [categories.example]
        name = "" # The name of the category
        code_regex    = '' # Regex to match within the code
        comment_regex = '' # Regex to match a comment on the same line as an alias/function definition or a comment on the first line of a function
        description   = "" # The description of this category
        command_name_regex    = '' # Regex to match the name of the command
        path_regex    = '' # Regex to match the path of the file

How halp finds descriptions for commands

The comment_placement setting determines where Halp looks for comments to describe your commands. It can be one of the following: BEST (default), ABOVE, INLINE. When BEST is used, Halp will look for comments in both places and use the inline comment when both are found.

Here's how Halp looks for comments in each case:

# Description                            <------ Above
alias command='some code' # Description  <------ Inline

# Description                            <------ Above
func command() {
    # Description                        <------ Inline
    some code
}

Contributing

Setup: Once per project

  1. Install Python >=3.11 and uv
  2. Clone this repository. git clone https://github.com/natelandau/halp
  3. Install the virtual environment with uv sync.
  4. Activate your virtual environment with source .venv/bin/activate
  5. Install the pre-commit hooks with pre-commit install --install-hooks.

Developing

  • This project follows the Conventional Commits standard to automate Semantic Versioning and Keep A Changelog with Commitizen.
    • When you're ready to commit changes run cz c
  • Run poe from within the development environment to print a list of Poe the Poet tasks available to run on this project. Common commands:
    • poe lint runs all linters
    • poe test runs all tests with Pytest
  • Run uv add {package} from within the development environment to install a run time dependency and add it to pyproject.toml and uv.lock.
  • Run uv remove {package} from within the development environment to uninstall a run time dependency and remove it from pyproject.toml and uv.lock.
  • Run poe upgrade from within the development environment to upgrade all dependencies to the latest versions allowed by pyproject.toml.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

halper-1.1.1.tar.gz (104.4 kB view details)

Uploaded Source

Built Distribution

halper-1.1.1-py3-none-any.whl (57.5 kB view details)

Uploaded Python 3

File details

Details for the file halper-1.1.1.tar.gz.

File metadata

  • Download URL: halper-1.1.1.tar.gz
  • Upload date:
  • Size: 104.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.11.10

File hashes

Hashes for halper-1.1.1.tar.gz
Algorithm Hash digest
SHA256 5c1565ae6bb479eb8b53db6c2caccbea07b0b8d9272fa0708ef9f3370bc227f4
MD5 ec68c29aed2e8935b11e5340b838d79b
BLAKE2b-256 cf39a3ae0c44f246dce77999a9bf8a1ef9cc18ded9297108b8d1810694a3da3c

See more details on using hashes here.

File details

Details for the file halper-1.1.1-py3-none-any.whl.

File metadata

  • Download URL: halper-1.1.1-py3-none-any.whl
  • Upload date:
  • Size: 57.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.11.10

File hashes

Hashes for halper-1.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 e7ee8dad1ed68148ac85420631d1b52e18b3a2ca8d98d6fdddb66ad04959fb35
MD5 6916d217fd40a20d0de50992ef6ee253
BLAKE2b-256 449aa16432326b061d0587805b47442eb5e0b6020816e94af76be35acf86812a

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page