Skip to content

Instantly share code, notes, and snippets.

@rmacfie
Last active October 4, 2019 11:14
Show Gist options
  • Save rmacfie/442247d1180770a21ab71ec76c9cfd2c to your computer and use it in GitHub Desktop.
Save rmacfie/442247d1180770a21ab71ec76c9cfd2c to your computer and use it in GitHub Desktop.
# bash completion
export BASH_COMPLETION_COMPAT_DIR="/usr/local/etc/bash_completion.d"
[[ -r "/usr/local/etc/profile.d/bash_completion.sh" ]] && . "/usr/local/etc/profile.d/bash_completion.sh"
# nvm
export NVM_DIR="$HOME/.nvm"
[ -s "/usr/local/opt/nvm/nvm.sh" ] && . "/usr/local/opt/nvm/nvm.sh"
[ -s "/usr/local/opt/nvm/etc/bash_completion" ] && . "/usr/local/opt/nvm/etc/bash_completion"
# git
export GIT_PS1_SHOWDIRTYSTATE=1
export GIT_PS1_SHOWUNTRACKEDFILES=1
alias git='LANG=en_US.UTF-8 git'
# gcloud
source '/usr/local/Caskroom/google-cloud-sdk/latest/google-cloud-sdk/path.bash.inc'
source '/usr/local/Caskroom/google-cloud-sdk/latest/google-cloud-sdk/completion.bash.inc'
source <(kubectl completion bash)
# custom prompt
function __prompt_command {
local EXIT="$?"
PS1=""
local Reset='\[$(tput sgr0)\]'
local Gray1='\[$(tput setaf 248)\]'
local Gray2='\[$(tput setaf 238)\]'
local Green='\[$(tput setaf 40)\]'
local Red='\[$(tput setaf 196)\]'
local Status="${Green}"
if [ $EXIT != 0 ]; then
Status="${Red}"
fi
PS1+="\n${Status}= ${Gray1}\u${Gray2}@${Gray1}\h \w${Reset}"
PS1+=" `__git_ps1 "${Gray2}(${Gray1}%s${Gray2})${Reset}"`"
PS1+="\n${Gray2}\$ ${Reset}"
}
PROMPT_COMMAND=__prompt_command
# git
export GIT_PS1_SHOWDIRTYSTATE=1
export GIT_PS1_SHOWUNTRACKEDFILES=1
alias git='LANG=en_US.UTF-8 git'
# custom prompt
function __prompt_command {
local EXIT="$?"
PS1=""
local Reset="\033[m"
local Gray1="${Reset}\033[1;30m"
local Gray2="${Reset}\033[37m"
local Green="${Reset}\033[32m"
local Red="${Reset}\033[31m"
local Status="${Green}"
if [ $EXIT != 0 ]; then
Status="${Red}"
fi
PS1+="\n${Status}= ${Gray1}\u${Gray2}@${Gray1}\h \w${Reset}"
PS1+=" `__git_ps1 "${Gray2}(${Gray1}${Reset}%s${Gray2})${Reset}"`"
PS1+="\n${Gray2}$ ${Reset}"
}
PROMPT_COMMAND=__prompt_command
Function Prompt {
$__lastOK = $?
$__lastCode = $Global:LASTEXITCODE
Write-Host ""
if ($__lastCode -eq 0) {
Write-Host "= " -NoNewline -ForegroundColor Green
} elseif ($__lastOK -eq $false) {
Write-Host "= " -NoNewline -ForegroundColor Red
} else {
Write-Host "= " -NoNewline -ForegroundColor Gray
}
Write-Host "$($Env:USERNAME)" -NoNewline -ForegroundColor DarkGray
Write-Host "@" -NoNewline -ForegroundColor Gray
Write-Host "$($Env:COMPUTERNAME.ToLowerInvariant())" -NoNewline -ForegroundColor DarkGray
Write-Host " $(Get-Location)" -ForegroundColor DarkGray
Write-Host "$('>' * ($NestedPromptLevel + 1))" -NoNewline -ForegroundColor Gray
$Global:LASTEXITCODE = $__lastCode
return " "
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment