Created
March 29, 2021 19:36
-
-
Save mbrowniebytes/098d3eae919b4b8065d8556f21dc807e to your computer and use it in GitHub Desktop.
Configure your bash profile for git
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
# change me vars | |
ec2_name="ec2namechangeme" | |
# use vim | |
export EDITOR=vim | |
alias vi="vim" | |
# allow tab auto complete w/ sudo | |
if [[ "$HOME" == "/home/ec2-user" ]]; then | |
complete -cf sudo | |
fi | |
# git status | |
git_status="n" | |
# existing git file in most distros | |
git_prompt=/usr/share/git-core/contrib/completion/git-prompt.sh | |
if [[ -f $git_prompt ]]; then | |
source $git_prompt | |
export GIT_PS1_SHOWDIRTYSTATE=true # + staged, * unstaged | |
export GIT_PS1_SHOWUNTRACKEDFILES=true # % untracked files | |
export GIT_PS1_SHOWUPSTREAM="auto" # < behind, > ahead, <> diverged, = no difference | |
export GIT_PS1_SHOWSTASHSTATE=true # $ something is stashed | |
git_status="y" | |
fi | |
unset git_prompt | |
# export PS1="[\u@\h \W]\$" # default | |
PS1="\u@${ec2_name} " | |
PS1+="\[\033[01;34m\]\${PWD#\$HOME/}\[\033[00m\]" | |
if [ $git_status = "y" ]; then | |
PS1+=" \[\033[0;32m\]\$(__git_ps1 '\''(%s)'\'')\[\033[00m\]" | |
fi | |
PS1+="\n\[\033[0;32m\]└─►\[\033[00m\] " | |
export PS1 | |
PATH=$PATH:$HOME/bin:/usr/bin:/usr/local/bin | |
export PATH | |
unset USERNAME | |
alias git-log="git log --pretty=oneline" | |
alias git-preview-files="git fetch; git diff --name-only HEAD..@{u}" | |
alias git-preview-diff="git fetch; git diff HEAD..@{u}" | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
To change the bash prompt on your AWS EC2 instance from the default of
[ec2-user@ip-10-1-1-1 ~]$
to
ec2-user@ec2-name /data/cool-app (development=)
└─►
Add as temp_bash_profile.sh
Note, ''' = '
Update ec2_name="ec2name" to the name of your ec2 ie super-cool-service
Append to existing bash profile
using sed
or edit and add to the end
Test and see results
ec2-user@ec2-name /data/cool-app (development=)
└─►