Created
March 8, 2021 18:12
-
-
Save mattmoor/5bc306992a0395dd2e2fcd785d8395e9 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
source /Library/Developer/CommandLineTools/usr/share/git-core/git-completion.bash | |
gitp () { | |
# Get the target of a file rename | |
git status -s . | grep "^R " | cut -d'>' -f 2 | |
# Open added or modified files, staged or not. | |
git status -s . | grep -vE "^ ?[DR?]" | sed 's/^...//g' | |
# The old... | |
# git status . | grep renamed | cut -d'>' -f 2 | |
# git status . | grep -vE "deleted|renamed" | grep : | cut -d':' -f 2 | |
} | |
e () { | |
emacsclient -a $XEMACS --no-wait $* > /dev/null 2>&1 & | |
} | |
gimacs () { | |
e $(gitp) | |
} | |
grit () { | |
grep $* $(gitp) | |
} | |
export XEMACS=/Applications/Emacs.app/Contents/MacOS/Emacs-x86_64-10_14 | |
export HISTSIZE=10000 | |
export GOPATH=/Users/mattmoor/go | |
export PATH=/usr/local/opt/gnu-sed/libexec/gnubin:/usr/local/bin:$PATH:$GOPATH/bin:~/bin | |
export YOUR_GITHUB_USERNAME=$USER | |
export EDITOR="emacsclient -a $XEMACS" | |
export KO_DOCKER_REPO=gcr.io/mattmoor-knative | |
# The next line updates PATH for the Google Cloud SDK. | |
if [ -f '/Users/mattmoor/google-cloud-sdk/path.bash.inc' ]; then . '/Users/mattmoor/google-cloud-sdk/path.bash.inc'; fi | |
# The next line enables shell command completion for gcloud. | |
if [ -f '/Users/mattmoor/google-cloud-sdk/completion.bash.inc' ]; then . '/Users/mattmoor/google-cloud-sdk/completion.bash.inc'; fi | |
# Helper for exec'ing bash in a pod. | |
ke() { | |
kubectl exec -ti "$1" /bin/bash | |
} | |
alias k=kubectl | |
__branch() { | |
$(git branch > /dev/null 2>&1) | |
if [[ $? != 0 ]]; then | |
return | |
fi | |
echo -n "$(git branch | grep \* | cut -d ' ' -f2) @ " | |
} | |
__prompt_command() { | |
PS1="" | |
local RCol='\[\e[0m\]' | |
local Red='\[\e[0;31m\]' | |
local Gre='\[\e[0;32m\]' | |
local BYel='\[\e[1;33m\]' | |
local Cyan='\[\e[1;36m\]' | |
local Pur='\[\e[0;35m\]' | |
# TODO(mattmoor): If we are on GOPATH, then colorize things and show the relative import path. | |
PS1+="${RCol}${Cyan}\$(__branch)${BYel}\${PWD#\$GOPATH/src/}${RCol}\n" | |
# Show the current kubectl context | |
PS1+="${RCol}${Pur}\$(kubectl config current-context)${RCol} " | |
PS1+="\$(if [[ \$? == 0 ]]; then echo \"${Gre}\"; else echo \"${Red}\$?\"; fi)> ${RCol}" | |
} | |
__prompt_command |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment