Last active
March 31, 2025 17:46
-
-
Save mattdkerr/99c0e949cd7530161dca1a05344a5d85 to your computer and use it in GitHub Desktop.
Make PowerShell UnIx-y
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# get powershell 7+ | |
# winget install powershell | |
Get-InstalledModule ` | |
| ? { $_.Repository -eq 'https://www.powershellgallery.com/api/v2/' } ` | |
| % { Install-Package -Name $_.Name -Source PSGallery -Force -AcceptLicense } | |
# Git prompt status line enablement | |
Import-Module 'C:\Users\mkerr\code\posh-git\src\posh-git.psd1' | |
# Install Git for Windows, make sure to put Unix tools on the command-line | |
if (Test-Path alias:ls*) { Remove-Alias ls } | |
if (Test-Path alias:mv*) { Remove-Alias mv } | |
if (Test-Path alias:cp*) { Remove-Alias cp } | |
if (Test-Path alias:rm*) { Remove-Alias rm } | |
if (Test-Path alias:dir*) { Remove-Alias dir } | |
# scoop install eza or rustup.rs then cargo install eza | |
function l { eza --git --icons --group-directories-first --ignore-glob="ntuser*|NTUSER*" --grid $args } | |
function ls { eza --git --icons --group-directories-first --ignore-glob="ntuser*|NTUSER*" --grid $args } | |
function ll { eza --git --icons --group-directories-first --ignore-glob="ntuser*|NTUSER*" -l $args } | |
function .. { cd .. } | |
# if you use Chocolatey | |
# Import-Module $env:ChocolateyInstall\helpers\chocolateyProfile.psm1 | |
Import-Module PSColors | |
# Powershell 7.5+ | |
Enable-ExperimentalFeature PSFeedbackProvider | |
Enable-ExperimentalFeature PSCommandNotFoundSuggestion | |
Import-Module Terminal-Icons | |
# scoop install zoxide | |
Invoke-Expression (& { (zoxide init powershell | Out-String) }) | |
# scoop install starship | |
Invoke-Expression (&starship init powershell) | |
# one time: Install-Module PSReadLine -Repository PSGallery -Scope CurrentUser -Force | |
Import-Module PSReadLine | |
Set-PSReadLineOption -EditMode Emacs | |
# make sure copy/paste works properly as before | |
Set-PSReadLineKeyHandler -Key Ctrl+C -Function Copy | |
Set-PSReadLineKeyHandler -Key Ctrl+v -Function Paste | |
# set up zsh-like command-history with tab completion and up/down scrolling | |
Set-PSReadLineOption -HistorySearchCursorMovesToEnd | |
Set-PSReadLineKeyHandler -Key Tab -Function MenuComplete | |
Set-PSReadLineKeyHandler -Key UpArrow -Function HistorySearchBackward | |
Set-PSReadLineKeyHandler -Key DownArrow -Function HistorySearchForward | |
# ctrl+t to bring up fzf + replace command | |
# alt+t to fzf + insert ito spot in command | |
Import-module PSfzf | |
Set-PSFzfOption -EnableAliasFuzzySetEverything |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Git: https://git-scm.com/downloads/win
Chocolatey: https://chocolatey.org/install
Rustup - https://rustup.rs/
Scoop: https://scoop.sh/