Skip to content

Instantly share code, notes, and snippets.

@gldraphael
Last active August 25, 2021 05:07
Show Gist options
  • Save gldraphael/5f2731964ad7777f5c142b7008df5b11 to your computer and use it in GitHub Desktop.
Save gldraphael/5f2731964ad7777f5c142b7008df5b11 to your computer and use it in GitHub Desktop.
dotfiles
# Prompt stuff
# ###############################################
# Import posh-git
Import-Module posh-git
# Update powershell prompt path color
$GitPromptSettings.DefaultPromptPath.ForegroundColor = [System.ConsoleColor]::Blue
# Setup starship
Invoke-Expression $(&starship init powershell)
$PromptScript = (Get-Item function:Prompt).ScriptBlock
function Prompt {
$PreservedExitStatus = $? # Before doing anything else, capture current $?
$CurrentWorkingDirectory = Split-Path -Path ((Get-Location).Path.Replace($Env:USERNAME, "~")) -Leaf
$Host.UI.RawUI.WindowTitle = "$CurrentWorkingDirectory" # Set Title
if ($? -ne $PreservedExitStatus) {
# Reset $? to False
# Write-Error "" -ErrorAction Ignore # Powershell 7+
# Source: https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_automatic_variables?view=powershell-7.1#section-1
cmd.exe /c "exit 1" # Hack for Powershell < 7
# Source: https://stackoverflow.com/questions/10666035/difference-between-and-lastexitcode-in-powershell
}
Invoke-Command $PromptScript
}
# Auto-completions
# # #################################################
Invoke-Expression -Command $(gh completion -s powershell | Out-String)
# Path
# #################################################
$Env:Path += ";${HOME}\\.bin"
# Other env variables
# #################################################
$Env:DOTNET_CLI_TELEMETRY_OPTOUT=1
# $Env:GIT_EDITOR=nvim # causes powershell to not start.. it hangs indefinitely...
# Create aliases for ssh-ing into VMs
# #################################################
# Foo VM
function sshfoo { ssh user@1.1.1.1 -A }
add_newline = false
[directory]
style = "bold blue"
[character]
success_symbol = "[❯](bold blue) "
error_symbol = "[❯](bold red) "
vicmd_symbol = "[❮](bold blue) "
[git_branch]
format = "[on](cyan) [$symbol$branch]($style) "
style = "bold yellow"
[cmd_duration]
min_time = 30_000
[aws]
disabled = true
[battery]
disabled = true
[cmake]
disabled = true
[conda]
disabled = true
[crystal]
disabled = true
[dark]
disabled = true
[docker_context]
disabled = true
[dotnet]
disabled = true
[elixir]
disabled = true
[elm]
disabled = true
[env_var]
disabled = true
[erlang]
disabled = true
[gcloud]
disabled = true
[julia]
disabled = true
[kotlin]
disabled = true
[kubernetes]
disabled = true
[line_break]
disabled = true
[lua]
disabled = true
[memory_usage]
disabled = true
[hg_branch]
disabled = true
[nim]
disabled = true
[openstack]
disabled = true
[purescript]
disabled = true
[ruby]
disabled = true
[shlvl]
disabled = true
[singularity]
disabled = true
[status]
disabled = true
[swift]
disabled = true
[time]
disabled = true
[nodejs]
disabled = true
[php]
disabled = true
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment