Skip to content

ryan258/alias-scanner

Repository files navigation

Alias Scanner

A Go CLI tool that scans shell alias files for potential issues including:

  • Shadowed system commands: Aliases that override existing system commands
  • Duplicate definitions: Multiple definitions of the same alias name
  • Unused aliases: Aliases that are never used (requires shell history analysis)

The repo also includes a small Node CLI wrapper so it can be published as an npm package and run with npx for one-off scans.

Installation

go install github.com/ryan258/alias-scanner@latest

Or build from source:

git clone https://github.com/ryan258/alias-scanner.git
cd alias-scanner
go build -o alias-scanner

Quick Run With npx

Once this repo is published to npm, you can run it without a persistent install:

npx alias-scanner scan

Or point it at a specific file:

npx alias-scanner scan -f /path/to/aliases -v

Usage

Basic usage

Scan the default alias file (~/.bash_aliases):

./alias-scanner scan

Specify a custom alias file

./alias-scanner scan -f /path/to/aliases

Verbose output

./alias-scanner scan -v

Example Output

Found 3 issues:
  [SHADOW] Line 5: alias 'grep' - shadows system command 'grep'
  [DUPLICATE] Line 12: alias 'll' - defined 2 times
  [INFO] Note: Unused alias detection requires shell history analysis (not implemented)

Features

  • Parses standard shell alias syntax (alias name='command')
  • Detects aliases that shadow system commands in PATH
  • Identifies duplicate alias definitions
  • Verbose mode for additional information
  • Cross-platform support (works on any system with Go)

Limitations

  • Unused alias detection requires shell history analysis (not implemented)
  • Only supports basic alias syntax (no functions or complex quoting)
  • Assumes standard shell alias file format

Development

Running tests

go test ./...
npm test

Building

go build
npm pack

License

MIT

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors