Skip to content

Instantly share code, notes, and snippets.

@ellimist
Created August 9, 2016 21:20
Show Gist options
  • Save ellimist/62a3a2e9dd0296cb6bd84aa309c9db1b to your computer and use it in GitHub Desktop.
Save ellimist/62a3a2e9dd0296cb6bd84aa309c9db1b to your computer and use it in GitHub Desktop.
# Path to your oh-my-zsh installation.
export ZSH=/Users/dev/.oh-my-zsh
ZSH_THEME="sorin"
plugins=(git zsh-autosuggestions docker docker-compose golang)
source $ZSH/oh-my-zsh.sh
export GOPATH=$HOME/Repos/go
export PATH="$HOME/.rbenv/bin:$PATH"
export PATH=$PATH:/usr/local/go/bin:$GOPATH/bin
# Preferred editor for local and remote sessions
if [[ -n $SSH_CONNECTION ]]; then
export EDITOR='vim'
else
export EDITOR='nvim'
fi
# Config aliases
alias zshconfig="nvim ~/.zshrc"
alias ohmyzsh="nvim ~/.oh-my-zsh"
alias vimconfig="vim ~/.vimrc"
alias reload="source ~/.zshrc"
alias cl="clear"
alias vim="nvim"
alias :q="exit"
# Git aliases
alias gitD="git fetch; git rebase origin/development; git push origin HEAD:refs/for/development; echo 'DONE';"
alias glog="git log --graph --abbrev-commit --decorate --date=relative --format=format:'%C(bold blue)%h%C(reset) - %C(bold green)(%ar)%C(reset) %C(white)%s%C(reset) %C(dim white)- %an%C(reset)%C(bold yellow)%d%C(reset)' --all"
alias gs='git status'
alias ga='git add .'
alias gd='git diff'
# Mysql apache aliases
alias mysql.start="mysql.server start"
alias mysql.stop="mysql.server stop"
alias apache.start="sudo apachectl start"
alias apache.stop="sudo apachectl stop"
alias apache.restart="sudo apachectl restart"
alias prettyjson='python -m json.tool'
# Misc aliases
alias _='sudo'
alias please='sudo'
# Common shell functions
alias less='less -r'
alias tf='tail -f'
alias lh='ls -alt | head' # see the last modified files
# List only directories
alias lsd="ls -lF ${colorflag} | grep --color=never '^d'"
# Enable aliases to be sudo’ed
alias sudo='sudo '
# Reload the shell (i.e. invoke as a login shell)
alias reload="exec $SHELL -l"
# Functions
#
# Create a new directory and enter it
function mkd() {
mkdir -p "$@" && cd "$_";
}
# Syntax-highlight JSON strings or files
# Usage: `json '{"foo":42}'` or `echo '{"foo":42}' | json`
function json() {
if [ -t 0 ]; then # argument
python -mjson.tool <<< "$*" | pygmentize -l javascript;
else # pipe
python -mjson.tool | pygmentize -l javascript;
fi;
}
# Run `dig` and display the most useful info
function digga() {
dig +nocmd "$1" any +multiline +noall +answer;
}
# `tre` is a shorthand for `tree` with hidden files and color enabled, ignoring
# the `.git` directory, listing directories first. The output gets piped into
# `less` with options to preserve color and line numbers, unless the output is
# small enough for one screen.
function tre() {
tree -aC -I '.git|node_modules|bower_components' --dirsfirst "$@" | less -FRNX;
}
# Init rbenv
eval "$(rbenv init -)"
# Add iterm2 shell integrations
test -e "${HOME}/.iterm2_shell_integration.zsh" && source "${HOME}/.iterm2_shell_integration.zsh"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment