Help or see manual with bat.
Add the following to your PowerShell $PROFILE, and try batman pip install.
<#
.SYNOPSIS
Help or see manual with bat
.NOTES
[bat](https://github.com/sharkdp/bat) should be installed and on your `$env:Path`.
.LINK
https://gist.github.com/YDX-2147483647/7059a181236fab93b0d8430b98699868
.EXAMPLE
batman Get-Command
.EXAMPLE
batman pip
.EXAMPLE
batman pip install
#>
function batman {
$command = "$Args"; # as a string
$is_pwsh_thing = $false;
if ($Args.Length -eq 1) {
switch (Get-Command $command) {
{ $_.CommandType -in @('Cmdlet', 'Function') } { $is_pwsh_thing = $true }
{ $_.CommandType -eq 'Alias' } {
$is_pwsh_thing = (Get-Command ($_.ResolvedCommand)).CommandType -in @('Cmdlet', 'Function') ;
}
Default {}
}
}
if ($is_pwsh_thing) {
help $command -Full | bat -l man
}
else {
Invoke-Expression "$command --help" | bat -l man
}
}To install bat, please check its documentation.
# On Windows
> scoop install less batFor bash, batman.sh is better.
- Simple: no magic.
- Compatible:
Get-Helpfor PowerShell things, and--helpfor external scripts/binaries. - Better paging: move back, search, syntax highlighting. (compared to
Out-Host -Pagingandmore.com)
For aliases referenced to an application not on $env:Path and circular aliases, batman works as expected but throws redundant exceptions.