Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
You can’t perform that action at this time.