Skip to content

Instantly share code, notes, and snippets.

@gregmac
Last active December 12, 2019 02:06
Show Gist options
  • Select an option

  • Save gregmac/81a6c853d3992cdf95fca47bb1bb0b63 to your computer and use it in GitHub Desktop.

Select an option

Save gregmac/81a6c853d3992cdf95fca47bb1bb0b63 to your computer and use it in GitHub Desktop.

Revisions

  1. gregmac revised this gist Jul 3, 2019. 1 changed file with 16 additions and 2 deletions.
    18 changes: 16 additions & 2 deletions $PROFILE\Microsoft.PowerShell_profile.ps1
    Original file line number Diff line number Diff line change
    @@ -1,11 +1,25 @@
    # 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 + '> ' } # default. TODO: is it possible to chain and call the previous `Prompt` command?
    }
    else { 'PS ' + $pwd + '> ' }
    }
  2. gregmac renamed this gist May 17, 2019. 1 changed file with 1 addition and 0 deletions.
    Original file line number Diff line number Diff line change
    @@ -7,4 +7,5 @@ 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 + '> ' } # default. TODO: is it possible to chain and call the previous `Prompt` command?
    }
  3. gregmac created this gist May 16, 2019.
    10 changes: 10 additions & 0 deletions Microsoft.PowerShell_profile.ps1
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,10 @@

    function Set-WindowTitle { $global:WindowTitleOverride = [string]::Join(" ",$args) }
    Set-Alias -name "title" -value Set-WindowTitle

    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
    }