Skip to content

Instantly share code, notes, and snippets.

@gregmac
Last active December 12, 2019 02:06
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gregmac/81a6c853d3992cdf95fca47bb1bb0b63 to your computer and use it in GitHub Desktop.
Save gregmac/81a6c853d3992cdf95fca47bb1bb0b63 to your computer and use it in GitHub Desktop.
PowerShell Set-WindowTitle profile config
# Import posh-git (if installed via scoop)
$poshGitModule = "$HOME\scoop\apps\posh-git\current\posh-git.psd1";
if (Test-Path $poshGitModule) { Import-Module $poshGitModule }
# msbuild convenience alias
Set-Alias MSBuild 'C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\MSBuild\Current\Bin\MSBuild.exe'
# bash-style completion
Set-PSReadlineKeyHandler -Key Tab -Function Complete
#Set-PSReadlineOption -ShowToolTips
# set powershell window title
function Set-WindowTitle { $global:WindowTitleOverride = [string]::Join(" ",$args) }
Set-Alias -name "title" -value Set-WindowTitle
# override promt: set window title to current directory,
# unless Set-WindowTitle was used to override,
# or posh-git is installed and we're in a git directory.
function Prompt
{
# Set WindowTitle to current directory name, unless overridden with Set-WindowTitle
$host.ui.RawUI.WindowTitle = if ($global:WindowTitleOverride) { $global:WindowTitleOverride } else { get-location };
if ($GitPromptScriptBlock) { & $GitPromptScriptBlock } # posh-git compatibility
else { 'PS ' + $pwd + '> ' }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment