Created
May 31, 2020 19:47
-
-
Save jerm/1dcaf2ce693f119712b5c0c1eef254ae 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
# Git prompt stuff | |
echo .profile | |
__git_ps1(){ | |
(:) | |
} | |
#[ -f ~/.git-completion.bash ] && source ~/.git-completion.bash | |
#[ -f ~/.git-config.bash ] && source ~/.git-config.bash | |
# Activate git completion and prompt functions. My Linux has these built-in in | |
# /etc/bash_completion.d/git | |
# On OSX I'm using homebrew where they can be found as below. | |
if [ "$(uname)" = "Darwin" ]; then | |
# bash 4 completion | |
if [ ${BASH_VERSINFO[0]} -eq '4' ]; then | |
[ -f /usr/local/etc/bash_completion ] && . /usr/local/etc/bash_completion | |
elif [ ${BASH_VERSINFO[0]} -eq '3' ]; then | |
[ -f /usr/local/git/contrib/completion/git-prompt.sh ] && source /usr/local/git/contrib/completion/git-prompt.sh | |
[ -f /usr/local/git/contrib/completion/git-prompt.sh ] && source /usr/local/git/contrib/completion/git-completion.bash | |
[ -f /usr/local/etc/bash_completion.d/git-completion.bash ] && source /usr/local/etc/bash_completion.d/git-completion.bash | |
[ -f /usr/local/etc/bash_completion.d/git-prompt.sh ] && source /usr/local/etc/bash_completion.d/git-prompt.sh | |
fi | |
export NVM_DIR="$HOME/.nvm" | |
#. "$(brew --prefix nvm)/nvm.sh" | |
alias ls='ls -G' | |
fi | |
# MCP Control Prompt (MCP) - See all the things! | |
# -- because I'm not cool enough to use only $ or # effectively | |
# | |
# Copy, right? 2014 Jeremy Price - @jermops | |
# | |
# v1.0 | |
PROD_HOST_TRIGGER='prod' | |
PROD_HOST_COLOR=31 | |
NORMAL_HOST_COLOR=33 | |
ALERT_USER_NAME='root' | |
ALERT_USER_COLOR=31 | |
NORMAL_USER_COLOR=32 | |
#functinon to allow dynamic boto env in prompt | |
_boto_env(){ | |
if [ -n "$AWS_PROFILE" ]; then | |
echo "aws-$AWS_PROFILE" | |
else | |
echo -n "aws-default" | |
fi | |
} | |
#Jeremy's time-telling, response-code watching, boto-env telling, git-laden, path showinge shell prompt | |
case "$TERM" in | |
xterm*|rxvt*|screen*|linux) | |
# Decide username and servername colors | |
if [[ "$(hostname)" =~ $PROD_HOST_TRIGGER ]]; then HCOLOR=$PROD_HOST_COLOR; else HCOLOR=$NORMAL_HOST_COLOR; fi | |
if [[ "$USER" =~ $ALERT_USER_NAME ]]; then UCOLOR=$ALERT_USER_COLOR; else UCOLOR=$NORMAL_USER_COLOR; fi | |
#Set up the bottom line with user@host:commandnum:$path | |
PS1='\[\033[01;${UCOLOR}m\]\u@\[\033[01;${HCOLOR}m\]\h\[\033[00m\]:\!:\[\033[00m\]\$ ' | |
#Populate the iTerm, Xterm, Eterm, etc... tab/title bar with current user and hostname | |
PS1="\[\e]0;\u@\h: \w\a\]$PS1" | |
# If we're using screen a compatible terminal, populate current tab | |
# with hostname | |
#[[ $TERM =~ "screen" ]] && | |
export PS1="\[\033k\033\134\033k\h\033\134\]$PS1" | |
# Add the top line with time, boto/aws env, path, git status, | |
# oh and make it red if the last command's return code is non-zero | |
PS1="\`if [[ \$? = "0" ]]; then echo "\\[\\033[37m\\]"; else echo "\\[\\033[31m\\]"; fi\`[\t]:\`_boto_env\`:\[\033[00;36m\]\w"'$(__git_ps1 " (git:%s)")\n'"$PS1" | |
;; | |
*) | |
;; | |
esac | |
# Larger bash history (default is 500) | |
export HISTFILESIZE=10000 | |
export HISTSIZE=10000 | |
#export HISTCONTROL="erasedups:ignoreboth" | |
export HISTCONTROL="ignoredups" | |
shopt -s histappend | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment