Skip to content

Instantly share code, notes, and snippets.

@souhaiebtar
Created January 31, 2026 10:37
Show Gist options
  • Select an option

  • Save souhaiebtar/04f25b43f1802671be447ec9793589c9 to your computer and use it in GitHub Desktop.

Select an option

Save souhaiebtar/04f25b43f1802671be447ec9793589c9 to your computer and use it in GitHub Desktop.
[powershell profile wrk cpnfig] powershell profile wrk config d31m1y2026 #powershell #windows
# fnm completion related
using namespace System.Management.Automation
using namespace System.Management.Automation.Language
# end fnm completion related
# Import modules
Import-Module Terminal-Icons
Import-Module PSReadLine
Import-Module posh-git
Import-Module posh-sshell
# Start SSH agent
# Start-SshAgent
# PSReadLine base configuration
Set-PSReadLineOption -PredictionSource History
Set-PSReadLineOption -EditMode Windows
# Handle prediction view style based on environment
# Prevent the warning by choosing the appropriate view style
function Set-AppropriateViewStyle {
# Check if we're in VSCode
$inVSCode = $env:TERM_PROGRAM -eq "vscode"
# Check console window size
$windowWidth = $Host.UI.RawUI.WindowSize.Width
$windowHeight = $Host.UI.RawUI.WindowSize.Height
$hasSufficientSize = ($windowWidth -ge 54) -and ($windowHeight -ge 15)
# Use InlineView if in VSCode or if window is too small
if ($inVSCode -or -not $hasSufficientSize) {
Set-PSReadLineOption -PredictionViewStyle InlineView
} else {
Set-PSReadLineOption -PredictionViewStyle ListView
}
}
function touch {
param([string]$Path)
if (Test-Path $Path) {
(Get-Item $Path).LastWriteTime = Get-Date
} else {
New-Item $Path -ItemType File | Out-Null
}
}
# Apply the appropriate view style
Set-AppropriateViewStyle
# Configure FZF key bindings
Set-PsFzfOption -PSReadlineChordProvider 'Ctrl+t' -PSReadlineChordReverseHistory 'Ctrl+r'
# Custom functions
function fact {
irm -Uri https://uselessfacts.jsph.pl/random.json?language=en | Select -ExpandProperty text
}
function joke {
irm https://icanhazdadjoke.com/ -Headers @{accept = 'application/json'} | select -ExpandProperty joke
}
function toggleAutoHide {
$location = @{Path = 'HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\StuckRects3'; Name = 'Settings'}
$value = Get-ItemPropertyValue @location
$value[8] = if ($value[8] -Eq 122) {123} Else {122}
Set-ItemProperty @location $value
Stop-Process -Name Explorer
}
function searchfile {
param (
[Parameter()]
[Alias('filename')]
[string]
$file
)
Get-ChildItem -Path . -Include $file -Recurse -File | Select-Object FullName | Out-String | Write-Host
}
function 2C {
param (
[Parameter()]
[Alias('Temp')]
[int]
$Temperature
)
($Temperature - 30) / 2
}
function git-remove-all {
git reset --hard HEAD^
git clean -df
}
function 2F {
param (
[Parameter()]
[Alias('Temp')]
[int]
$Temperature
)
($Temperature * 2) + 30
}
# function update {
# iex "& { $(irm https://aka.ms/install-powershell.ps1) } -UseMSI"
# }
function profile {
code $profile
}
function scoopBucketList {
gci "~/scoop/buckets/$($args[0])/bucket" |% { echo "$($_.BaseName)" }
}
function textHash256($tohash) {
[System.BitConverter]::ToString([System.Security.Cryptography.SHA256]::Create().ComputeHash([System.Text.Encoding]::UTF8.GetBytes($tohash))).Replace("-","").ToLower()
}
# Aliases
Set-Alias -Name which -Value Get-Command
Set-Alias -Name open -Value explorer
Set-Alias -Name clip -Value Set-Clipboard
Set-Alias -Name vim -Value nvim
# PowerToys CommandNotFound module (commented out)
#f45873b3-b655-43a6-b217-97c00aa0db58 PowerToys CommandNotFound module
# Import-Module -Name Microsoft.WinGet.CommandNotFound
#f45873b3-b655-43a6-b217-97c00aa0db58
# fnm configuration
fnm env --use-on-cd --shell powershell | Out-String | Invoke-Expression
# fnm completion start
Register-ArgumentCompleter -Native -CommandName 'fnm' -ScriptBlock {
param($wordToComplete, $commandAst, $cursorPosition)
$commandElements = $commandAst.CommandElements
$command = @(
'fnm'
for ($i = 1; $i -lt $commandElements.Count; $i++) {
$element = $commandElements[$i]
if ($element -isnot [StringConstantExpressionAst] -or
$element.StringConstantType -ne [StringConstantType]::BareWord -or
$element.Value.StartsWith('-') -or
$element.Value -eq $wordToComplete) {
break
}
$element.Value
}) -join ';'
$completions = @(switch ($command) {
'fnm' {
[CompletionResult]::new('--node-dist-mirror', '--node-dist-mirror', [CompletionResultType]::ParameterName, '<https://nodejs.org/dist/> mirror')
[CompletionResult]::new('--fnm-dir', '--fnm-dir', [CompletionResultType]::ParameterName, 'The root directory of fnm installations')
[CompletionResult]::new('--multishell-path', '--multishell-path', [CompletionResultType]::ParameterName, 'Where the current node version link is stored. This value will be populated automatically by evaluating `fnm env` in your shell profile. Read more about it using `fnm help env`')
[CompletionResult]::new('--log-level', '--log-level', [CompletionResultType]::ParameterName, 'The log level of fnm commands')
[CompletionResult]::new('--arch', '--arch', [CompletionResultType]::ParameterName, 'Override the architecture of the installed Node binary. Defaults to arch of fnm binary')
[CompletionResult]::new('--version-file-strategy', '--version-file-strategy', [CompletionResultType]::ParameterName, 'A strategy for how to resolve the Node version. Used whenever `fnm use` or `fnm install` is called without a version, or when `--use-on-cd` is configured on evaluation')
[CompletionResult]::new('--resolve-engines', '--resolve-engines', [CompletionResultType]::ParameterName, 'Resolve `engines.node` field in `package.json` whenever a `.node-version` or `.nvmrc` file is not present. This feature is enabled by default. To disable it, provide `--resolve-engines=false`.')
[CompletionResult]::new('--corepack-enabled', '--corepack-enabled', [CompletionResultType]::ParameterName, 'Enable corepack support for each new installation. This will make fnm call `corepack enable` on every Node.js installation. For more information about corepack see <https://nodejs.org/api/corepack.html>')
[CompletionResult]::new('-h', '-h', [CompletionResultType]::ParameterName, 'Print help (see more with ''--help'')')
[CompletionResult]::new('--help', '--help', [CompletionResultType]::ParameterName, 'Print help (see more with ''--help'')')
[CompletionResult]::new('-V', '-V ', [CompletionResultType]::ParameterName, 'Print version')
[CompletionResult]::new('--version', '--version', [CompletionResultType]::ParameterName, 'Print version')
[CompletionResult]::new('list-remote', 'list-remote', [CompletionResultType]::ParameterValue, 'List all remote Node.js versions')
[CompletionResult]::new('ls-remote', 'ls-remote', [CompletionResultType]::ParameterValue, 'List all remote Node.js versions')
[CompletionResult]::new('list', 'list', [CompletionResultType]::ParameterValue, 'List all locally installed Node.js versions')
[CompletionResult]::new('ls', 'ls', [CompletionResultType]::ParameterValue, 'List all locally installed Node.js versions')
[CompletionResult]::new('install', 'install', [CompletionResultType]::ParameterValue, 'Install a new Node.js version')
[CompletionResult]::new('i', 'i', [CompletionResultType]::ParameterValue, 'Install a new Node.js version')
[CompletionResult]::new('use', 'use', [CompletionResultType]::ParameterValue, 'Change Node.js version')
[CompletionResult]::new('env', 'env', [CompletionResultType]::ParameterValue, 'Print and set up required environment variables for fnm')
[CompletionResult]::new('completions', 'completions', [CompletionResultType]::ParameterValue, 'Print shell completions to stdout')
[CompletionResult]::new('alias', 'alias', [CompletionResultType]::ParameterValue, 'Alias a version to a common name')
[CompletionResult]::new('unalias', 'unalias', [CompletionResultType]::ParameterValue, 'Remove an alias definition')
[CompletionResult]::new('default', 'default', [CompletionResultType]::ParameterValue, 'Set a version as the default version')
[CompletionResult]::new('current', 'current', [CompletionResultType]::ParameterValue, 'Print the current Node.js version')
[CompletionResult]::new('exec', 'exec', [CompletionResultType]::ParameterValue, 'Run a command within fnm context')
[CompletionResult]::new('uninstall', 'uninstall', [CompletionResultType]::ParameterValue, 'Uninstall a Node.js version')
[CompletionResult]::new('uni', 'uni', [CompletionResultType]::ParameterValue, 'Uninstall a Node.js version')
[CompletionResult]::new('help', 'help', [CompletionResultType]::ParameterValue, 'Print this message or the help of the given subcommand(s)')
break
}
'fnm;list-remote' {
[CompletionResult]::new('--filter', '--filter', [CompletionResultType]::ParameterName, 'Filter versions by a user-defined version or a semver range')
[CompletionResult]::new('--lts', '--lts', [CompletionResultType]::ParameterName, 'Show only LTS versions (optionally filter by LTS codename)')
[CompletionResult]::new('--sort', '--sort', [CompletionResultType]::ParameterName, 'Version sorting order')
[CompletionResult]::new('--node-dist-mirror', '--node-dist-mirror', [CompletionResultType]::ParameterName, '<https://nodejs.org/dist/> mirror')
[CompletionResult]::new('--fnm-dir', '--fnm-dir', [CompletionResultType]::ParameterName, 'The root directory of fnm installations')
[CompletionResult]::new('--log-level', '--log-level', [CompletionResultType]::ParameterName, 'The log level of fnm commands')
[CompletionResult]::new('--arch', '--arch', [CompletionResultType]::ParameterName, 'Override the architecture of the installed Node binary. Defaults to arch of fnm binary')
[CompletionResult]::new('--version-file-strategy', '--version-file-strategy', [CompletionResultType]::ParameterName, 'A strategy for how to resolve the Node version. Used whenever `fnm use` or `fnm install` is called without a version, or when `--use-on-cd` is configured on evaluation')
[CompletionResult]::new('--resolve-engines', '--resolve-engines', [CompletionResultType]::ParameterName, 'Resolve `engines.node` field in `package.json` whenever a `.node-version` or `.nvmrc` file is not present. This feature is enabled by default. To disable it, provide `--resolve-engines=false`.')
[CompletionResult]::new('--latest', '--latest', [CompletionResultType]::ParameterName, 'Only show the latest matching version')
[CompletionResult]::new('--corepack-enabled', '--corepack-enabled', [CompletionResultType]::ParameterName, 'Enable corepack support for each new installation. This will make fnm call `corepack enable` on every Node.js installation. For more information about corepack see <https://nodejs.org/api/corepack.html>')
[CompletionResult]::new('-h', '-h', [CompletionResultType]::ParameterName, 'Print help (see more with ''--help'')')
[CompletionResult]::new('--help', '--help', [CompletionResultType]::ParameterName, 'Print help (see more with ''--help'')')
break
}
'fnm;ls-remote' {
[CompletionResult]::new('--filter', '--filter', [CompletionResultType]::ParameterName, 'Filter versions by a user-defined version or a semver range')
[CompletionResult]::new('--lts', '--lts', [CompletionResultType]::ParameterName, 'Show only LTS versions (optionally filter by LTS codename)')
[CompletionResult]::new('--sort', '--sort', [CompletionResultType]::ParameterName, 'Version sorting order')
[CompletionResult]::new('--node-dist-mirror', '--node-dist-mirror', [CompletionResultType]::ParameterName, '<https://nodejs.org/dist/> mirror')
[CompletionResult]::new('--fnm-dir', '--fnm-dir', [CompletionResultType]::ParameterName, 'The root directory of fnm installations')
[CompletionResult]::new('--log-level', '--log-level', [CompletionResultType]::ParameterName, 'The log level of fnm commands')
[CompletionResult]::new('--arch', '--arch', [CompletionResultType]::ParameterName, 'Override the architecture of the installed Node binary. Defaults to arch of fnm binary')
[CompletionResult]::new('--version-file-strategy', '--version-file-strategy', [CompletionResultType]::ParameterName, 'A strategy for how to resolve the Node version. Used whenever `fnm use` or `fnm install` is called without a version, or when `--use-on-cd` is configured on evaluation')
[CompletionResult]::new('--resolve-engines', '--resolve-engines', [CompletionResultType]::ParameterName, 'Resolve `engines.node` field in `package.json` whenever a `.node-version` or `.nvmrc` file is not present. This feature is enabled by default. To disable it, provide `--resolve-engines=false`.')
[CompletionResult]::new('--latest', '--latest', [CompletionResultType]::ParameterName, 'Only show the latest matching version')
[CompletionResult]::new('--corepack-enabled', '--corepack-enabled', [CompletionResultType]::ParameterName, 'Enable corepack support for each new installation. This will make fnm call `corepack enable` on every Node.js installation. For more information about corepack see <https://nodejs.org/api/corepack.html>')
[CompletionResult]::new('-h', '-h', [CompletionResultType]::ParameterName, 'Print help (see more with ''--help'')')
[CompletionResult]::new('--help', '--help', [CompletionResultType]::ParameterName, 'Print help (see more with ''--help'')')
break
}
'fnm;list' {
[CompletionResult]::new('--node-dist-mirror', '--node-dist-mirror', [CompletionResultType]::ParameterName, '<https://nodejs.org/dist/> mirror')
[CompletionResult]::new('--fnm-dir', '--fnm-dir', [CompletionResultType]::ParameterName, 'The root directory of fnm installations')
[CompletionResult]::new('--log-level', '--log-level', [CompletionResultType]::ParameterName, 'The log level of fnm commands')
[CompletionResult]::new('--arch', '--arch', [CompletionResultType]::ParameterName, 'Override the architecture of the installed Node binary. Defaults to arch of fnm binary')
[CompletionResult]::new('--version-file-strategy', '--version-file-strategy', [CompletionResultType]::ParameterName, 'A strategy for how to resolve the Node version. Used whenever `fnm use` or `fnm install` is called without a version, or when `--use-on-cd` is configured on evaluation')
[CompletionResult]::new('--resolve-engines', '--resolve-engines', [CompletionResultType]::ParameterName, 'Resolve `engines.node` field in `package.json` whenever a `.node-version` or `.nvmrc` file is not present. This feature is enabled by default. To disable it, provide `--resolve-engines=false`.')
[CompletionResult]::new('--corepack-enabled', '--corepack-enabled', [CompletionResultType]::ParameterName, 'Enable corepack support for each new installation. This will make fnm call `corepack enable` on every Node.js installation. For more information about corepack see <https://nodejs.org/api/corepack.html>')
[CompletionResult]::new('-h', '-h', [CompletionResultType]::ParameterName, 'Print help (see more with ''--help'')')
[CompletionResult]::new('--help', '--help', [CompletionResultType]::ParameterName, 'Print help (see more with ''--help'')')
break
}
'fnm;ls' {
[CompletionResult]::new('--node-dist-mirror', '--node-dist-mirror', [CompletionResultType]::ParameterName, '<https://nodejs.org/dist/> mirror')
[CompletionResult]::new('--fnm-dir', '--fnm-dir', [CompletionResultType]::ParameterName, 'The root directory of fnm installations')
[CompletionResult]::new('--log-level', '--log-level', [CompletionResultType]::ParameterName, 'The log level of fnm commands')
[CompletionResult]::new('--arch', '--arch', [CompletionResultType]::ParameterName, 'Override the architecture of the installed Node binary. Defaults to arch of fnm binary')
[CompletionResult]::new('--version-file-strategy', '--version-file-strategy', [CompletionResultType]::ParameterName, 'A strategy for how to resolve the Node version. Used whenever `fnm use` or `fnm install` is called without a version, or when `--use-on-cd` is configured on evaluation')
[CompletionResult]::new('--resolve-engines', '--resolve-engines', [CompletionResultType]::ParameterName, 'Resolve `engines.node` field in `package.json` whenever a `.node-version` or `.nvmrc` file is not present. This feature is enabled by default. To disable it, provide `--resolve-engines=false`.')
[CompletionResult]::new('--corepack-enabled', '--corepack-enabled', [CompletionResultType]::ParameterName, 'Enable corepack support for each new installation. This will make fnm call `corepack enable` on every Node.js installation. For more information about corepack see <https://nodejs.org/api/corepack.html>')
[CompletionResult]::new('-h', '-h', [CompletionResultType]::ParameterName, 'Print help (see more with ''--help'')')
[CompletionResult]::new('--help', '--help', [CompletionResultType]::ParameterName, 'Print help (see more with ''--help'')')
break
}
'fnm;install' {
[CompletionResult]::new('--progress', '--progress', [CompletionResultType]::ParameterName, 'Show an interactive progress bar for the download status')
[CompletionResult]::new('--node-dist-mirror', '--node-dist-mirror', [CompletionResultType]::ParameterName, '<https://nodejs.org/dist/> mirror')
[CompletionResult]::new('--fnm-dir', '--fnm-dir', [CompletionResultType]::ParameterName, 'The root directory of fnm installations')
[CompletionResult]::new('--log-level', '--log-level', [CompletionResultType]::ParameterName, 'The log level of fnm commands')
[CompletionResult]::new('--arch', '--arch', [CompletionResultType]::ParameterName, 'Override the architecture of the installed Node binary. Defaults to arch of fnm binary')
[CompletionResult]::new('--version-file-strategy', '--version-file-strategy', [CompletionResultType]::ParameterName, 'A strategy for how to resolve the Node version. Used whenever `fnm use` or `fnm install` is called without a version, or when `--use-on-cd` is configured on evaluation')
[CompletionResult]::new('--resolve-engines', '--resolve-engines', [CompletionResultType]::ParameterName, 'Resolve `engines.node` field in `package.json` whenever a `.node-version` or `.nvmrc` file is not present. This feature is enabled by default. To disable it, provide `--resolve-engines=false`.')
[CompletionResult]::new('--lts', '--lts', [CompletionResultType]::ParameterName, 'Install latest LTS')
[CompletionResult]::new('--latest', '--latest', [CompletionResultType]::ParameterName, 'Install latest version')
[CompletionResult]::new('--corepack-enabled', '--corepack-enabled', [CompletionResultType]::ParameterName, 'Enable corepack support for each new installation. This will make fnm call `corepack enable` on every Node.js installation. For more information about corepack see <https://nodejs.org/api/corepack.html>')
[CompletionResult]::new('-h', '-h', [CompletionResultType]::ParameterName, 'Print help (see more with ''--help'')')
[CompletionResult]::new('--help', '--help', [CompletionResultType]::ParameterName, 'Print help (see more with ''--help'')')
break
}
'fnm;i' {
[CompletionResult]::new('--progress', '--progress', [CompletionResultType]::ParameterName, 'Show an interactive progress bar for the download status')
[CompletionResult]::new('--node-dist-mirror', '--node-dist-mirror', [CompletionResultType]::ParameterName, '<https://nodejs.org/dist/> mirror')
[CompletionResult]::new('--fnm-dir', '--fnm-dir', [CompletionResultType]::ParameterName, 'The root directory of fnm installations')
[CompletionResult]::new('--log-level', '--log-level', [CompletionResultType]::ParameterName, 'The log level of fnm commands')
[CompletionResult]::new('--arch', '--arch', [CompletionResultType]::ParameterName, 'Override the architecture of the installed Node binary. Defaults to arch of fnm binary')
[CompletionResult]::new('--version-file-strategy', '--version-file-strategy', [CompletionResultType]::ParameterName, 'A strategy for how to resolve the Node version. Used whenever `fnm use` or `fnm install` is called without a version, or when `--use-on-cd` is configured on evaluation')
[CompletionResult]::new('--resolve-engines', '--resolve-engines', [CompletionResultType]::ParameterName, 'Resolve `engines.node` field in `package.json` whenever a `.node-version` or `.nvmrc` file is not present. This feature is enabled by default. To disable it, provide `--resolve-engines=false`.')
[CompletionResult]::new('--lts', '--lts', [CompletionResultType]::ParameterName, 'Install latest LTS')
[CompletionResult]::new('--latest', '--latest', [CompletionResultType]::ParameterName, 'Install latest version')
[CompletionResult]::new('--corepack-enabled', '--corepack-enabled', [CompletionResultType]::ParameterName, 'Enable corepack support for each new installation. This will make fnm call `corepack enable` on every Node.js installation. For more information about corepack see <https://nodejs.org/api/corepack.html>')
[CompletionResult]::new('-h', '-h', [CompletionResultType]::ParameterName, 'Print help (see more with ''--help'')')
[CompletionResult]::new('--help', '--help', [CompletionResultType]::ParameterName, 'Print help (see more with ''--help'')')
break
}
'fnm;use' {
[CompletionResult]::new('--node-dist-mirror', '--node-dist-mirror', [CompletionResultType]::ParameterName, '<https://nodejs.org/dist/> mirror')
[CompletionResult]::new('--fnm-dir', '--fnm-dir', [CompletionResultType]::ParameterName, 'The root directory of fnm installations')
[CompletionResult]::new('--log-level', '--log-level', [CompletionResultType]::ParameterName, 'The log level of fnm commands')
[CompletionResult]::new('--arch', '--arch', [CompletionResultType]::ParameterName, 'Override the architecture of the installed Node binary. Defaults to arch of fnm binary')
[CompletionResult]::new('--version-file-strategy', '--version-file-strategy', [CompletionResultType]::ParameterName, 'A strategy for how to resolve the Node version. Used whenever `fnm use` or `fnm install` is called without a version, or when `--use-on-cd` is configured on evaluation')
[CompletionResult]::new('--resolve-engines', '--resolve-engines', [CompletionResultType]::ParameterName, 'Resolve `engines.node` field in `package.json` whenever a `.node-version` or `.nvmrc` file is not present. This feature is enabled by default. To disable it, provide `--resolve-engines=false`.')
[CompletionResult]::new('--install-if-missing', '--install-if-missing', [CompletionResultType]::ParameterName, 'Install the version if it isn''t installed yet')
[CompletionResult]::new('--silent-if-unchanged', '--silent-if-unchanged', [CompletionResultType]::ParameterName, 'Don''t output a message identifying the version being used if it will not change due to execution of this command')
[CompletionResult]::new('--corepack-enabled', '--corepack-enabled', [CompletionResultType]::ParameterName, 'Enable corepack support for each new installation. This will make fnm call `corepack enable` on every Node.js installation. For more information about corepack see <https://nodejs.org/api/corepack.html>')
[CompletionResult]::new('-h', '-h', [CompletionResultType]::ParameterName, 'Print help (see more with ''--help'')')
[CompletionResult]::new('--help', '--help', [CompletionResultType]::ParameterName, 'Print help (see more with ''--help'')')
break
}
'fnm;env' {
[CompletionResult]::new('--shell', '--shell', [CompletionResultType]::ParameterName, 'The shell syntax to use. Infers when missing')
[CompletionResult]::new('--node-dist-mirror', '--node-dist-mirror', [CompletionResultType]::ParameterName, '<https://nodejs.org/dist/> mirror')
[CompletionResult]::new('--fnm-dir', '--fnm-dir', [CompletionResultType]::ParameterName, 'The root directory of fnm installations')
[CompletionResult]::new('--log-level', '--log-level', [CompletionResultType]::ParameterName, 'The log level of fnm commands')
[CompletionResult]::new('--arch', '--arch', [CompletionResultType]::ParameterName, 'Override the architecture of the installed Node binary. Defaults to arch of fnm binary')
[CompletionResult]::new('--version-file-strategy', '--version-file-strategy', [CompletionResultType]::ParameterName, 'A strategy for how to resolve the Node version. Used whenever `fnm use` or `fnm install` is called without a version, or when `--use-on-cd` is configured on evaluation')
[CompletionResult]::new('--resolve-engines', '--resolve-engines', [CompletionResultType]::ParameterName, 'Resolve `engines.node` field in `package.json` whenever a `.node-version` or `.nvmrc` file is not present. This feature is enabled by default. To disable it, provide `--resolve-engines=false`.')
[CompletionResult]::new('--json', '--json', [CompletionResultType]::ParameterName, 'Print JSON instead of shell commands')
[CompletionResult]::new('--multi', '--multi', [CompletionResultType]::ParameterName, 'Deprecated. This is the default now')
[CompletionResult]::new('--use-on-cd', '--use-on-cd', [CompletionResultType]::ParameterName, 'Print the script to change Node versions every directory change')
[CompletionResult]::new('--corepack-enabled', '--corepack-enabled', [CompletionResultType]::ParameterName, 'Enable corepack support for each new installation. This will make fnm call `corepack enable` on every Node.js installation. For more information about corepack see <https://nodejs.org/api/corepack.html>')
[CompletionResult]::new('-h', '-h', [CompletionResultType]::ParameterName, 'Print help (see more with ''--help'')')
[CompletionResult]::new('--help', '--help', [CompletionResultType]::ParameterName, 'Print help (see more with ''--help'')')
break
}
'fnm;completions' {
[CompletionResult]::new('--shell', '--shell', [CompletionResultType]::ParameterName, 'The shell syntax to use. Infers when missing')
[CompletionResult]::new('--node-dist-mirror', '--node-dist-mirror', [CompletionResultType]::ParameterName, '<https://nodejs.org/dist/> mirror')
[CompletionResult]::new('--fnm-dir', '--fnm-dir', [CompletionResultType]::ParameterName, 'The root directory of fnm installations')
[CompletionResult]::new('--log-level', '--log-level', [CompletionResultType]::ParameterName, 'The log level of fnm commands')
[CompletionResult]::new('--arch', '--arch', [CompletionResultType]::ParameterName, 'Override the architecture of the installed Node binary. Defaults to arch of fnm binary')
[CompletionResult]::new('--version-file-strategy', '--version-file-strategy', [CompletionResultType]::ParameterName, 'A strategy for how to resolve the Node version. Used whenever `fnm use` or `fnm install` is called without a version, or when `--use-on-cd` is configured on evaluation')
[CompletionResult]::new('--resolve-engines', '--resolve-engines', [CompletionResultType]::ParameterName, 'Resolve `engines.node` field in `package.json` whenever a `.node-version` or `.nvmrc` file is not present. This feature is enabled by default. To disable it, provide `--resolve-engines=false`.')
[CompletionResult]::new('--corepack-enabled', '--corepack-enabled', [CompletionResultType]::ParameterName, 'Enable corepack support for each new installation. This will make fnm call `corepack enable` on every Node.js installation. For more information about corepack see <https://nodejs.org/api/corepack.html>')
[CompletionResult]::new('-h', '-h', [CompletionResultType]::ParameterName, 'Print help (see more with ''--help'')')
[CompletionResult]::new('--help', '--help', [CompletionResultType]::ParameterName, 'Print help (see more with ''--help'')')
break
}
'fnm;alias' {
[CompletionResult]::new('--node-dist-mirror', '--node-dist-mirror', [CompletionResultType]::ParameterName, '<https://nodejs.org/dist/> mirror')
[CompletionResult]::new('--fnm-dir', '--fnm-dir', [CompletionResultType]::ParameterName, 'The root directory of fnm installations')
[CompletionResult]::new('--log-level', '--log-level', [CompletionResultType]::ParameterName, 'The log level of fnm commands')
[CompletionResult]::new('--arch', '--arch', [CompletionResultType]::ParameterName, 'Override the architecture of the installed Node binary. Defaults to arch of fnm binary')
[CompletionResult]::new('--version-file-strategy', '--version-file-strategy', [CompletionResultType]::ParameterName, 'A strategy for how to resolve the Node version. Used whenever `fnm use` or `fnm install` is called without a version, or when `--use-on-cd` is configured on evaluation')
[CompletionResult]::new('--resolve-engines', '--resolve-engines', [CompletionResultType]::ParameterName, 'Resolve `engines.node` field in `package.json` whenever a `.node-version` or `.nvmrc` file is not present. This feature is enabled by default. To disable it, provide `--resolve-engines=false`.')
[CompletionResult]::new('--corepack-enabled', '--corepack-enabled', [CompletionResultType]::ParameterName, 'Enable corepack support for each new installation. This will make fnm call `corepack enable` on every Node.js installation. For more information about corepack see <https://nodejs.org/api/corepack.html>')
[CompletionResult]::new('-h', '-h', [CompletionResultType]::ParameterName, 'Print help (see more with ''--help'')')
[CompletionResult]::new('--help', '--help', [CompletionResultType]::ParameterName, 'Print help (see more with ''--help'')')
break
}
'fnm;unalias' {
[CompletionResult]::new('--node-dist-mirror', '--node-dist-mirror', [CompletionResultType]::ParameterName, '<https://nodejs.org/dist/> mirror')
[CompletionResult]::new('--fnm-dir', '--fnm-dir', [CompletionResultType]::ParameterName, 'The root directory of fnm installations')
[CompletionResult]::new('--log-level', '--log-level', [CompletionResultType]::ParameterName, 'The log level of fnm commands')
[CompletionResult]::new('--arch', '--arch', [CompletionResultType]::ParameterName, 'Override the architecture of the installed Node binary. Defaults to arch of fnm binary')
[CompletionResult]::new('--version-file-strategy', '--version-file-strategy', [CompletionResultType]::ParameterName, 'A strategy for how to resolve the Node version. Used whenever `fnm use` or `fnm install` is called without a version, or when `--use-on-cd` is configured on evaluation')
[CompletionResult]::new('--resolve-engines', '--resolve-engines', [CompletionResultType]::ParameterName, 'Resolve `engines.node` field in `package.json` whenever a `.node-version` or `.nvmrc` file is not present. This feature is enabled by default. To disable it, provide `--resolve-engines=false`.')
[CompletionResult]::new('--corepack-enabled', '--corepack-enabled', [CompletionResultType]::ParameterName, 'Enable corepack support for each new installation. This will make fnm call `corepack enable` on every Node.js installation. For more information about corepack see <https://nodejs.org/api/corepack.html>')
[CompletionResult]::new('-h', '-h', [CompletionResultType]::ParameterName, 'Print help (see more with ''--help'')')
[CompletionResult]::new('--help', '--help', [CompletionResultType]::ParameterName, 'Print help (see more with ''--help'')')
break
}
'fnm;default' {
[CompletionResult]::new('--node-dist-mirror', '--node-dist-mirror', [CompletionResultType]::ParameterName, '<https://nodejs.org/dist/> mirror')
[CompletionResult]::new('--fnm-dir', '--fnm-dir', [CompletionResultType]::ParameterName, 'The root directory of fnm installations')
[CompletionResult]::new('--log-level', '--log-level', [CompletionResultType]::ParameterName, 'The log level of fnm commands')
[CompletionResult]::new('--arch', '--arch', [CompletionResultType]::ParameterName, 'Override the architecture of the installed Node binary. Defaults to arch of fnm binary')
[CompletionResult]::new('--version-file-strategy', '--version-file-strategy', [CompletionResultType]::ParameterName, 'A strategy for how to resolve the Node version. Used whenever `fnm use` or `fnm install` is called without a version, or when `--use-on-cd` is configured on evaluation')
[CompletionResult]::new('--resolve-engines', '--resolve-engines', [CompletionResultType]::ParameterName, 'Resolve `engines.node` field in `package.json` whenever a `.node-version` or `.nvmrc` file is not present. This feature is enabled by default. To disable it, provide `--resolve-engines=false`.')
[CompletionResult]::new('--corepack-enabled', '--corepack-enabled', [CompletionResultType]::ParameterName, 'Enable corepack support for each new installation. This will make fnm call `corepack enable` on every Node.js installation. For more information about corepack see <https://nodejs.org/api/corepack.html>')
[CompletionResult]::new('-h', '-h', [CompletionResultType]::ParameterName, 'Print help (see more with ''--help'')')
[CompletionResult]::new('--help', '--help', [CompletionResultType]::ParameterName, 'Print help (see more with ''--help'')')
break
}
'fnm;current' {
[CompletionResult]::new('--node-dist-mirror', '--node-dist-mirror', [CompletionResultType]::ParameterName, '<https://nodejs.org/dist/> mirror')
[CompletionResult]::new('--fnm-dir', '--fnm-dir', [CompletionResultType]::ParameterName, 'The root directory of fnm installations')
[CompletionResult]::new('--log-level', '--log-level', [CompletionResultType]::ParameterName, 'The log level of fnm commands')
[CompletionResult]::new('--arch', '--arch', [CompletionResultType]::ParameterName, 'Override the architecture of the installed Node binary. Defaults to arch of fnm binary')
[CompletionResult]::new('--version-file-strategy', '--version-file-strategy', [CompletionResultType]::ParameterName, 'A strategy for how to resolve the Node version. Used whenever `fnm use` or `fnm install` is called without a version, or when `--use-on-cd` is configured on evaluation')
[CompletionResult]::new('--resolve-engines', '--resolve-engines', [CompletionResultType]::ParameterName, 'Resolve `engines.node` field in `package.json` whenever a `.node-version` or `.nvmrc` file is not present. This feature is enabled by default. To disable it, provide `--resolve-engines=false`.')
[CompletionResult]::new('--corepack-enabled', '--corepack-enabled', [CompletionResultType]::ParameterName, 'Enable corepack support for each new installation. This will make fnm call `corepack enable` on every Node.js installation. For more information about corepack see <https://nodejs.org/api/corepack.html>')
[CompletionResult]::new('-h', '-h', [CompletionResultType]::ParameterName, 'Print help (see more with ''--help'')')
[CompletionResult]::new('--help', '--help', [CompletionResultType]::ParameterName, 'Print help (see more with ''--help'')')
break
}
'fnm;exec' {
[CompletionResult]::new('--using', '--using', [CompletionResultType]::ParameterName, 'Either an explicit version, or a filename with the version written in it')
[CompletionResult]::new('--node-dist-mirror', '--node-dist-mirror', [CompletionResultType]::ParameterName, '<https://nodejs.org/dist/> mirror')
[CompletionResult]::new('--fnm-dir', '--fnm-dir', [CompletionResultType]::ParameterName, 'The root directory of fnm installations')
[CompletionResult]::new('--log-level', '--log-level', [CompletionResultType]::ParameterName, 'The log level of fnm commands')
[CompletionResult]::new('--arch', '--arch', [CompletionResultType]::ParameterName, 'Override the architecture of the installed Node binary. Defaults to arch of fnm binary')
[CompletionResult]::new('--version-file-strategy', '--version-file-strategy', [CompletionResultType]::ParameterName, 'A strategy for how to resolve the Node version. Used whenever `fnm use` or `fnm install` is called without a version, or when `--use-on-cd` is configured on evaluation')
[CompletionResult]::new('--resolve-engines', '--resolve-engines', [CompletionResultType]::ParameterName, 'Resolve `engines.node` field in `package.json` whenever a `.node-version` or `.nvmrc` file is not present. This feature is enabled by default. To disable it, provide `--resolve-engines=false`.')
[CompletionResult]::new('--using-file', '--using-file', [CompletionResultType]::ParameterName, 'Deprecated. This is the default now')
[CompletionResult]::new('--corepack-enabled', '--corepack-enabled', [CompletionResultType]::ParameterName, 'Enable corepack support for each new installation. This will make fnm call `corepack enable` on every Node.js installation. For more information about corepack see <https://nodejs.org/api/corepack.html>')
[CompletionResult]::new('-h', '-h', [CompletionResultType]::ParameterName, 'Print help (see more with ''--help'')')
[CompletionResult]::new('--help', '--help', [CompletionResultType]::ParameterName, 'Print help (see more with ''--help'')')
break
}
'fnm;uninstall' {
[CompletionResult]::new('--node-dist-mirror', '--node-dist-mirror', [CompletionResultType]::ParameterName, '<https://nodejs.org/dist/> mirror')
[CompletionResult]::new('--fnm-dir', '--fnm-dir', [CompletionResultType]::ParameterName, 'The root directory of fnm installations')
[CompletionResult]::new('--log-level', '--log-level', [CompletionResultType]::ParameterName, 'The log level of fnm commands')
[CompletionResult]::new('--arch', '--arch', [CompletionResultType]::ParameterName, 'Override the architecture of the installed Node binary. Defaults to arch of fnm binary')
[CompletionResult]::new('--version-file-strategy', '--version-file-strategy', [CompletionResultType]::ParameterName, 'A strategy for how to resolve the Node version. Used whenever `fnm use` or `fnm install` is called without a version, or when `--use-on-cd` is configured on evaluation')
[CompletionResult]::new('--resolve-engines', '--resolve-engines', [CompletionResultType]::ParameterName, 'Resolve `engines.node` field in `package.json` whenever a `.node-version` or `.nvmrc` file is not present. This feature is enabled by default. To disable it, provide `--resolve-engines=false`.')
[CompletionResult]::new('--corepack-enabled', '--corepack-enabled', [CompletionResultType]::ParameterName, 'Enable corepack support for each new installation. This will make fnm call `corepack enable` on every Node.js installation. For more information about corepack see <https://nodejs.org/api/corepack.html>')
[CompletionResult]::new('-h', '-h', [CompletionResultType]::ParameterName, 'Print help (see more with ''--help'')')
[CompletionResult]::new('--help', '--help', [CompletionResultType]::ParameterName, 'Print help (see more with ''--help'')')
break
}
'fnm;uni' {
[CompletionResult]::new('--node-dist-mirror', '--node-dist-mirror', [CompletionResultType]::ParameterName, '<https://nodejs.org/dist/> mirror')
[CompletionResult]::new('--fnm-dir', '--fnm-dir', [CompletionResultType]::ParameterName, 'The root directory of fnm installations')
[CompletionResult]::new('--log-level', '--log-level', [CompletionResultType]::ParameterName, 'The log level of fnm commands')
[CompletionResult]::new('--arch', '--arch', [CompletionResultType]::ParameterName, 'Override the architecture of the installed Node binary. Defaults to arch of fnm binary')
[CompletionResult]::new('--version-file-strategy', '--version-file-strategy', [CompletionResultType]::ParameterName, 'A strategy for how to resolve the Node version. Used whenever `fnm use` or `fnm install` is called without a version, or when `--use-on-cd` is configured on evaluation')
[CompletionResult]::new('--resolve-engines', '--resolve-engines', [CompletionResultType]::ParameterName, 'Resolve `engines.node` field in `package.json` whenever a `.node-version` or `.nvmrc` file is not present. This feature is enabled by default. To disable it, provide `--resolve-engines=false`.')
[CompletionResult]::new('--corepack-enabled', '--corepack-enabled', [CompletionResultType]::ParameterName, 'Enable corepack support for each new installation. This will make fnm call `corepack enable` on every Node.js installation. For more information about corepack see <https://nodejs.org/api/corepack.html>')
[CompletionResult]::new('-h', '-h', [CompletionResultType]::ParameterName, 'Print help (see more with ''--help'')')
[CompletionResult]::new('--help', '--help', [CompletionResultType]::ParameterName, 'Print help (see more with ''--help'')')
break
}
'fnm;help' {
[CompletionResult]::new('list-remote', 'list-remote', [CompletionResultType]::ParameterValue, 'List all remote Node.js versions')
[CompletionResult]::new('list', 'list', [CompletionResultType]::ParameterValue, 'List all locally installed Node.js versions')
[CompletionResult]::new('install', 'install', [CompletionResultType]::ParameterValue, 'Install a new Node.js version')
[CompletionResult]::new('use', 'use', [CompletionResultType]::ParameterValue, 'Change Node.js version')
[CompletionResult]::new('env', 'env', [CompletionResultType]::ParameterValue, 'Print and set up required environment variables for fnm')
[CompletionResult]::new('completions', 'completions', [CompletionResultType]::ParameterValue, 'Print shell completions to stdout')
[CompletionResult]::new('alias', 'alias', [CompletionResultType]::ParameterValue, 'Alias a version to a common name')
[CompletionResult]::new('unalias', 'unalias', [CompletionResultType]::ParameterValue, 'Remove an alias definition')
[CompletionResult]::new('default', 'default', [CompletionResultType]::ParameterValue, 'Set a version as the default version')
[CompletionResult]::new('current', 'current', [CompletionResultType]::ParameterValue, 'Print the current Node.js version')
[CompletionResult]::new('exec', 'exec', [CompletionResultType]::ParameterValue, 'Run a command within fnm context')
[CompletionResult]::new('uninstall', 'uninstall', [CompletionResultType]::ParameterValue, 'Uninstall a Node.js version')
[CompletionResult]::new('help', 'help', [CompletionResultType]::ParameterValue, 'Print this message or the help of the given subcommand(s)')
break
}
'fnm;help;list-remote' {
break
}
'fnm;help;list' {
break
}
'fnm;help;install' {
break
}
'fnm;help;use' {
break
}
'fnm;help;env' {
break
}
'fnm;help;completions' {
break
}
'fnm;help;alias' {
break
}
'fnm;help;unalias' {
break
}
'fnm;help;default' {
break
}
'fnm;help;current' {
break
}
'fnm;help;exec' {
break
}
'fnm;help;uninstall' {
break
}
'fnm;help;help' {
break
}
})
$completions.Where{ $_.CompletionText -like "$wordToComplete*" } |
Sort-Object -Property ListItemText
}
# fnm completion end
# Starship prompt
$ENV:STARSHIP_CONFIG = "$HOME\.config\starship\starship.toml"
Invoke-Expression (& Starship init powershell)
# Monitor window size changes and update view style accordingly
# This ensures that the view style is always appropriate
Register-EngineEvent -SourceIdentifier PowerShell.OnIdle -MaxTriggerCount 1 -Action {
# Add event to re-register this script
Register-EngineEvent -SourceIdentifier PowerShell.OnIdle -MaxTriggerCount 1 -Action $Action
# Check if window size changed and update view style if needed
$currentWidth = $Host.UI.RawUI.WindowSize.Width
$currentHeight = $Host.UI.RawUI.WindowSize.Height
if ($Global:LastWindowWidth -ne $currentWidth -or $Global:LastWindowHeight -ne $currentHeight) {
Set-AppropriateViewStyle
$Global:LastWindowWidth = $currentWidth
$Global:LastWindowHeight = $currentHeight
}
} | Out-Null
# Initialize window size tracking variables
$Global:LastWindowWidth = $Host.UI.RawUI.WindowSize.Width
$Global:LastWindowHeight = $Host.UI.RawUI.WindowSize.Height
if ($env:TERM_PROGRAM -eq "vscode") { . "$(code --locate-shell-integration-path pwsh)" }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment