Merge branch 'prezto'

* prezto:
  Add git-undo-commit alias
  Use prezto instead of oh-my-zsh
This commit is contained in:
Henrik Lissner 2014-07-29 19:03:19 -04:00
commit 4f5c6cd8d5
14 changed files with 409 additions and 406 deletions

View file

@ -7,9 +7,9 @@ task :zsh => 'zsh:update'
namespace :zsh do
task :install do
unless Dir.exists?(File.expand_path("~/.oh-my-zsh"))
echo "Installing oh-my-zsh"
github 'robbyrussell/oh-my-zsh', '~/.oh-my-zsh'
unless Dir.exists?(File.expand_path("~/.zprezto"))
echo "Installing prezto"
github 'hlissner/prezto', '~/.zprezto'
end
sh_safe '~/.dotfiles/install.sh'
@ -21,12 +21,13 @@ namespace :zsh do
end
task :update => "zsh:install" do
echo "Updating oh-my-zsh"
sh_safe 'cd ~/.oh-my-zsh && git pull'
echo "Updating zprezto"
sh_safe 'cd ~/.zprezto && git pull'
# TODO: pull from parent repo
end
task :remove do
sh_safe 'rm -rf ~/.oh-my-zsh' if Dir.exists?(File.expand_path("~/.oh-my-zsh"))
sh_safe 'rm -rf ~/.zprezto' if Dir.exists?(File.expand_path("~/.zprezto"))
end
end

10
zlogin Normal file
View file

@ -0,0 +1,10 @@
# Executes commands at login post-zshrc.
# Execute code that does not affect the current session in the background.
{
# Compile the completion dump to increase startup speed.
zcompdump="${ZDOTDIR:-$HOME}/.zcompdump"
if [[ -s "$zcompdump" && (! -s "${zcompdump}.zwc" || "$zcompdump" -nt "${zcompdump}.zwc") ]]; then
zcompile "$zcompdump"
fi
} &!

3
zlogout Normal file
View file

@ -0,0 +1,3 @@
# Executes commands at logout.
echo "Logged out!"

69
zprofile Normal file
View file

@ -0,0 +1,69 @@
# Executes commands at login pre-zshrc.
# Browser
[[ "$OSTYPE" == darwin* ]] && export BROWSER='open'
# Editors
export EDITOR='vim'
export VISUAL='vim'
export PAGER='less'
export RUBYOPT=rubygems
# Language
if [[ -z "$LANG" ]]; then
export LANG='en_US.UTF-8'
fi
# Paths
# Ensure path arrays do not contain duplicates.
typeset -gU cdpath fpath mailpath path
# Set the the list of directories that cd searches.
# cdpath=(
# $cdpath
# )
# Set the list of directories that Zsh searches for programs.
path=(
$HOME/.dotfiles/bin
$HOME/.dotfiles/bin/`hostname`
/usr/local/{bin,sbin}
/usr/local/opt/{rb,py}env
$path
)
fpath=(
$HOME/.zsh/themes
$fpath
)
# Less
# Set the default Less options.
# Mouse-wheel scrolling has been disabled by -X (disable screen clearing).
# Remove -X and -F (exit if the content fits on one screen) to enable it.
export LESS='-F -g -i -M -R -S -w -X -z-4'
# Set the Less input preprocessor.
if (( $+commands[lesspipe.sh] )); then
export LESSOPEN='| /usr/bin/env lesspipe.sh %s 2>&-'
fi
# Temporary Files
if [[ ! -d "$TMPDIR" ]]; then
export TMPDIR="/tmp/$USER"
mkdir -p -m 700 "$TMPDIR"
fi
TMPPREFIX="${TMPDIR%/}/zsh"
if [[ ! -d "$TMPPREFIX" ]]; then
mkdir -p "$TMPPREFIX"
fi

View file

@ -2,74 +2,52 @@
# GIT
if command_exists 'git'; then
# On top of oh-my-zsh's git aliases
alias gap='ga -p'
alias ga='git add'
alias gap='git add --patch'
alias gt='git tag'
alias gtl='git describe --tags --abbrev=0'
alias gpb='git push origin'
alias gcu='git reset --soft "HEAD^"'
# alias gpb='git push origin'
git-new-root() {
git-move-root() {
git filter-branch --subdirectory-filter "$@" --prune-empty -- --all
}
# find oh-my-zsh's here: ~/.oh-my-zsh/plugins/git/git.plugin.zsh
fi
# OS-specific aliases
if is_linux; then
alias ipt='sudo iptables'
elif is_mac; then
if [[ "$OSTYPE" == darwin* ]]; then
alias b='brew'
alias ql='quicklook'
alias v='vim'
# Open file in emacs server; must be running!
alias e="emacsclient -n"
o() {
if [ $# -eq 0 ]; then
open .
else
open $@
fi
}
else
alias ipt='sudo iptables'
fi
# Tmux
command_exists 'tmux' && alias t='tmux -CC'
# transmission-remote
if command_exists 'transmission-remote'; then
alias bt="transmission-remote server"
alias btl="bt -l"
alias bta="bt --add"
btr() { bt -t$1 -r }
bts() { bt -t$1 -S }
fi
alias va='vagrant'
# Interpreters
command_exists "rbenv" && alias rbe='rbenv'
command_exists "ruby" && alias rb='ruby'
command_exists "pyenv" && alias pye='pyenv'
command_exists "python" && alias py='python'
command_exists "python3" && alias py3='python3'
alias rbe='rbenv'
alias rb='ruby'
alias pye='pyenv'
alias py='python'
alias py3='python3'
[ -e /Applications/love.app ] && alias love="/Applications/love.app/Contents/MacOS/love"
# Shell conveniences
alias ls='ls --color=auto'
alias l='ls -1'
alias ll='ls -l'
alias la='ls -la'
alias l.='ls -Ad .*'
alias du='du -h -d 1'
alias q='exit'
alias \\q='exit'
alias sha1='openssl sha1'
alias mkdir='mkdir -pv'
alias header='curl -I'
# Resume download if possible
@ -81,9 +59,8 @@ alias sudo='sudo '
# Make a directory and change to it
function mkd { mkdir "$@" && cd "$@" }
alias reload='exec $SHELL -l'
alias c='clear'
alias r='rake -g'
alias r='noglob rake -g'
# Disable zsh glob syntax on the rake command
alias rake='noglob rake'

View file

@ -1,81 +0,0 @@
#!/bin/zsh
unsetopt menu_complete # do not autoselect the first completion entry
unsetopt flowcontrol
setopt auto_menu # show completion menu on succesive tab press
setopt complete_in_word
setopt always_to_end
WORDCHARS=''
zmodload -i zsh/complist
zstyle ':completion:*' completer _expand _complete _ignored _approximate
zstyle ':completion:*' glob on
# case-insensitive (all),partial-word and then substring completion
if [ "x$CASE_SENSITIVE" = "xtrue" ]; then
zstyle ':completion:*' matcher-list 'r:|[._-]=* r:|=*' 'l:|=* r:|=*'
unset CASE_SENSITIVE
else
zstyle ':completion:*' matcher-list 'm:{a-z}={A-Z}' 'r:|[._-]=* r:|=*' 'l:|=* r:|=*'
fi
zstyle ':completion:*' list-colors ''
# should this be in keybindings?
bindkey -M menuselect '^o' accept-and-infer-next-history
zstyle ':completion:*:*:*:*:*' menu select
zstyle ':completion:*:*:kill:*:processes' list-colors '=(#b) #([0-9]#) ([0-9a-z-]#)*=01;34=0=01'
zstyle ':completion:*:*:*:*:processes' command "ps -u `whoami` -o pid,user,comm -w -w"
# disable named-directories autocompletion
zstyle ':completion:*:cd:*' tag-order local-directories directory-stack path-directories
cdpath=(.)
# use /etc/hosts and known_hosts for hostname completion
[ -r ~/.ssh/known_hosts ] && _ssh_hosts=(${${${${(f)"$(<$HOME/.ssh/known_hosts)"}:#[\|]*}%%\ *}%%,*}) || _ssh_hosts=()
hosts=(
"$_ssh_hosts[@]"
"$HOST"
localhost
)
zstyle ':completion:*:hosts' $hosts
# Use caching so that commands like apt and dpkg complete are useable
zstyle ':completion::complete:*' use-cache 1
zstyle ':completion::complete:*' cache-path $ZSH/cache/
# Don't complete uninteresting users
zstyle ':completion:*:*:*:users' ignored-patterns \
adm amanda apache avahi beaglidx bin cacti canna clamav daemon \
dbus distcache dovecot fax ftp games gdm gkrellmd gopher \
hacluster haldaemon halt hsqldb ident junkbust ldap lp mail \
mailman mailnull mldonkey mysql nagios \
named netdump news nfsnobody nobody nscd ntp nut nx openvpn \
operator pcap postfix postgres privoxy pulse pvm quagga radvd \
rpc rpcuser rpm shutdown squid sshd sync uucp vcsa xfs
# ... unless we really want to.
zstyle '*' single-ignored show
if [ "x$COMPLETION_WAITING_DOTS" = "xtrue" ]; then
expand-or-complete-with-dots() {
echo -n "\e[31m......\e[0m"
zle expand-or-complete
zle redisplay
}
zle -N expand-or-complete-with-dots
bindkey "^I" expand-or-complete-with-dots
fi
# expand globs on tab
zstyle ':completion:*:expand:*' tag-order all-expansions
zstyle ':completion:*:history-words' remove-all-dups yes
zstyle ':completion:*:manuals' separate-sections true
zstyle ':completion:*:manuals.*' insert-sections true
autoload -Uz compinit
compinit

View file

@ -2,90 +2,13 @@
# Disable autocorrect behavior, very annoying!
unsetopt correct_all
# HISTORY
HISTFILE=/tmp/histfile
HISTSIZE=5000
SAVEHIST=5000
# No longer prompt to update oh-my-zsh
DISABLE_AUTO_UPDATE="true"
# Don't overwrite, append!
setopt APPEND_HISTORY
# Sharing history between shell instances
setopt SHARE_HISTORY
# If I type cd and then cd again, only save the last one
setopt HIST_IGNORE_DUPS
# Don't save lines that are just whitespace
setopt HIST_IGNORE_SPACE
setopt HIST_NO_STORE
# Reduce extra whitespace
setopt HIST_REDUCE_BLANKS
# Save time and how long a command ran
setopt EXTENDED_HISTORY
# Beep boop
setopt NO_BEEP
setopt EXTENDED_GLOB
setopt PROMPT_SUBST
setopt AUTO_PUSHD
setopt PUSHD_IGNORE_DUPS
# Don't wait for keys (snappier vi-mode)
export KEYTIMEOUT=1
export EDITOR=vim
export RUBYOPT=rubygems
# COMPLETION_WAITING_DOTS="true"
##################################
# Make zsh prompt act like vi
zle -N edit-command-line
bindkey -v
bindkey '^f' edit-command-line
bindkey '^r' history-incremental-search-backward
bindkey '^w' backward-kill-word
bindkey '^a' beginning-of-line
bindkey '^e' end-of-line
if ! [ "$EMACS" ]; then
bindkey ${terminfo[kdch1]} delete-char
# Switch between block and line cursor (Only in iterm)
if is_mac; then
function zle-keymap-select zle-line-init {
# change cursor shape in iTerm2
case $KEYMAP in
vicmd) print -n -- "\E]50;CursorShape=0\C-G";; # block cursor
viins|main) print -n -- "\E]50;CursorShape=1\C-G";; # line cursor
esac
zle reset-prompt
zle -R
}
function zle-line-finish {
print -n -- "\E]50;CursorShape=0\C-G" # block cursor
}
zle -N zle-line-init
zle -N zle-line-finish
zle -N zle-keymap-select
fi
fi
# Switch between block and line cursor (Only in iterm)
autoload colors
if [[ "$terminfo[colors]" -gt 8 ]]; then
colors
fi
for COLOR in RED GREEN YELLOW BLUE MAGENTA CYAN BLACK WHITE; do
eval $COLOR='$fg_no_bold[${(L)COLOR}]'
eval BOLD_$COLOR='$fg_bold[${(L)COLOR}]'
done
eval RESET='$reset_color'
# print -n -- "\E]50;CursorShape=1\C-G"

View file

@ -5,57 +5,4 @@ function command_exists {
command -v "$1" &> /dev/null
}
# OS detection
function is_deb {
command_exists apt-get
}
function is_mac {
[[ $(uname) == 'Darwin' ]]
}
function is_linux {
[[ $(uname) == 'Linux' ]]
}
# Extract a compressed file with the appropriate command
function unpack {
if [ -f "$1" ]; then
case $1 in
*.tar.bz2) tar xjf $1 ;;
*.tar.gz) tar xzf $1 ;;
*.bz2) bunzip2 $1 ;;
*.rar) unrar x $1 ;;
*.gz) gunzip $1 ;;
*.tar) tar xf $1 ;;
*.tbz2) tar xjf $1 ;;
*.tgz) tar xzf $1 ;;
*.zip) unzip $1 ;;
*.Z) uncompress $1 ;;
*) echo "'$1' cannot be extracted via extract()" ;;
esac
else
echo "'$1' is not a valid file"
fi
}
if is_mac; then
# Change working directory to the top-most Finder window location
function cdf() { # short for `cdfinder`
cd "$(osascript -e 'tell app "Finder" to POSIX path of (insertion location as alias)')"
}
# Open a file in Mac OS's quick-look
function quicklook {
(( $# > 0 )) && qlmanage -p $* &>/dev/null &
}
# Check to see if the (mac) app exists
function app_exists {
[ -d /Applications/"$1" ] || [ -e /Applications/"$1".app ] || [ -e ~/Applications/"$1".app ]
}
fi
# vim:set ft=zsh:

View file

@ -1,41 +0,0 @@
#!/bin/zsh
function _init_paths {
export PATH=/usr/bin:/bin:/usr/sbin
# Setup homebrew paths
if [ -e /usr/local/bin/brew ]; then
local BREWDIR=`/usr/local/bin/brew --prefix`
PATH=$BREWDIR/bin:$PATH
local COREUTILS=`brew --prefix coreutils`
if [ -d "$COREUTILS" ]; then
PATH="$COREUTILS/libexec/gnubin:$PATH"
MANPATH="$COREUTILS/libexec/gnuman:$MANPATH"
fi
fi
# rb/pyenv paths
local RBENV_DIR="`brew --prefix rbenv`"
local PYENV_DIR="`brew --prefix pyenv`"
if [ -d "$RBENV_DIR" ]; then
PATH=$RBENV_DIR/bin:$PATH
export RBENV_ROOT=$RBENV_DIR
fi
if [ -d "$PYENV_DIR" ]; then
PATH=$PYENV_DIR/bin:$PATH
export PYENV_ROOT=$PYENV_DIR
fi
# hostname-specific bins
[ -d $HOME/.dotfiles/bin/`hostname` ] && PATH=$HOME/.dotfiles/bin/`hostname`:$PATH
# global bins
PATH=$HOME/.dotfiles/bin:$PATH
}
_init_paths
unset -f _init_paths
# vim:set ft=zsh:

114
zsh/preztorc Normal file
View file

@ -0,0 +1,114 @@
# Sets Prezto options.
# General
zstyle ':prezto:module:prompt' theme 'my'
# 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 \
'environment' \
'terminal' \
'editor' \
'opp' \
'history' \
'history-substring-search' \
'directory' \
'spectrum' \
'utility' \
'completion' \
'prompt' \
'git' \
'ssh' \
'osx'
# 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
# Set the query found color.
# zstyle ':prezto:module:history-substring-search:color' found ''
# Set the query not found color.
# zstyle ':prezto:module:history-substring-search:color' not-found ''
# Set the search globbing flags.
# zstyle ':prezto:module:history-substring-search' globbing-flags ''
# 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'
#
# Set syntax highlighting styles.
# zstyle ':prezto:module:syntax-highlighting' styles \
# 'builtin' 'bg=blue' \
# 'command' 'bg=blue' \
# 'function' 'bg=blue'
# 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'

View file

@ -1,93 +1,117 @@
#!/bin/zsh
zstyle ':prezto:module:git:info:branch' format 'branch:%b'
zstyle ':prezto:module:git:info:remote' format 'remote:%R'
zstyle ':prezto:module:git:info:keys' format \
'prompt' ' git(%b)' \
'rprompt' '[%R]'
function prompt_custom_preexec {
if (( $+functions[git-info] )); then
git-info
fi
}
function prompt_custom_setup {
PROMPT='%m%# '
RPROMPT=''
}
# autoload colors
# if [[ "$terminfo[colors]" -gt 8 ]]; then
# colors
# fi
# GIT Stuff
ZSH_THEME_GIT_PROMPT_PREFIX=" %{$fg[white]%}"
ZSH_THEME_GIT_PROMPT_SUFFIX=""
ZSH_THEME_GIT_PROMPT_DIRTY="%{$fg[red]%}+%{$fg[white]%}"
# ZSH_THEME_GIT_PROMPT_PREFIX=" %{$fg[white]%}"
# ZSH_THEME_GIT_PROMPT_SUFFIX=""
# ZSH_THEME_GIT_PROMPT_DIRTY="%{$fg[red]%}+%{$fg[white]%}"
# ZSH_THEME_GIT_PROMPT_CLEAN=""
##################
# Build Prompt #
##################
function _prompt_pwd {
SHORTPWD=`print -Pn "%3~"`
# function _prompt_pwd {
# SHORTPWD=`print -Pn "%3~"`
#
# if [[ -n "${ZSH_VERSION:-}" ]]
# then _pwd="${SHORTPWD[0,1]}"
# else _pwd="${SHORTPWD:0:1}"
# fi
#
# [[ $_pwd =~ "[^/~]" ]] && SHORTPWD=".../$SHORTPWD"
#
# echo -n $SHORTPWD
# }
#
# # function _prompt_git {
# # [ "`git_prompt_info`" ] && echo -n "$(git_prompt_info)"
# # }
#
# function _prompt_vimode {
# # The prompt turns green in command mode, and red in insert mode
# PROMPT="$"
#
# MODE_INDICATOR="%{$fg[green]%}%{$PROMPT%}"
# MODE_PROMPT="${${KEYMAP/vicmd/$MODE_INDICATOR}/(main|viins)/}"
# if [ $MODE_PROMPT ]; then
# echo -n "$MODE_PROMPT "
# else
# echo -n "$PROMPT "
# fi
# }
#
# function _prompt_rbenv {
# local ruby_version
# ruby_version="$(rbenv local 2>/dev/null)"
# [ "$?" -eq 0 ] && echo -n " %{$fx[bold]%}%{$fg[red]%}:$ruby_version"
# }
#
# function _prompt_pyenv {
# local py_version
# py_version="$(pyenv local 2>/dev/null)"
# [ "$?" -eq 0 ] && echo -n " %{$fx[bold]%}%{$fg[yellow]%}:$py_version"
# }
#
# # prompts
# function _lprompt {
# # Start each prompt with a newline
# echo
#
# # Show the hostname if this is an SSH session
# if [ ! -z "$SSH_CLIENT" ]; then
# echo -n "%{$fg[blue]%}"
# if is_mac; then
# echo -n "$(hostname | sed -e 's/\.local$//') "
# else
# echo -n "$(hostname) "
# fi
# fi
#
# # Print the prompt
# echo -n "$fg[red]$FX[bold]$(_prompt_vimode)$reset_color"
# }
#
# function _rprompt {
# # Make the rprompt a bright grey to set it apart
# echo -n "%{$FG[245]%}"
# echo -n "$(_prompt_pwd)"
#
# # Show the branch/status if in a git repo
# # echo -n '$(_prompt_git)'
#
# # Display the local version of rb/pyenv
# command_exists rbenv && echo -n "$(_prompt_rbenv)"
# command_exists pyenv && echo -n "$(_prompt_pyenv)"
#
# # Reset formatting for command output
# echo -n "$reset_color"
# }
if [[ -n "${ZSH_VERSION:-}" ]]
then _pwd="${SHORTPWD[0,1]}"
else _pwd="${SHORTPWD:0:1}"
fi
[[ $_pwd =~ "[^/~]" ]] && SHORTPWD=".../$SHORTPWD"
echo -n $SHORTPWD
}
function _prompt_git {
[ "`git_prompt_info`" ] && echo -n "$(git_prompt_info)"
}
function _prompt_vimode {
# The prompt turns green in command mode, and red in insert mode
PROMPT="$"
MODE_INDICATOR="%{$fg[green]%}%{$PROMPT%}"
MODE_PROMPT="${${KEYMAP/vicmd/$MODE_INDICATOR}/(main|viins)/}"
if [ $MODE_PROMPT ]; then
echo -n "$MODE_PROMPT "
else
echo -n "$PROMPT "
fi
}
function _prompt_rbenv {
local ruby_version
ruby_version="$(rbenv local 2>/dev/null)"
[ "$?" -eq 0 ] && echo -n " %{$fx[bold]%}%{$fg[red]%}:$ruby_version"
}
function _prompt_pyenv {
local py_version
py_version="$(pyenv local 2>/dev/null)"
[ "$?" -eq 0 ] && echo -n " %{$fx[bold]%}%{$fg[yellow]%}:$py_version"
}
# prompts
function _lprompt {
# Start each prompt with a newline
echo
# Show the hostname if this is an SSH session
if [ ! -z "$SSH_CLIENT" ]; then
echo -n "%{$fg[blue]%}"
if is_mac; then
echo -n "$(hostname | sed -e 's/\.local$//') "
else
echo -n "$(hostname) "
fi
fi
# Print the prompt
echo -n '%{$fg[red]%}%{$FX[bold]%}$(_prompt_vimode)%{$reset_color%}'
}
function _rprompt {
# Make the rprompt a bright grey to set it apart
echo -n "%{$FG[245]%}"
echo -n '$(_prompt_pwd)'
# Show the branch/status if in a git repo
echo -n '$(_prompt_git)'
# Display the local version of rb/pyenv
command_exists rbenv && echo -n '$(_prompt_rbenv)'
command_exists pyenv && echo -n '$(_prompt_pyenv)'
# Reset formatting for command output
echo -n "%{$reset_color%}"
}
PROMPT="$(_lprompt)"
RPROMPT="$(_rprompt)"
# PROMPT="$(_lprompt)"
# RPROMPT="$(_rprompt)"
# vim:set ft=zsh:

View file

@ -0,0 +1,75 @@
#
# A simple theme based off sorin
#
# Load dependencies.
pmodload 'helper'
function prompt_my_pwd {
local pwd="${PWD/#$HOME/~}"
if [[ "$pwd" == (#m)[/~] ]]; then
_prompt_my_pwd="$MATCH"
unset MATCH
else
_prompt_my_pwd="${${${(@j:/:M)${(@s:/:)pwd}##.#?}:h}%/}/${pwd:t}"
fi
}
function prompt_my_precmd {
setopt LOCAL_OPTIONS
unsetopt XTRACE KSH_ARRAYS
# Format PWD.
prompt_my_pwd
# Get Git repository information.
if (( $+functions[git-info] )); then
git-info
fi
}
function prompt_my_setup {
setopt LOCAL_OPTIONS
unsetopt XTRACE KSH_ARRAYS
prompt_opts=(cr percent subst)
# Load required functions.
autoload -Uz add-zsh-hook
# Add hook for calling git-info before each command.
add-zsh-hook precmd prompt_my_precmd
# Set editor-info parameters.
zstyle ':prezto:module:editor:info:completing' format '%B%F{red}...%f%b'
zstyle ':prezto:module:editor:info:keymap:primary' format ' %B%F{red}%f%b'
zstyle ':prezto:module:editor:info:keymap:primary:overwrite' format ' %F{red}♺%f'
zstyle ':prezto:module:editor:info:keymap:alternate' format ' %B%F{green}%f%b'
# Set git-info parameters.
zstyle ':prezto:module:git:info' verbose 'yes'
zstyle ':prezto:module:git:info:action' format ':%%B%F{yellow}%s%f%%b'
zstyle ':prezto:module:git:info:added' format ' %%B%F{green}✚%f%%b'
zstyle ':prezto:module:git:info:ahead' format ' %%B%F{yellow}⬆%f%%b'
zstyle ':prezto:module:git:info:behind' format ' %%B%F{yellow}⬇%f%%b'
zstyle ':prezto:module:git:info:branch' format ':%F{green}%b%f'
zstyle ':prezto:module:git:info:commit' format ':%F{green}%.7c%f'
zstyle ':prezto:module:git:info:deleted' format ' %%B%F{red}✖%f%%b'
zstyle ':prezto:module:git:info:modified' format ' %%B%F{blue}✱%f%%b'
zstyle ':prezto:module:git:info:position' format ':%F{red}%p%f'
zstyle ':prezto:module:git:info:renamed' format ' %%B%F{magenta}➜%f%%b'
zstyle ':prezto:module:git:info:stashed' format ' %%B%F{cyan}✭%f%%b'
zstyle ':prezto:module:git:info:unmerged' format ' %%B%F{yellow}═%f%%b'
zstyle ':prezto:module:git:info:untracked' format ' %%B%F{white}◼%f%%b'
zstyle ':prezto:module:git:info:keys' format \
'prompt' ' %F{blue}%f$(coalesce "%b" "%p" "%c")%s' \
'rprompt' '%A%B%S%a%d%m%r%U%u'
# Define prompts.
PROMPT='
%F{cyan}${_prompt_my_pwd}%f${git_info:+${(e)git_info[prompt]}}%(!. %B%F{red}#%f%b.)${editor_info[keymap]} '
RPROMPT='${editor_info[overwrite]}%(?:: %F{red}⏎%f)${VIM:+" %B%F{green}V%f%b"}${git_info[rprompt]}'
# SPROMPT='zsh: correct %F{red}%R%f to %F{green}%r%f [nyae]? '
}
prompt_my_setup "$@"

7
zshenv
View file

@ -1,5 +1,4 @@
source ~/.zsh/paths
if [ -z ${ZSH_INIT+x} ]; then
source ~/.zsh/functions
source ~/.zsh/aliases
# Ensure that a non-login, non-interactive shell has a defined environment.
if [[ "$SHLVL" -eq 1 && ! -o LOGIN && -s "${ZDOTDIR:-$HOME}/.zprofile" ]]; then
source "${ZDOTDIR:-$HOME}/.zprofile"
fi

31
zshrc
View file

@ -1,33 +1,16 @@
#!/bin/zsh
# ZSH Env variables
export ZSH_INIT=1
export ZSH=$HOME/.oh-my-zsh
source ~/.zsh/functions
# Plugins:
# see <https://github.com/robbyrussell/oh-my-zsh/tree/master/plugins>
plugins=(git)
if is_mac; then
plugins+=tmux
plugins+=vagrant
# Source Prezto.
if [[ -s "${ZDOTDIR:-$HOME}/.zprezto/init.zsh" ]]; then
source ~/.zsh/preztorc
source "${ZDOTDIR:-$HOME}/.zprezto/init.zsh"
fi
# Liiiiive!
source $ZSH/oh-my-zsh.sh
# Source component rcfiles
source ~/.zsh/paths
source ~/.zsh/functions
source ~/.zsh/aliases
source ~/.zsh/config
source ~/.zsh/completion
source ~/.zsh/prompt
# source ~/.zsh/welcome
# Have a system specific rcfile? Source it!
[ -f ~/.localrc ] && source ~/.localrc
# Init rbenv & pyenv
command_exists rbenv && eval "$(rbenv init -)"
command_exists pyenv && eval "$(pyenv init -)"
command_exists "rbenv" && eval "$(rbenv init -)"
command_exists "pyenv" && eval "$(pyenv init -)"