Skip to content

Instantly share code, notes, and snippets.

@cptpiepmatz
Last active December 24, 2022 00:48

Revisions

  1. cptpiepmatz revised this gist Dec 24, 2022. 1 changed file with 9 additions and 6 deletions.
    15 changes: 9 additions & 6 deletions prompt.ps1
    Original file line number Diff line number Diff line change
    @@ -16,13 +16,16 @@ function ExitCode {
    }

    function OnBranch {
    $consoleOut = $((git branch) -match "^\*\s+(?<Branch>\S+)");
    if ($consoleOut) {
    if ($consoleOut -ne "True") {
    $consoleOut = ($consoleOut -match "^\*\s+(?<Branch>\S+)");
    Try {
    $consoleOut = $((git branch) -match "^\*\s+(?<Branch>\S+)");
    if ($consoleOut) {
    if ($consoleOut -ne "True") {
    $consoleOut = ($consoleOut -match "^\*\s+(?<Branch>\S+)");
    }
    return " on " + "$ESC[38;5;163m" + $Matches.Branch + "$ESC[0m";
    }
    return " on " + "$ESC[38;5;163m" + $Matches.Branch + "$ESC[0m";
    }
    Catch {}
    return "";
    }

    @@ -71,4 +74,4 @@ function global:prompt {
    (ViaRust) +
    "`n" +
    "> "
    }
    }
  2. cptpiepmatz revised this gist Oct 7, 2022. 1 changed file with 13 additions and 1 deletion.
    14 changes: 13 additions & 1 deletion prompt.ps1
    Original file line number Diff line number Diff line change
    @@ -6,6 +6,15 @@ switch ($env:ComputerName) {
    default {$computerName = $env:ComputerName}
    }

    function ExitCode {
    if (-not($?)) {
    if ($LASTEXITCODE -ne 0) {
    return " {" + $LASTEXITCODE + "}";
    }
    }
    return "";
    }

    function OnBranch {
    $consoleOut = $((git branch) -match "^\*\s+(?<Branch>\S+)");
    if ($consoleOut) {
    @@ -44,7 +53,10 @@ function ViaRust {
    }

    function global:prompt {
    "PS " +
    "PS" +
    "$ESC[38;5;1m" +
    (ExitCode) +
    " " +
    "$ESC[38;5;33m" +
    $env:UserName +
    "@" +
  3. cptpiepmatz revised this gist Mar 24, 2022. 1 changed file with 41 additions and 0 deletions.
    41 changes: 41 additions & 0 deletions prompt.ps1
    Original file line number Diff line number Diff line change
    @@ -6,6 +6,43 @@ switch ($env:ComputerName) {
    default {$computerName = $env:ComputerName}
    }

    function OnBranch {
    $consoleOut = $((git branch) -match "^\*\s+(?<Branch>\S+)");
    if ($consoleOut) {
    if ($consoleOut -ne "True") {
    $consoleOut = ($consoleOut -match "^\*\s+(?<Branch>\S+)");
    }
    return " on " + "$ESC[38;5;163m" + $Matches.Branch + "$ESC[0m";
    }
    return "";
    }

    function ViaNode {
    Try {
    if (Get-Item -Path "package.json") {
    $nodeVersion = $(node -v);
    return " via $ESC[38;5;2mNode " + $nodeVersion + "$ESC[0m";
    }
    return "";
    }
    Catch {
    return "";
    }
    }

    function ViaRust {
    Try {
    if (Get-Item -Path "Cargo.toml") {
    $rustVersion = $((rustc -V) -match "rustc (?<Version>\S+)");
    return " via $ESC[38;5;166mRust " + $Matches.Version + "$ESC[0m";
    }
    return "";
    }
    Catch {
    return "";
    }
    }

    function global:prompt {
    "PS " +
    "$ESC[38;5;33m" +
    @@ -17,5 +54,9 @@ function global:prompt {
    "$ESC[38;5;214m" +
    ("$pwd").Replace("$home", "~") +
    "$ESC[0m" +
    (OnBranch) +
    (ViaNode) +
    (ViaRust) +
    "`n" +
    "> "
    }
  4. Piepmatz revised this gist Jun 20, 2020. 1 changed file with 1 addition and 0 deletions.
    1 change: 1 addition & 0 deletions prompt.ps1
    Original file line number Diff line number Diff line change
    @@ -12,6 +12,7 @@ function global:prompt {
    $env:UserName +
    "@" +
    $computerName +
    "$ESC[0m" +
    ":" +
    "$ESC[38;5;214m" +
    ("$pwd").Replace("$home", "~") +
  5. Piepmatz revised this gist Jun 20, 2020. No changes.
  6. Piepmatz created this gist Jun 20, 2020.
    20 changes: 20 additions & 0 deletions prompt.ps1
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,20 @@
    $ESC = [char]27

    switch ($env:ComputerName) {
    "TIMSYOGA" {$computerName = "TY"}
    "TIMSTOWER" {$computerName = "TT"}
    default {$computerName = $env:ComputerName}
    }

    function global:prompt {
    "PS " +
    "$ESC[38;5;33m" +
    $env:UserName +
    "@" +
    $computerName +
    ":" +
    "$ESC[38;5;214m" +
    ("$pwd").Replace("$home", "~") +
    "$ESC[0m" +
    "> "
    }