Skip to content

Instantly share code, notes, and snippets.

@jalberto
Last active August 29, 2015 14:09
Show Gist options
  • Save jalberto/9cf3355bace3ab829369 to your computer and use it in GitHub Desktop.
Save jalberto/9cf3355bace3ab829369 to your computer and use it in GitHub Desktop.
My ZSH config
#
# Sets Prezto options.
#
# Authors:
# Sorin Ionescu <[email protected]>
#
#
# General
#
# Set case-sensitivity for completion, history lookup, etc.
# zstyle ':prezto:*:*' case-sensitive 'yes'
# Color output (auto set to 'no' on dumb terminals).
zstyle ':prezto:*:*' color 'yes'
# Set the Zsh modules to load (man zshmodules).
zstyle ':prezto:load' zmodule 'attr' 'stat'
# Set the Zsh functions to load (man zshcontrib).
zstyle ':prezto:load' zfunction 'zargs' 'zmv'
# Set the Prezto modules to load (browse modules).
# The order matters.
zstyle ':prezto:load' pmodule \
'utility' \
'environment' \
'terminal' \
'editor' \
'history' \
'directory' \
'spectrum' \
'completion' \
'archive' \
'fasd' \
'ssh' \
'yum' \
'ruby' \
'rails' \
'git' \
'syntax-highlighting' \
'history-substring-search' \
'prompt'
#
# Editor
#
# Set the key mapping style to 'emacs' or 'vi'.
zstyle ':prezto:module:editor' key-bindings 'vi'
# Auto convert .... to ../..
zstyle ':prezto:module:editor' dot-expansion 'yes'
#
# Git
#
# Ignore submodules when they are 'dirty', 'untracked', 'all', or 'none'.
zstyle ':prezto:module:git:status:ignore' submodules 'all'
#
# GNU Utility
#
# Set the command prefix on non-GNU systems.
# zstyle ':prezto:module:gnu-utility' prefix 'g'
#
# History Substring Search
#
#
# Prompt
#
# Set the prompt theme to load.
# Setting it to 'random' loads a random theme.
# Auto set to 'off' on dumb terminals.
zstyle ':prezto:module:prompt' theme 'smiley'
#
# Ruby
#
# Auto switch the Ruby version on directory change.
zstyle ':prezto:module:ruby:rvm' auto-switch 'yes'
zstyle ':prezto:module:ruby:info:version' format 'version:%v'
#
# SSH
#
# Set the SSH identities to load into the agent.
# zstyle ':prezto:module:ssh:load' identities 'id_rsa' 'id_rsa2' 'id_github'
#
# Syntax Highlighting
#
# Set syntax highlighters.
# By default, only the main highlighter is enabled.
zstyle ':prezto:module:syntax-highlighting' highlighters \
'main' \
'brackets' \
'pattern' \
'cursor' \
'root'
#
#
# Terminal
#
# Auto set the tab and window titles.
zstyle ':prezto:module:terminal' auto-title 'yes'
# Set the window title format.
zstyle ':prezto:module:terminal:window-title' format '%n@%m: %s'
# Set the tab title format.
zstyle ':prezto:module:terminal:tab-title' format '%m: %s'
#
# Tmux
#
# Auto start a session when Zsh is launched in a local terminal.
# zstyle ':prezto:module:tmux:auto-start' local 'yes'
# Auto start a session when Zsh is launched in a SSH connection.
# zstyle ':prezto:module:tmux:auto-start' remote 'yes'
# Path {{{
if [[ -d "$HOME/local/bin" ]] ; then
export PATH=$PATH:$HOME/local/bin
fi
# if [[ -d "/opt/android-sdk" ]]; then
# export PATH="/opt/android-sdk:/opt/android-sdk/tools:$PATH"
# fi
# if [[ -d "$HOME/node_modules/coffee-script/bin" ]]; then
# export PATH="$HOME/node_modules/coffee-script/bin:$PATH"
# fi
if [[ -d "$HOME/local/bin" ]] ; then
export PATH="/usr/local/heroku/bin:$PATH"
fi
export PATH=$PATH:$HOME/.rvm/bin # Add RVM to PATH for scriptin
# }}}
# Source Prezto.
if [[ -s "${ZDOTDIR:-$HOME}/.zprezto/init.zsh" ]]; then
source "${ZDOTDIR:-$HOME}/.zprezto/init.zsh"
fi
# Customize to your needs...
# 10 second wait if you do something that will delete everything
setopt RM_STAR_WAIT
# Case insensitive globbing
setopt NO_CASE_GLOB
# Who doesn't want home and end to work?
bindkey '\e[1~' beginning-of-line
bindkey '\e[4~' end-of-line
# Incremental search is elite!
bindkey -M vicmd "/" history-incremental-search-backward
bindkey -M vicmd "?" history-incremental-search-forward
# it's like, space AND completion. Gnarlbot.
bindkey -M viins ' ' magic-space
# Search based on what you typed in already
bindkey -M vicmd "//" history-beginning-search-backward
bindkey -M vicmd "??" history-beginning-search-forward
export HISTSIZE=2000
export QMAKE=/usr/bin/qmake-qt4
export JAVA_HOME="/usr/java/latest"
# Change delay for vi mode
export KEYTIMEOUT=1
# Set Ctrl-R for search
bindkey '\e[3~' delete-char
bindkey '^r' history-incremental-search-backward
export EDITOR="vi"
# Rails & Ruby & Dev {{{
alias v='vagrant'
alias vl='vagrant --provider=lxc'
alias vk='vagrant --provider=kvm'
alias vd='vagrant --provider=docker'
# Automate session creation with sessions plugin for vim
vi() {
if [ -f "/usr/local/bin/vim" ] ; then
VIM=/usr/local/bin/vim
GVIM=/usr/local/bin/gvim
else
VIM=vim
GVIM=gvim
fi
local cmd
local dir_name
local args
case "$TERM" in
xterm|xterm-256color)
cmd=$GVIM
;;
*)
cmd=$VIM
;;
esac
args="-p"
if [ -d "$PWD/.git" ] ; then
dir_name=${PWD##*/}
if [ -f "$HOME/.vim/sessions/${dir_name}.vim" ] ; then
command $cmd --servername ${dir_name} $@
else
command $cmd --servername ${dir_name} $@ "+SaveSession ${dir_name}"
fi
else
echo "04"
command $cmd $args $@
fi
}
pcd() {
if [[ -z "$1" ]] ; then
cd "$HOME/Projects"
else
cd "$HOME/Projects/$1"
fi
}
r() {
if [ -d "$PWD/bin" ] ; then
echo "* using binstub"
./bin/rails "$@"
else
rails "$@"
fi
}
bu() {
if [ -d "$PWD/bin" ] ; then
echo "* using binstub"
./bin/bundle "$@"
else
bundle "$@"
fi
}
rk() {
if [ -d "$PWD/bin" ] ; then
echo "* using binstub"
./bin/rake "$@"
else
rake "$@"
fi
}
# }}}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment