Created
May 12, 2022 15:41
-
-
Save jwosty/0216a8120cd7495c220ab0e94e971aa5 to your computer and use it in GitHub Desktop.
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
# Jwosty's powershell profile | |
Import-Module 'C:\tools\poshgit\dahlbyk-posh-git-9bda399\src\posh-git.psd1' | |
# Start emacs in no-window mode (CLI mode) | |
function Private:emacs() | |
{ | |
& emacs -nw $args | |
} | |
function Get-ShortPromptPath() { | |
$long = Get-PromptPath | |
$short = Split-Path -Path $long -Leaf | |
git rev-parse --is-inside-work-tree *>$null | |
if ($? -and ($long.length -gt 26)) { | |
return $short | |
} else { | |
return $long | |
} | |
} | |
function Get-ShortPromptPathNew() { | |
$repoPath = git rev-parse --show-toplevel 2>$NULL | |
if ($?) { | |
# we are inside a git repo | |
$savedPwd = $pwd | |
Push-Location $repoPath | |
Set-Location .. | |
$result = Resolve-Path -Relative $savedPwd | |
Pop-Location | |
return $result -replace '^\.\\(?!$)' | |
} else { | |
# we are not inside a git repo | |
return Get-PromptPath | |
} | |
} | |
# Make completion behave more like bash, which stops at the first diffing char (the sane way), instead | |
# of the garbage Windows-ism which cycles through all possibilities on successive tab presses. The | |
# latter drives me absolutey insane. | |
Set-PSReadlineKeyHandler -Key Tab -Function Complete | |
New-Alias which get-command | |
$GitPromptSettings.DefaultPromptAbbreviateHomeDirectory = $true | |
$GitPromptSettings.DefaultPromptPath = '$(Get-ShortPromptPathNew)' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment