Enhanced wrapper for bat that adds wildcard support and flexible
encoding handling for viewing text files across platforms.
Supported entrypoints
vbat.cmd— Windows (CMD) launcher that forwards to PowerShellvbat.ps1— PowerShell script (Windows)vbat.sh— POSIX shell script (Linux/macOS)
Requirements
bat(shorthand pager) must be installed and available onPATH.- A cat(1) clone with wings. https://github.com/sharkdp/bat
Quick usage
- Windows (CMD):
vbat.cmd myfile.txt
- PowerShell:
. vbat.ps1 myfile.txt(or runvbat.cmdfrom CMD)
- Bash (Linux/macOS):
./vbat.sh myfile.txt
Options
--encoding=VALUEor-e VALUE— override encoding for files (e.g.UTF-8,CP949,EUC-KR).-hor--help— show usage help.
.encoding sidecar files
Each target text file may have a sidecar file named <filename>.encoding that contains a line like:
encoding=UTF8
The scripts will prefer an explicit --encoding argument, then a .encoding sidecar, and finally fall back to a sensible default (PowerShell/CMD variants default to CP949; the shell script defaults to UTF-8).
Examples
- View all
.txtfiles with default behavior:vbat.ps1 *.txt
- Force UTF-8 for a single file:
vbat.sh myfile.txt --encoding=UTF-8
- Use short flag:
vbat.cmd myfile.txt -e CP949
Notes
- The Windows
vbat.cmdis a tiny launcher that invokes PowerShell with the same logic asvbat.ps1. - The shell script uses
iconvto convert encodings before piping intobat. - If you see an "unsupported encoding" error, either install the required encoding support (platform-specific) or use a different encoding value.
Troubleshooting
- Ensure
batis on yourPATHand callable asbat. - On Windows, run PowerShell scripts according to your execution policy, or use
vbat.cmdto avoid changing policies.
See the individual scripts for full implementation details.