Skip to content

Instantly share code, notes, and snippets.

@zymr-keshav
Created October 26, 2017 11:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zymr-keshav/7c395d3c9f5489eb32a6dd10741239a1 to your computer and use it in GitHub Desktop.
Save zymr-keshav/7c395d3c9f5489eb32a6dd10741239a1 to your computer and use it in GitHub Desktop.
bash profile for mac OS X which have git branch name and colored terminal and useful alias
# git branch in prompt
parse_git_branch() {
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ (\1)/'
}
RED="\[\033[0;31m\]"
YELLOW="\[\033[1;33m\]"
GREEN="\[\033[0;32m\]"
BLUE="\[\033[1;34m\]"
LIGHT_RED="\[\033[1;31m\]"
LIGHT_GREEN="\[\033[1;32m\]"
WHITE="\[\033[1;37m\]"
LIGHT_GRAY="\[\033[0;37m\]"
COLOR_NONE="\[\e[0m\]"
export PS1="${GREEN}\u@${YELLOW}\h:${LIGHT_RED}\w${LIGHT_GREEN}\$(parse_git_branch)${WHITE} $ "
if [ -f ~/.git-completion.bash ]; then
. ~/.git-completion.bash
fi
export CLICOLOR=1
export LSCOLORS=ExFxBxDxCxegedabagacad
alias ls='ls -GFh'
export NVM_DIR="/Users/keshav.m/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh" # This loads nvm
alias cp='cp -iv' # Preferred 'cp' implementation
alias mv='mv -iv' # Preferred 'mv' implementation
alias mkdir='mkdir -pv' # Preferred 'mkdir' implementation
alias ls='ls -GFh'
alias ll='ls -Fla' # Preferred 'ls' implementation
alias less='less -FSRXc' # Preferred 'less' implementation
# cd() { builtin cd "$@"; ll; } # Always list directory contents upon 'cd'
alias cd..='cd ../' # Go back 1 directory level (for fast typers)
alias ..='cd ../' # Go back 1 directory level
alias edit='subl' # edit: Opens any file in sublime editor
alias f='open -a Finder ./' # f: Opens current directory in MacOS Finder
alias ~="cd ~" # ~: Go Home
alias c='clear'
alias qfind="find . -name " # qfind: Quickly search for file
ff () { /usr/bin/find . -name "$@" ; } # ff: Find file under the current directory
ffs () { /usr/bin/find . -name "$@"'*' ; } # ffs: Find file whose name starts with a given string
ffe () { /usr/bin/find . -name '*'"$@" ; } # ffe: Find file whose name ends with a given string
alias psgrep='ps aux | grep '
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment