Skip to content

Instantly share code, notes, and snippets.

@sweeneyrobb
Created January 2, 2016 19:23
Show Gist options
  • Save sweeneyrobb/e9f17f145bb256770f7a to your computer and use it in GitHub Desktop.
Save sweeneyrobb/e9f17f145bb256770f7a to your computer and use it in GitHub Desktop.
Tweaks the prompt so that when your working directory appears in the $prompts hash table it will replace it with a designated string (the value of the hash table). Makes working with long paths a little bit more bearable without reducing the path too much. Add to $PROFILE to use without pasting every time.
function prompt() {
$prompts = @{
$HOME = "~";
"$HOME\Documents\GitHub" = "~\[github]";
$env:windir = "windir";
}
$loc = (Get-Location | Select -ExpandProperty Path)
$prompts.GetEnumerator() | ForEach-Object { $loc = $loc.Replace($_.Name, $_.Value) }
return $loc + "> "
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment