2015-07-07 22:39:55 +00:00
|
|
|
###
|
|
|
|
# .zshrc
|
|
|
|
#
|
|
|
|
# Kirsle's Global ZSH Configuration
|
|
|
|
###
|
|
|
|
|
2015-07-07 23:10:47 +00:00
|
|
|
export LANG=en_US.UTF-8 # Unicode
|
|
|
|
setopt prompt_subst # Allow for dynamic prompts
|
|
|
|
autoload -U colors && colors # Get color aliases
|
|
|
|
autoload -U compinit && compinit # Better tab completion
|
|
|
|
export HISTSIZE=2000 # History settings
|
|
|
|
export HISTFILE="$HOME/.history"
|
|
|
|
export SAVEHIST=$HISTSIZE
|
|
|
|
setopt hist_ignore_all_dups
|
|
|
|
setopt hist_ignore_space
|
2015-07-14 19:11:19 +00:00
|
|
|
setopt inc_append_history
|
2015-11-22 04:23:47 +00:00
|
|
|
setopt nobeep
|
2015-07-07 22:39:55 +00:00
|
|
|
|
|
|
|
# 256 colors
|
|
|
|
[[ "$TERM" == "xterm" ]] && export TERM=xterm-256color
|
|
|
|
|
2016-01-13 19:59:14 +00:00
|
|
|
# CLI colors under OS X for `ls`
|
|
|
|
if [[ `uname` == "Darwin" ]]; then
|
|
|
|
# Enable colors and set a similar scheme as on Linux (see `man ls`)
|
|
|
|
export CLICOLOR=1
|
|
|
|
export LSCOLORS="ExGxcxdxcxegedabagecec"
|
|
|
|
fi
|
|
|
|
|
2015-07-07 22:39:55 +00:00
|
|
|
# Normalize the PATH
|
2015-11-22 04:23:47 +00:00
|
|
|
CORE_PATH="/usr/sbin:/sbin:/usr/bin:/bin"
|
2017-01-11 18:40:10 +00:00
|
|
|
USR_PATH="/usr/local/sbin:/usr/local/bin:${HOME}/bin:${HOME}/go/bin:${HOME}/go/.ext/bin:${HOME}/android/sdk/platform-tools"
|
2015-11-22 04:23:47 +00:00
|
|
|
if [[ `uname` == "Linux" ]] then export PATH="${CORE_PATH}:${USR_PATH}"
|
|
|
|
else export PATH="${USR_PATH}:${CORE_PATH}"
|
|
|
|
fi
|
2015-07-07 22:39:55 +00:00
|
|
|
export EDITOR="/usr/bin/vim"
|
|
|
|
|
|
|
|
# Virtualenv
|
2015-07-28 19:07:51 +00:00
|
|
|
export WORKON_HOME=~/.virtualenvs
|
2015-07-07 22:39:55 +00:00
|
|
|
|
2015-10-20 03:56:09 +00:00
|
|
|
# Go
|
2017-01-11 18:40:10 +00:00
|
|
|
export GOPATH="$HOME/go/.ext:$HOME/go"
|
2015-10-20 03:56:09 +00:00
|
|
|
|
2016-03-18 17:37:21 +00:00
|
|
|
# Node/npm
|
2016-04-17 22:00:30 +00:00
|
|
|
if [[ ! -f "${HOME}/.npmrc" ]]; then
|
|
|
|
echo "prefix = ${HOME}/.npm-global-pkg" > $HOME/.npmrc
|
|
|
|
fi
|
2016-03-18 17:37:21 +00:00
|
|
|
export NPM_PACKAGES="${HOME}/.npm-global-pkg"
|
|
|
|
export NODE_PATH="${NPM_PACKAGES}/lib/node_modules:${NODE_PATH}"
|
|
|
|
export PATH="${NPM_PACKAGES}/bin:$PATH"
|
|
|
|
|
2016-06-06 17:07:40 +00:00
|
|
|
# Java
|
|
|
|
export CLASSPATH="$CLASSPATH:${HOME}/java"
|
|
|
|
|
2015-07-07 22:39:55 +00:00
|
|
|
# Reload zshrc
|
|
|
|
alias rezsh="source ${HOME}/.zshrc"
|
|
|
|
|
|
|
|
# Allow overriding hostname in the prompt from a local config
|
|
|
|
export PROMPT_HOSTNAME="%m"
|
|
|
|
|
|
|
|
# Source local (system specific) configurations
|
|
|
|
if [[ -f "${HOME}/.zshrc-local" ]]; then
|
|
|
|
source "${HOME}/.zshrc-local"
|
|
|
|
fi
|
|
|
|
|
|
|
|
###
|
|
|
|
# Base shell prompt.
|
|
|
|
###
|
|
|
|
|
|
|
|
# I slowly build the prompt up over multiple places and store it in
|
|
|
|
# in $base_prompt, so I can modify it before exporting it (for example,
|
|
|
|
# so the git branch appears before the % at the end of the prompt).
|
|
|
|
|
|
|
|
# For the color palette, see: http://www.pixelbeat.org/docs/terminal_colours/
|
|
|
|
# Use light shades of blue and pink.
|
|
|
|
local blue="%F{39}"
|
|
|
|
local pink="%F{213}"
|
|
|
|
local orange="%F{208}"
|
|
|
|
local lime="%F{46}"
|
|
|
|
local cyan="%F{51}"
|
|
|
|
local base_prompt="%{$blue%}[%{$pink%}%n%{$blue%}@%{$pink%}${PROMPT_HOSTNAME} %{$lime%}%1~"
|
|
|
|
|
|
|
|
###
|
|
|
|
# Include git branch in the prompt
|
|
|
|
###
|
|
|
|
|
|
|
|
git_branch() {
|
|
|
|
local res=`git branch 2>/dev/null | grep -v '^[^*]' | perl -pe 's/^\*\s+//g'`
|
|
|
|
if [[ "$res" != "" ]]; then
|
|
|
|
local res=" ($res)"
|
|
|
|
fi
|
|
|
|
echo $res
|
|
|
|
}
|
|
|
|
|
|
|
|
local git_prompt='%{$cyan%}$(git_branch)%{$reset_color%}'
|
|
|
|
local base_prompt="${base_prompt}${git_prompt}"
|
|
|
|
|
|
|
|
# End the base prompt
|
|
|
|
local base_prompt="${base_prompt}%{$blue%}]%# %{%f%}"
|
|
|
|
|
2015-07-07 23:10:47 +00:00
|
|
|
###
|
|
|
|
# Set terminal titles automatically
|
|
|
|
###
|
|
|
|
|
2016-03-11 19:33:00 +00:00
|
|
|
# allow resetting the terminal title like in DOS
|
|
|
|
function title {
|
|
|
|
export PROMPT_DOS_TITLE="$1"
|
|
|
|
}
|
|
|
|
|
2015-07-07 23:10:47 +00:00
|
|
|
precmd() {
|
2016-03-11 19:33:00 +00:00
|
|
|
if [ "$PROMPT_DOS_TITLE" != "" ]; then
|
|
|
|
print -Pn "\e]0;${PROMPT_DOS_TITLE}\a"
|
|
|
|
else
|
|
|
|
print -Pn "\e]0;%n@${PROMPT_HOSTNAME}:%~\a"
|
|
|
|
fi
|
2015-07-07 23:10:47 +00:00
|
|
|
}
|
|
|
|
|
2015-07-07 23:13:23 +00:00
|
|
|
###############################################################################
|
|
|
|
# Aliases and things #
|
|
|
|
###############################################################################
|
|
|
|
|
|
|
|
alias vi="vim"
|
|
|
|
alias grep="grep --exclude=min.js --color=auto"
|
|
|
|
alias ll="ls -l"
|
2016-03-18 17:37:21 +00:00
|
|
|
alias tojson="python -m json.tool" # JSON pretty print
|
2015-07-07 23:13:23 +00:00
|
|
|
|
2015-11-22 04:23:47 +00:00
|
|
|
if [[ `uname` == 'Linux' ]] then
|
|
|
|
alias ls="ls --color=auto"
|
|
|
|
fi
|
|
|
|
|
2016-01-20 00:14:02 +00:00
|
|
|
# `h` is a shortcut for `history 1` (show all history) or `history 1 | grep`
|
|
|
|
# example: `h ls` will do `history 1 | grep ls`
|
|
|
|
h() {
|
|
|
|
if [ -z "$*" ]; then
|
|
|
|
history 1;
|
|
|
|
else
|
|
|
|
history 1 | egrep "$@";
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2015-07-07 22:39:55 +00:00
|
|
|
###############################################################################
|
|
|
|
# zsh plugins #
|
|
|
|
###############################################################################
|
|
|
|
|
|
|
|
# Load zgen (plugin manager)
|
|
|
|
source "${HOME}/.dotfiles/zsh/zgen/zgen.zsh"
|
|
|
|
|
|
|
|
# Initialize zgen plugins
|
|
|
|
if ! zgen saved; then
|
|
|
|
echo "Creating a zgen save"
|
|
|
|
|
|
|
|
# Load plugins
|
|
|
|
zgen oh-my-zsh plugins/virtualenv
|
|
|
|
zgen oh-my-zsh plugins/virtualenvwrapper
|
2016-01-20 00:56:02 +00:00
|
|
|
zgen load zsh-users/zsh-syntax-highlighting
|
2015-07-07 22:39:55 +00:00
|
|
|
|
|
|
|
# Save all to the init script
|
|
|
|
zgen save
|
|
|
|
fi
|
|
|
|
|
|
|
|
###
|
|
|
|
# Configure plugin: virtualenvwrapper
|
|
|
|
###
|
|
|
|
|
|
|
|
# Virtualenv prompt. The dynamic part (name of the virtualenv) needs to
|
|
|
|
# recompute each time so we separate it out into a single-quoted variable.
|
|
|
|
# See: http://stackoverflow.com/questions/11877551/zsh-not-re-computing-my-shell-prompt
|
|
|
|
export ZSH_THEME_VIRTUALENV_PREFIX="("
|
|
|
|
export ZSH_THEME_VIRTUALENV_SUFFIX=")"
|
|
|
|
local virtualenv_prompt='%{$orange%}$(virtualenv_prompt_info)%{$reset_color%}'
|
|
|
|
local base_prompt="${virtualenv_prompt}${base_prompt}"
|
|
|
|
|
2016-01-20 00:56:02 +00:00
|
|
|
###
|
|
|
|
# Configure plugin: zsh-syntax-highlighting
|
|
|
|
###
|
|
|
|
|
|
|
|
typeset -A ZSH_HIGHLIGHT_STYLES
|
|
|
|
|
|
|
|
# I like blue instead of green as the base color for most things.
|
|
|
|
# 39 = light blue, 27 = darker blue
|
|
|
|
ZSH_HIGHLIGHT_STYLES[alias]=fg=39
|
|
|
|
ZSH_HIGHLIGHT_STYLES[suffix-alias]=fg=39,underline
|
|
|
|
ZSH_HIGHLIGHT_STYLES[builtin]=fg=39
|
|
|
|
ZSH_HIGHLIGHT_STYLES[function]=fg=39
|
|
|
|
ZSH_HIGHLIGHT_STYLES[command]=fg=39
|
|
|
|
ZSH_HIGHLIGHT_STYLES[precommand]=fg=39,underline
|
|
|
|
ZSH_HIGHLIGHT_STYLES[hashed-command]=fg=39
|
|
|
|
ZSH_HIGHLIGHT_STYLES[globbing]=fg=green
|
|
|
|
|
|
|
|
# Highlight command line flags too.
|
|
|
|
ZSH_HIGHLIGHT_STYLES[single-hyphen-option]=fg=27
|
|
|
|
ZSH_HIGHLIGHT_STYLES[double-hyphen-option]=fg=27
|
|
|
|
|
2015-07-07 22:39:55 +00:00
|
|
|
# Finalize and export the prompt
|
|
|
|
export PROMPT=$base_prompt
|
2016-06-16 18:24:19 +00:00
|
|
|
|
|
|
|
###
|
|
|
|
# Import common functions (bash/zsh)
|
|
|
|
###
|
|
|
|
|
|
|
|
. ~/.common.sh
|