Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@ninmonkey
Last active December 6, 2021 14:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ninmonkey/a1f51fd73dec718ec836743a66123d72 to your computer and use it in GitHub Desktop.
Save ninmonkey/a1f51fd73dec718ec836743a66123d72 to your computer and use it in GitHub Desktop.
pwsh-psit-config.md
function Find-PagerEnvVars {
<#
.synopsis
find common pager related vars
#>
ls env: | ? Key -match 'less|pager|bat|wsl|term|local'
}
function viewHelpPager {
<#
.synopsis
view the source code to 'help', which sets up a bunch of env vars for get-help
#>
gi function:\help | % ScriptBlock
| bat -l ps1
}
# get pagers
$lessChoco = gcm less -All | ? Source -match ('chocolatey') # C:\ProgramData\chocolatey\bin\less.exe
$lessGit = gcm less -All | ? Source -match '\\git\\' # C:\Program Files\Git\usr\bin\less.exe
$bat = gcm bat
$lessChoco, $lessGit, $bat
/*
If you can't paste multi-lines without it running them individually,
this config fixes that */
/* this bind/hotkey is what breaks multiline pasting */
{
"key": "ctrl+v",
"command": "-workbench.action.terminal.paste",
"when": "terminalFocus && terminalHasBeenCreated || terminalFocus && terminalProcessSupported"
},
  • πŸ”΄ Pipe PSIT -> bat -> less
πŸ’>gcm help | % ScriptBlock
| bat -l ps1 --force-colorization | less -R
k v
$lessChoco C:\ProgramData\chocolatey\bin\less.exe
$lessGig C:\Program Files\Git\usr\bin\less.exe
# get pagers
$lessChoco = gcm less -All | ? Source -match ('chocolatey')  # C:\ProgramData\chocolatey\bin\less.exe
$lessGit = gcm less -All | ? Source -match '\\git\\'   # C:\Program Files\Git\usr\bin\less.exe
$bat = gcm bat 
$lessChoco, $lessGit, $bat

& $lessGit --help -R    # no color
& $lessChoco --help -R  # color

....
Get-Error | & $lessGit -R # no
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment