Last active
December 2, 2023 16:55
-
-
Save SebastianGrans/c48874f2c9148b4b5ce340066a472012 to your computer and use it in GitHub Desktop.
Useful thinsg to put in your PowerShell `$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
# Copy last command to clipboard | |
function cl() { | |
$last_command = (Get-History -Count 1).CommandLine | |
Set-Clipboard -Value $last_command | |
} | |
# Copy absolute path of a file or folder to clipboard | |
function cap($path) { | |
Set-Clipboard -Value (Resolve-Path $path) | |
} | |
# MacOS like `open` command | |
function open([string]$path = ".") { | |
if(-Not(Test-Path $path)) { | |
Write-Error "Path $path doesn't exist" -ErrorAction Stop | |
} | |
explorer.exe $path | |
} | |
# Git integration - https://github.com/dahlbyk/posh-git | |
# Adds tab completion and other nice things | |
Import-Module posh-git | |
# Improved auto-complete - https://github.com/PowerShell/PSReadLine | |
Set-PSReadlineKeyHandler -Key Tab -Function MenuComplete | |
# E.g. `ssh<upArrow>` only searches for previous commands starting with `ssh`. | |
Set-PSReadLineKeyHandler -Key UpArrow -Function HistorySearchBackward | |
Set-PSReadLineKeyHandler -Key DownArrow -Function HistorySearchForward | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment