Skip to content

Instantly share code, notes, and snippets.

@willsantos
Last active August 14, 2024 15:18
Show Gist options
  • Save willsantos/20b8710f48c4c9d476f11b84eae9bbfa to your computer and use it in GitHub Desktop.
Save willsantos/20b8710f48c4c9d476f11b84eae9bbfa to your computer and use it in GitHub Desktop.
Config basica do Powershell

Profile

#Alias
new-alias rename rename-item
new-alias lsa get-childitem

# Shows navigable menu of all options when hitting Tab
Set-PSReadlineKeyHandler -Key Tab -Function MenuComplete

# Autocompletion for arrow keys
Set-PSReadlineKeyHandler -Key UpArrow -Function HistorySearchBackward
Set-PSReadlineKeyHandler -Key DownArrow -Function HistorySearchForward

Clear-Host

Exibir a branch

function prompt {
    # Define as cores usando sequências de escape ANSI
    $green = "`e[32m"  # Verde
    $yellow = "`e[33m"  # Amarelo
    $reset = "`e[0m"   # Resetar cor

    # Obtem o nome da branch atual
    $gitBranch = & git rev-parse --abbrev-ref HEAD 2>$null

    # Verifica se o HEAD está desvinculado ou se está em uma branch
    if ($gitBranch -eq 'HEAD') {
        $branchIndicator = "$yellow(Detached HEAD)$reset"
    } elseif ($gitBranch) {
        $branchIndicator = "$green($gitBranch)$reset"
    } else {
        $branchIndicator = ""
    }

    # Exibe o prompt com o diretório atual e a branch colorida
    "$PWD $branchIndicator> "
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment