ct (Command Trace) is a Bash command resolution tracer that explains how Bash resolves a command and what the kernel ultimately executes.
It traces the full resolution process—covering aliases, functions, keywords, builtins, and external executables—while exposing shadowed commands, overrides, and filesystem indirection.
ct combines and extends type, which, command -v, and file, providing visibility into Bash resolution order, $PATH shadowing, and kernel execution details.
-
Bash resolution order for aliases, functions, keywords, builtins, and executables
-
Shadowed commands and overrides (e.g. aliases or functions hiding binaries)
-
Full
$PATHscan, including shadowed or unreachable entries -
Clear separation of Bash resolution targets vs kernel execution targets
-
Filesystem execution details:
- Canonical executable paths
- Symlink chains (including
/etc/alternatives) - ELF interpreters for binaries
- Shebangs for scripts
-
Optional JSON output for scripting and automation
ct is intended for understanding why a command resolves the way it does—not just what it resolves to.
- Traces Bash command resolution for aliases, functions, keywords, builtins, and executables
- Shows Bash vs kernel execution targets
- Highlights shadowed commands and overrides
- Performs a full
$PATHscan, including shadowed or unreachable entries - Detects builtin state (enabled vs disabled)
- Resolves filesystem details: canonical paths, symlink chains,
/etc/alternatives, usr-merged directories, ELF interpreters, shebangs - Safely auto-extends
$PATHto include admin/system directories - Supports
-x/--extendfor manual path extension - Handles edge cases: reserved keywords, special characters
- Produces color-coded, human-readable output
- Optional JSON output for scripting and automation
- Supports tab completion
- Preserves shell environment state
- Compatible with gnu-utils and Bash ≥ 4.4
- Works in both interactive shells and scripts
JSON output is intended for scripting and inspection.
- Fields may be added in future versions
- Consumers should not assume strict schema stability across major versions
nullindicates “not applicable”- Boolean fields are always
trueorfalse
Each PATH entry reports:
- Directory
- State (
notfound,file,symlink) - Symlink target (if applicable)
- Shadowed status
/usr-merge detection
Core dependencies
grep,file,cut,head,readlink,readelf,awk
Optional (for color output)
tput
Bash version
- Bash ≥ 4.4
Clone the repository.
# Clone the repository.
git clone https://github.com/JB63134/bash_ca.git /usr/local/bin/bash_ct
# Source the main script in your .bashrc or .bash_profile
echo "source /usr/local/bin/bash_ct/.bash_ct" >> ~/.bashrc
# Apply changes immediately
source ~/.bashrcct [options] command
| Option | Description |
|---|---|
-h, --help |
Show usage information |
-v, --version |
Show version and license |
-j, --json |
Emit JSON output |
-x, --extend |
Extend $PATH manually |
ct ls
ct python
ct -j bashInvalid paths are rejected:
ct /bin/ls
ct ./script



