Skip to content

Instantly share code, notes, and snippets.

@VictoriaVasys
Last active April 21, 2017 02:29
Show Gist options
  • Save VictoriaVasys/80a72b6399a6f3a8148d8bfff1e8eb2e to your computer and use it in GitHub Desktop.
Save VictoriaVasys/80a72b6399a6f3a8148d8bfff1e8eb2e to your computer and use it in GitHub Desktop.

A very abbreviated walkthrough to fix up your .bashrc and make your command line look SNAZZay :)

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.

  1. open your bash_profile atom ~/.bash_profile
  2. 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
  1. Open your .bashrc atom ~/.bashrc
  2. Enter code you had in your .bash_profile & code from the next steps straight into your .bashrc
  3. 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
  1. 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"
  1. 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)

  1. 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"
  1. Install bash-completion https://gist.github.com/trey/2722934
brew install git bash-completion
  1. Source your .bash_profile & .bashrc
source ~/.bash_profile
source ~/.bashrc
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment