Last active
January 18, 2022 00:46
-
-
Save brettmillerb/467e4ee2d7f8e97897f106a5534f884b to your computer and use it in GitHub Desktop.
Mac Pwsh Profile
This file contains 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
Import-Module -Name Toolbox | |
Import-Module -Name Microsoft.PowerShell.UnixCompleters | |
Import-Module -Name Terminal-Icons | |
function BackOne { | |
Set-Location .. | |
} | |
function BackTwo { | |
Set-Location ../.. | |
} | |
function Get-NativeChildItem { | |
& (Get-Command ls -CommandType Application) -lhG | |
} | |
function Get-NativeChildItemG { | |
& (Get-Command ls -CommandType Application) -G | |
} | |
function Get-NativeChildItemA { | |
& (Get-Command ls -CommandType Application) -lAhG | |
} | |
Invoke-Expression "$(thefuck --alias)" | |
New-Alias -Name code -Value 'code-insiders' | |
New-Alias -Name '..' -Value 'BackOne' | |
New-Alias -Name '...' -Value 'BackTwo' | |
New-Alias -Name clip -Value Set-Clipboard | |
New-Alias -Name ll -Value Get-NativeChildItem | |
New-Alias -Name ls -Value Get-NativeChildItemG | |
New-Alias -Name la -Value Get-NativeChildItemA | |
Set-PSReadLineKeyHandler -Key UpArrow -Function HistorySearchBackward | |
Set-PSReadLineKeyHandler -Key Tab -Function MenuComplete | |
Set-PSReadLineOption -HistorySearchCursorMovesToEnd:$true | |
# EditorServicesCommandSuite - Only needs to load in Vscode. | |
if ($host.name -eq 'Visual Studio Code Host') { | |
Import-Module EditorServicesCommandSuite | |
Import-EditorCommand -Module EditorServicesCommandSuite | |
} | |
Import-Module posh-git | |
Import-Module oh-my-posh | |
Set-PoshPrompt -Theme /Users/brett.miller/.oh-my-posh.omp.json | |
$env:AZ_ENABLED = $true | |
# Taken from here: https://devblogs.microsoft.com/scripting/whats-in-your-powershell-profile-powershell-team-favorites/ | |
# Changing directories without having to type cd to replicate zsh | |
$ExecutionContext.InvokeCommand.CommandNotFoundAction = { | |
param([string]$commandName, | |
[System.Management.Automation.CommandLookupEventArgs]$eventArgs | |
) | |
# Remove the ‘get-‘ prefix that confuses Test-Path after we produce | |
# something that is path like after the get-. | |
if ($commandName.StartsWith(‘get-‘)) { | |
$commandName = $commandName.Substring(4) | |
} | |
# If the command looks like a location, just switch to that directory | |
if (Test-Path -Path $commandName) { | |
$eventArgs.CommandScriptBlock = { Set-Location -LiteralPath $commandName }.GetNewClosure() | |
return | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment