For a more thorough walkthrough, see Josh T's gist: https://gist.github.com/josh-works/7f2e6c82d22dca6e9fbc029c8b17703d
First off, we're editing our .bashrc rather than our .bash_profile. (Josh sent me this article which gives a great explanation on why). But before we do, we have to link it to run in our .bash_profile.
- open your bash_profile
atom ~/.bash_profile
- Copy & paste the code below. This should be the only thing in your bash_profile (if you have aliases and other things you want to keep in there, cut & paste them into your .bashrc in step 4.)
[[ -s "$HOME/.profile" ]] && source "$HOME/.profile" # Load the default .profile
[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" # Load RVM into a shell session *as a function*
if [ -f ~/.bashrc ]; then
source ~/.bashrc
fi
- Open your .bashrc
atom ~/.bashrc
- Enter code you had in your .bash_profile & code from the next steps straight into your .bashrc
- This is the code that will show & colorize both your current folder & current git branch(when applicaple) in your PS1:
## Git configuration
# Branch name in prompt
source ~/.git-prompt.sh
# Tab completion for branch names
source ~/.git-completion.bash
## color & Git input
e=$'\e'
COLORreddish="$e[0;35m"
PS1='$COLORreddish[\W$(__git_ps1 " (%s)")]\⚡ \[\e[m\]'
export PROMPT_COMMAND='echo -ne "\033]0;${PWD/#$HOME/~}\007"'
export HISTCONTROL=ignoreboth:erasedups
- Aliases for git shortcuts:
# shortcuts for git
alias ga="git add"
alias gb="git branch"
alias gd="git diff --patience --ignore-space-change"
alias gl="git log --pretty=format:\"%Cgreen%h%Creset %Cblue%ad%Creset %s%C(yellow)%d%Creset %Cblue[%an]%Creset\" --graph --date=short"
alias gc="git checkout"
alias gs="git status"
- Aliases for directories and listing
alias m1="cd ~/turing/1module"
alias pre="cd ~/turing/prework"
alias ll='ls -al' # shows all files & directories incl. dot files in alphabetical order
alias ls="ls -lahG" # same as above but also display sizes in human-readable form & exclude "group information" (not sure -h & -G are necessary, but this is what Josh uses)
alias lr='ls -hartGl' # shows all files & directories in last-updated order with most-recent at the bottom
Here's a great website for figuring out the ls commands: http://linuxcommand.org/man_pages/ls1.html (or use your tldr or man command)
- Other things people have recommended:
# Set CLICOLOR if you want Ansi Colors in iTerm2
export CLICOLOR=1
# Set colors to match iTerm2 Terminal Colors
export TERM=xterm-256color
export LSCOLORS=ExFxBxDxCxegedabagacad
export EDITOR='/usr/local/bin/code'
export CC=/usr/local/bin/gcc-4.2
# export PS1="\W \[\033[0;33m\]⚡\[\033[0;39m\] "
# path goodies (from Josh)
export NVM_DIR="/Users/as.in.victory/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh" # This loads nvm
export PATH="$PATH:$HOME/.rvm/bin" # Add RVM to PATH for scripting
source ~/.rvm/scripts/rvm
## Wrap git automatically in `hub`
eval "$(hub alias -s)"
# programs that launch editors (e.g. git) will use Atom
export EDITOR="code -w"
- Install bash-completion https://gist.github.com/trey/2722934
brew install git bash-completion
- Source your .bash_profile & .bashrc
source ~/.bash_profile
source ~/.bashrc