Skip to content

Instantly share code, notes, and snippets.

@kevonc
Last active April 24, 2016 13:52
Show Gist options
  • Save kevonc/8016069 to your computer and use it in GitHub Desktop.
Save kevonc/8016069 to your computer and use it in GitHub Desktop.
To pretty up the terminal prompt, edit ~/.bash_profile.
# Change from zsh to bash
chsh
change /bin/zsh to /bin/bash
# .bash_profile
# Exports
# =======
# Make sublime our editor of choice
export EDITOR="subl -w"
# Make some commands not show up in history
export HISTIGNORE="ls:ls *:cd:cd -:pwd;exit:date:* --help"
# Add colors to LS
# http://geoff.greer.fm/lscolors/
export CLICOLOR=1
export LSCOLORS=fxexcxdxbxegedabagacad
# Tab improvements
bind 'set completion-ignore-case on'
bind 'set show-all-if-ambiguous on'
bind 'TAB: menu-complete'
# Aliases
# Clear Console
alias c='clear'
# List files in long list format including hidden files
alias ll='ls -la'
# Go back one directory
alias b='cd ..'
alias h='history'
alias s='cd ~/sites'
alias dnsflush="sudo killall -HUP mDNSResponder"
# Git
# ===
# Paste this into terminal to turn on git colors.
# git config --global color.ui true
# Fastest possible way to check if repo is dirty.
function parse_git_dirty() {
git diff --quiet --ignore-submodules HEAD 2>/dev/null; [ $? -eq 1 ] && echo '*'
}
function parse_git_branch() {
git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e "s/* \(.*\)/\1$(parse_git_dirty)/"
}
# Prompt
# ======
echo "----------------------------------------------------------------"
echo "$(git --version)"
echo "$(ruby -v)"
echo "$(rails -v)"
echo "----------------------------------------------------------------"
# Colors
BLACK='\e[0;30m'
BLUE='\e[0;34m'
GREEN='\e[0;32m'
CYAN='\e[0;36m'
RED='\e[0;31m'
PURPLE='\e[0;35m'
BROWN='\e[0;33m'
GRAY='\e[0;37m'
DARK_GRAY='\e[1;30m'
LIGHT_BLUE='\e[1;34m'
LIGHT_GREEN='\e[1;32m'
LIGHT_CYAN='\e[1;36m'
LIGHT_RED='\e[1;31m'
LIGHT_PURPLE='\e[1;35m'
YELLOW='\e[1;33m'
WHITE='\e[1;37m'
# https://dougbarton.us/Bash/Bash-prompts.html
PS1="\[$GREEN\]\w\[$WHITE\]\$([[ -n \$(git branch 2> /dev/null) ]] && echo \" on \")\[$LIGHT_PURPLE\]\$(parse_git_branch)\[$WHITE\]\n\$ \[$RESET\]"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment