Skip to content

Instantly share code, notes, and snippets.

@mingyuchoo
Last active November 29, 2023 23:59
Show Gist options
  • Save mingyuchoo/85a5e1469a0f65deeb97802672c80c97 to your computer and use it in GitHub Desktop.
Save mingyuchoo/85a5e1469a0f65deeb97802672c80c97 to your computer and use it in GitHub Desktop.
How to create Powershell profile

How to create profile for Powershell

Creat a profile file for Powershell

> New-Item -ItemType file -Path $PROFILE -Force

Open profile file

> notepad .\Microsoft.PowerShell_profile.ps1

Create base script

# make error messages readable
$host.privatedata.ErrorBackgroundColor = 'DarkRed'
$host.privatedata.ErrorForegroundColor = 'White'

# make strings readable
$colors = @{}
$colors['String'] = [System.ConsoleColor]::Cyan
$colors['Comment'] = [System.ConsoleColor]::Gray

# set history count
$MaxiumHistoryCount = 4096

# emacs key
Set-PSReadLineOption -EditMode Emacs -Colors $colors

# set alias
Set-Alias -Name docker -Value podman

# hook direnv
Invoke-Expression "$(direnv hook powershell)"

# Import the Chocolatey Profile that contains the necessary code to enable
# tab-completions to function for `choco`.
# Be aware that if you are missing these lines from your profile, tab completion
# for `choco` will not function.
# See https://ch0.co/tab-completion for details.
$ChocolateyProfile = "$env:ChocolateyInstall\helpers\chocolateyProfile.psm1"
if (Test-Path($ChocolateyProfile)) {
  Import-Module "$ChocolateyProfile"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment