Actions Status

NAME

chot - Command Heuristic Omni-Tracer

VERSION

Version 1.04

SYNOPSIS

  chot [options] command/library

OPTIONS
   -1   --one           Stop at the first match
   -d   --debug         Show debug output
   -i   --info          Show command trace info
   -n   --dryrun        Show command without executing
   -h   --help          Print this message
   -l   --list          Print file path (-ll for ls -l)
   -L   --deref         Dereference symlinks (with -ll)
   -m   --man           Show documentation
   -N   --[no-]number   Line number display (default: off)
   -r   --raw           Don't resolve symlinks/wrappers
   -v   --version       Print version
   -C   --column[=#]    Use nup for multi-column display
   -p   --pager=#       Specify pager command
   -t   --type=#        Specify handler (Command:Perl:Python:Ruby:Node)
        --py            Shortcut for --type Python
        --pl            Shortcut for --type Perl
        --rb            Shortcut for --type Ruby
        --nd            Shortcut for --type Node
        --bat-theme     Set bat theme per mode (light=X dark=X)

EXAMPLES
  chot greple              # Look at a script command
  chot Getopt::Long        # Look at a Perl module
  chot --py json           # Look at a Python module
  chot --rb json           # Look at a Ruby library
  chot --nd express        # Look at a Node.js module
  chot -l greple           # Show file path only
  chot --py -m json        # Show documentation

DESCRIPTION

chot is a utility to locate and display command or library source files.

It is convenient to see a command file written in shell or any other script language.

For library files, Perl modules are fully supported, and support for Python, Ruby, and Node.js libraries is included.

The program searches through all file type handlers (Command, Perl, Python, Ruby, Node by default) and displays all matches found using a pager.

For Homebrew-installed commands, both the wrapper script in bin/ and the actual executable (typically in libexec/) are displayed. This is useful for understanding how wrapper scripts delegate to their implementations.

For optex commands (symlinks in ~/.optex.d/bin/ pointing to the optex binary), the actual command is resolved by searching $PATH. If an alias is defined in ~/.optex.d/config.toml, the alias target is followed. Configuration files (~/.optex.d/NAME.rc) are also included in the results. Use -i to see the full resolution chain including alias definitions.

TRACING MECHANISM

chot traces commands and libraries through multiple layers of indirection to find the actual source files.

Command Tracing

The Command handler resolves commands through the following pipeline:

PATH search → optex resolution → pyenv shim resolution → Homebrew wrapper resolution

Python Module Tracing

The Python handler performs additional resolution to locate meaningful source files:

Examples

For a Homebrew-installed Python command pandoc-embedz:

$ chot -l pandoc-embedz
/opt/homebrew/bin/pandoc-embedz               # Homebrew wrapper
.../libexec/venv/bin/pandoc-embedz            # venv entry point
.../pandoc_embedz/__init__.py                 # package init
.../pandoc_embedz/main.py                     # main source

For a pyenv-installed Python command:

$ chot -l gpty
/Users/you/.pyenv/shims/gpty                  # pyenv shim
/Users/you/.pyenv/versions/.../bin/gpty       # actual entry point
.../gpty/gpty.py                              # main source

OPTIONS

HANDLER MODULES

The program uses a plugin architecture where different file type handlers are dynamically loaded based on the --type option. Each handler must implement a get_path($app, $name) method.

EXAMPLES

# Display a script command (brew is a shell script)
chot brew

# Display a Perl module
chot List::Util

# Display a Python module
chot --py json

# Just show the file path
chot -l brew

# Show detailed file information
chot -ll Getopt::Long

# Show documentation (perldoc for Perl, pydoc for Python, ri for Ruby, etc.)
chot -m List::Util
chot --py -m json
chot --rb -m json
chot -m ls

# Only search for Perl modules
chot --pl Data::Dumper

# Only search for Python modules
chot --py os.path

# Display a Ruby library
chot --rb yaml

# Display a Node.js module
chot --nd express

# Trace a Homebrew venv Python command
chot -l pandoc-embedz

# Show documentation with fallback (man → pydoc)
chot -m speedtest-z

# Multi-column display using nup
chot -C greple
chot -C2 greple

# Use a custom pager
chot --pager "vim -R" List::Util

# Pass options to the pager (use -- to separate)
chot -- +10 List::Util  # Open at line 10

INSTALLATION

# Homebrew
brew tap tecolicom/tap
brew install app-chot

# From CPAN
cpanm App::chot

# From GitHub
cpanm https://github.com/tecolicom/App-chot.git

ENVIRONMENT

BUGS

When inspecting itself with chot chot, the display order of the wrapper script and the actual executable may be reversed. This is because the wrapper adds libexec/bin to $PATH, causing the raw executable to be found before the wrapper during path search.

SEE ALSO

App::chot, App::optex, Getopt::EX, Getopt::EX::Hashed

AUTHOR

Kazumasa Utashiro

LICENSE

Copyright 2021-2026 Kazumasa Utashiro.

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.