diff options
author | David Runge <david.runge@frqrec.com> | 2014-10-31 18:30:03 +0100 |
---|---|---|
committer | David Runge <david.runge@frqrec.com> | 2014-10-31 18:30:03 +0100 |
commit | ccf94b7df09799feb201d1a59928932fda4e24f4 (patch) | |
tree | 32a8352121f29c02ac3e3024deaae338c5fc04a3 | |
parent | ca44a29e2ebd7c2fc80899139335ee1547867ea6 (diff) | |
download | dotfiles-ccf94b7df09799feb201d1a59928932fda4e24f4.tar.gz dotfiles-ccf94b7df09799feb201d1a59928932fda4e24f4.tar.bz2 dotfiles-ccf94b7df09799feb201d1a59928932fda4e24f4.tar.xz dotfiles-ccf94b7df09799feb201d1a59928932fda4e24f4.zip |
zsh: Adding config files for zprezto, zsh settings and prompts, to comply with the way zprezto gets started
-rw-r--r-- | .gitignore | 9 | ||||
-rw-r--r-- | .zlogin | 22 | ||||
-rw-r--r-- | .zlogout | 14 | ||||
-rw-r--r-- | .zpreztorc | 133 | ||||
-rw-r--r-- | .zprofile | 77 | ||||
-rw-r--r-- | .zsh.after/export.zsh | 8 | ||||
-rw-r--r-- | .zsh.before/aliases.zsh | 11 | ||||
-rw-r--r-- | .zsh.before/custom_prompt_path.zsh | 4 | ||||
-rw-r--r-- | .zsh.before/functions.zsh | 7 | ||||
-rw-r--r-- | .zsh.before/git.zsh | 4 | ||||
-rw-r--r-- | .zsh.before/key-bindings.zsh | 10 | ||||
-rw-r--r-- | .zsh.before/last-command.zsh | 7 | ||||
-rw-r--r-- | .zsh.before/noglob.zsh | 4 | ||||
-rw-r--r-- | .zsh.before/rm.zsh | 2 | ||||
-rw-r--r-- | .zsh.before/vi-mode.zsh | 3 | ||||
-rw-r--r-- | .zsh.prompts/prompt_agnoster_setup | 141 | ||||
-rw-r--r-- | .zsh.prompts/prompt_kylewest_setup | 57 | ||||
-rw-r--r-- | .zsh.prompts/prompt_skwp_setup | 74 | ||||
-rw-r--r-- | .zsh.prompts/prompt_steeef_simplified_setup | 98 | ||||
-rw-r--r-- | .zshenv | 12 | ||||
-rw-r--r-- | .zshrc | 16 |
21 files changed, 701 insertions, 12 deletions
@@ -356,10 +356,5 @@ svn/ .zcompdump .zcompdump.zwc .zdirs -.zhistory -.zlogin -.zlogout -.zpreztorc -.zprofile -.zshenv -.zshrc +.zsh-update +.zsh_history @@ -0,0 +1,22 @@ +# +# Executes commands at login post-zshrc. +# +# Authors: +# Sorin Ionescu <sorin.ionescu@gmail.com> +# + +# 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 +} &! + +# Print a random, hopefully interesting, adage. +if (( $+commands[fortune] )); then + fortune -a + print +fi + diff --git a/.zlogout b/.zlogout new file mode 100644 index 0000000..d898fec --- /dev/null +++ b/.zlogout @@ -0,0 +1,14 @@ +# +# Executes commands at logout. +# +# Authors: +# Sorin Ionescu <sorin.ionescu@gmail.com> +# + +# Print the message. +cat <<-EOF + +Thank you. Come again! + -- Dr. Apu Nahasapeemapetilon +EOF + diff --git a/.zpreztorc b/.zpreztorc new file mode 100644 index 0000000..e17c751 --- /dev/null +++ b/.zpreztorc @@ -0,0 +1,133 @@ +# +# Sets Prezto options. +# +# Authors: +# Sorin Ionescu <sorin.ionescu@gmail.com> +# + +# +# General +# + +# Set case-sensitivity for completion, history lookup, etc. +zstyle ':prezto:*:*' case-sensitive 'no' + +# 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' \ + 'history' \ + 'directory' \ + 'spectrum' \ + 'utility' \ + 'completion' \ + 'archive' \ + 'fasd' \ + 'git' \ + 'syntax-highlighting' \ + 'history-substring-search' \ + 'ssh' \ + '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' + +# +# Pacman +# + +# Set the Pacman frontend. +# zstyle ':prezto:module:pacman' frontend 'yaourt' + +# +# 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 'steeef' + +# +# Screen +# + +# Auto start a session when Zsh is launched. +# zstyle ':prezto:module:screen' auto-start 'yes' + +# +# GPG-Agent +# + +# Enable SSH-Agent protocol emulation. +# zstyle ':prezto:module:gpg-agent' ssh-support 'yes' + +# +# SSH-Agent +# + +# Enable ssh-agent forwarding. +#zstyle ':prezto:module:ssh-agent' forwarding 'yes' + +# Set ssh-agent identities to load. +# zstyle ':prezto:module:ssh-agent' identities 'id_rsa' 'id_rsa2' 'id_github' + +# +# Syntax Highlighting +# + +# Set syntax highlighters. +# By default main, brackets, and cursor are 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' + +# +# Tmux +# + +# Auto start a session when Zsh is launched. +# zstyle ':prezto:module:tmux' auto-start 'yes' + diff --git a/.zprofile b/.zprofile new file mode 100644 index 0000000..7118770 --- /dev/null +++ b/.zprofile @@ -0,0 +1,77 @@ +# +# Executes commands at login pre-zshrc. +# +# Authors: +# Sorin Ionescu <sorin.ionescu@gmail.com> +# + +# +# Browser +# + +if [[ "$OSTYPE" == darwin* ]]; then + export BROWSER='open' +fi + +# +# Editors +# + +export EDITOR='nano' +export VISUAL='nano' +export PAGER='less' + +# +# 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=( + /usr/local/{bin,sbin} + $path +) + +# +# 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 + diff --git a/.zsh.after/export.zsh b/.zsh.after/export.zsh index 8aa685c..e578ef7 100644 --- a/.zsh.after/export.zsh +++ b/.zsh.after/export.zsh @@ -3,19 +3,19 @@ case "$(hostname)" in "dvzrv") export TERM=xterm-termite + export LC_TIME=de_DE.UTF-8 ;; "frqrec") - export TERM=screen-256color + #export TERM=xterm-256color + export TERM=rxvt-256color + export LC_TIME=de_DE.UTF-8 ;; *) export TERM=rxvt-256color ;; esac -# set time settings to use de_DE.UTF-8 (24h format ftw!) -export LC_TIME=de_DE.UTF-8 export BROWSER=firefox - export REPORTTIME=30 # if vimpager is installed, use it instead of less diff --git a/.zsh.before/aliases.zsh b/.zsh.before/aliases.zsh index b38dc53..2fc2c1d 100644 --- a/.zsh.before/aliases.zsh +++ b/.zsh.before/aliases.zsh @@ -1 +1,10 @@ -alias brew='echo' +# Global aliases +alias -g ...='../..' +alias -g ....='../../..' +alias -g .....='../../../..' +alias -g C='| wc -l' +alias -g H='| head' +alias -g L="| less" +alias -g N="| /dev/null" +alias -g S='| sort' +alias -g G='| grep' # now you can do: ls foo G something diff --git a/.zsh.before/custom_prompt_path.zsh b/.zsh.before/custom_prompt_path.zsh new file mode 100644 index 0000000..18e68b9 --- /dev/null +++ b/.zsh.before/custom_prompt_path.zsh @@ -0,0 +1,4 @@ +#Load themes from yadr and from user's custom prompts (themes) in ~/.zsh.prompts +autoload promptinit +fpath=($HOME/.zsh.prompts $fpath) +promptinit diff --git a/.zsh.before/functions.zsh b/.zsh.before/functions.zsh index 01bc224..4b2ef1a 100644 --- a/.zsh.before/functions.zsh +++ b/.zsh.before/functions.zsh @@ -1,3 +1,10 @@ +# Functions +# +# (f)ind by (n)ame +# usage: fn foo +# to find all files containing 'foo' in the name +function fn() { ls **/*$1* } + if [ -e $HOME/bin/functions.sh ] then . $HOME/bin/functions.sh diff --git a/.zsh.before/git.zsh b/.zsh.before/git.zsh new file mode 100644 index 0000000..c87ec5a --- /dev/null +++ b/.zsh.before/git.zsh @@ -0,0 +1,4 @@ +# Makes git auto completion faster favouring for local completions +__git_files () { + _wanted files expl 'local files' _files +} diff --git a/.zsh.before/key-bindings.zsh b/.zsh.before/key-bindings.zsh new file mode 100644 index 0000000..c1c7d8e --- /dev/null +++ b/.zsh.before/key-bindings.zsh @@ -0,0 +1,10 @@ +# http://zsh.sourceforge.net/Doc/Release/Zsh-Line-Editor.html +# http://zsh.sourceforge.net/Doc/Release/Zsh-Line-Editor.html#Zle-Builtins +# http://zsh.sourceforge.net/Doc/Release/Zsh-Line-Editor.html#Standard-Widgets + +bindkey -v # Use vi key bindings +bindkey '^r' history-incremental-search-backward # [Ctrl-r] - Search backward incrementally for a specified string. The string may begin with ^ to anchor the search to the beginning of the line. + +# emacs style +bindkey '^a' beginning-of-line +bindkey '^e' end-of-line diff --git a/.zsh.before/last-command.zsh b/.zsh.before/last-command.zsh new file mode 100644 index 0000000..9f7486b --- /dev/null +++ b/.zsh.before/last-command.zsh @@ -0,0 +1,7 @@ +# Use Ctrl-x,Ctrl-l to get the output of the last command +zmodload -i zsh/parameter +insert-last-command-output() { +LBUFFER+="$(eval $history[$((HISTCMD-1))])" +} +zle -N insert-last-command-output +bindkey "^X^L" insert-last-command-output diff --git a/.zsh.before/noglob.zsh b/.zsh.before/noglob.zsh new file mode 100644 index 0000000..ede67c9 --- /dev/null +++ b/.zsh.before/noglob.zsh @@ -0,0 +1,4 @@ +# Don't try to glob with zsh so you can do +# stuff like ga *foo* and correctly have +# git add the right stuff +alias git='noglob git' diff --git a/.zsh.before/rm.zsh b/.zsh.before/rm.zsh new file mode 100644 index 0000000..26508a3 --- /dev/null +++ b/.zsh.before/rm.zsh @@ -0,0 +1,2 @@ +# Override rm -i alias which makes rm prompt for every action +alias rm='nocorrect rm' diff --git a/.zsh.before/vi-mode.zsh b/.zsh.before/vi-mode.zsh new file mode 100644 index 0000000..4ac7453 --- /dev/null +++ b/.zsh.before/vi-mode.zsh @@ -0,0 +1,3 @@ +set -o vi +export EDITOR=vim +export VISUAL=vim diff --git a/.zsh.prompts/prompt_agnoster_setup b/.zsh.prompts/prompt_agnoster_setup new file mode 100644 index 0000000..16d18c9 --- /dev/null +++ b/.zsh.prompts/prompt_agnoster_setup @@ -0,0 +1,141 @@ +# vim:ft=zsh ts=2 sw=2 sts=2 +# +# agnoster's Theme - https://gist.github.com/3712874 +# A Powerline-inspired theme for ZSH +# +# # README +# +# In order for this theme to render correctly, you will need a +# [Powerline-patched font](https://gist.github.com/1595572). +# +# In addition, I recommend the +# [Solarized theme](https://github.com/altercation/solarized/) and, if you're +# using it on Mac OS X, [iTerm 2](http://www.iterm2.com/) over Terminal.app - +# it has significantly better color fidelity. +# +# # Goals +# +# The aim of this theme is to only show you *relevant* information. Like most +# prompts, it will only show git information when in a git working directory. +# However, it goes a step further: everything from the current user and +# hostname to whether the last call exited with an error to whether background +# jobs are running in this shell will all be displayed automatically when +# appropriate. + +### Segment drawing +# A few utility functions to make it easy and re-usable to draw segmented prompts + +CURRENT_BG='NONE' +SEGMENT_SEPARATOR='⮀' + +# Customizations + +# Checks if working tree is dirty +# From robbyrussell/oh-my-zsh +parse_git_dirty() { + local SUBMODULE_SYNTAX='' + local GIT_STATUS='' + local CLEAN_MESSAGE='nothing to commit (working directory clean)' + if [[ "$(command git config --get oh-my-zsh.hide-status)" != "1" ]]; then + if [[ $POST_1_7_2_GIT -gt 0 ]]; then + SUBMODULE_SYNTAX="--ignore-submodules=dirty" + fi + if [[ "$DISABLE_UNTRACKED_FILES_DIRTY" == "true" ]]; then + GIT_STATUS=$(command git status -s ${SUBMODULE_SYNTAX} -uno 2> /dev/null | tail -n1) + else + GIT_STATUS=$(command git status -s ${SUBMODULE_SYNTAX} 2> /dev/null | tail -n1) + fi + if [[ -n $GIT_STATUS ]]; then + echo "$ZSH_THEME_GIT_PROMPT_DIRTY" + else + echo "$ZSH_THEME_GIT_PROMPT_CLEAN" + fi + else + echo "$ZSH_THEME_GIT_PROMPT_CLEAN" + fi +} + +# Takes two arguments, background and foreground. Both can be omitted, +# rendering default background/foreground. +prompt_segment() { + local bg fg + [[ -n $1 ]] && bg="%K{$1}" || bg="%k" + [[ -n $2 ]] && fg="%F{$2}" || fg="%f" + if [[ $CURRENT_BG != 'NONE' && $1 != $CURRENT_BG ]]; then + echo -n " %{$bg%F{$CURRENT_BG}%}$SEGMENT_SEPARATOR%{$fg%} " + else + echo -n "%{$bg%}%{$fg%} " + fi + CURRENT_BG=$1 + [[ -n $3 ]] && echo -n $3 +} + +# End the prompt, closing any open segments +prompt_end() { + if [[ -n $CURRENT_BG ]]; then + echo -n " %{%k%F{$CURRENT_BG}%}$SEGMENT_SEPARATOR" + else + echo -n "%{%k%}" + fi + echo -n "%{%f%}" + CURRENT_BG='' +} + +### Prompt components +# Each component will draw itself, and hide itself if no information needs to be shown + +# Context: user@hostname (who am I and where am I) +prompt_context() { + local user=`whoami` + + if [[ "$user" != "$DEFAULT_USER" || -n "$SSH_CLIENT" ]]; then + prompt_segment black default "%(!.%{%F{yellow}%}.)$user@%m" + fi +} + +# Git: branch/detached head, dirty status +prompt_git() { + local ref dirty + if $(git rev-parse --is-inside-work-tree >/dev/null 2>&1); then + ZSH_THEME_GIT_PROMPT_DIRTY='±' + dirty=$(parse_git_dirty) + ref=$(git symbolic-ref HEAD 2> /dev/null) || ref="➦ $(git show-ref --head -s --abbrev |head -n1 2> /dev/null)" + if [[ -n $dirty ]]; then + prompt_segment yellow black + else + prompt_segment green black + fi + echo -n "${ref/refs\/heads\//⭠ }$dirty" + fi +} + +# Dir: current working directory +prompt_dir() { + prompt_segment blue black '%~' +} + +# Status: +# - was there an error +# - am I root +# - are there background jobs? +prompt_status() { + local symbols + symbols=() + [[ $RETVAL -ne 0 ]] && symbols+="%{%F{red}%}✘" + [[ $UID -eq 0 ]] && symbols+="%{%F{yellow}%}⚡" + [[ $(jobs -l | wc -l) -gt 0 ]] && symbols+="%{%F{cyan}%}⚙" + + [[ -n "$symbols" ]] && prompt_segment black default "$symbols" +} + +## Main prompt +build_prompt() { + RETVAL=$? + prompt_status + prompt_context + prompt_dir + prompt_git + prompt_end +} + +PROMPT='%{%f%b%k%}$(build_prompt) ' diff --git a/.zsh.prompts/prompt_kylewest_setup b/.zsh.prompts/prompt_kylewest_setup new file mode 100644 index 0000000..c67b5e4 --- /dev/null +++ b/.zsh.prompts/prompt_kylewest_setup @@ -0,0 +1,57 @@ +# +# A theme based on sorin theme +# * ruby info shown on the right +# * git info on the left +# * editor mode as $> or <# +# * single line prompt +# +# Authors: +# Sorin Ionescu <sorin.ionescu@gmail.com> +# Kyle West <kswest@gmail.com> + +function prompt_kylewest_precmd { + setopt LOCAL_OPTIONS + unsetopt XTRACE KSH_ARRAYS + + # Get Git repository information. + if (( $+functions[git-info] )); then + git-info on + git-info + fi + + # Get ruby information + if (( $+functions[ruby-info] )); then + ruby-info + fi +} + +function prompt_kylewest_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_kylewest_precmd + + # editor + zstyle ':prezto:module:editor:info:completing' format '%B%F{red}...%f%b' + zstyle ':prezto:module:editor:info:keymap:primary' format "%B%F{green}$>%f%b" + zstyle ':prezto:module:editor:info:keymap:alternate' format "%B%F{magenta}<#%f%b" + + # ruby info (rvm, rbenv) + zstyle ':prezto:module:ruby:info:version' format '[ %v ]' + + # vcs + zstyle ':prezto:module:git:info:branch' format '%F{yellow}%b%f' + zstyle ':prezto:module:git:info:dirty' format '%B%F{red}!%f%b' + zstyle ':prezto:module:git:info:keys' format 'prompt' '- %b%D ' + + # prompts + PROMPT='%F{cyan}%c%f ${git_info[prompt]}${editor_info[keymap]} ' + RPROMPT='%F{blue}${ruby_info[version]}' +} + +prompt_kylewest_setup "$@" diff --git a/.zsh.prompts/prompt_skwp_setup b/.zsh.prompts/prompt_skwp_setup new file mode 100644 index 0000000..c45eb8a --- /dev/null +++ b/.zsh.prompts/prompt_skwp_setup @@ -0,0 +1,74 @@ +# +# A theme based on steeef theme +# * RVM/Rbenv info shown on the right +# * Git branch info on the left +# * Single line prompt +# +# Authors: +# Steve Losh <steve@stevelosh.com> +# Bart Trojanowski <bart@jukie.net> +# Brian Carper <brian@carper.ca> +# steeef <steeef@gmail.com> +# Sorin Ionescu <sorin.ionescu@gmail.com> +# Yan Pritzker <yan@pritzker.ws> + +function prompt_skwp_precmd { + setopt LOCAL_OPTIONS + unsetopt XTRACE KSH_ARRAYS + + # Get Git repository information. + if (( $+functions[git-info] )); then + git-info on + git-info + fi + + # Get ruby information + if (( $+functions[ruby-info] )); then + ruby-info + fi +} + +function prompt_skwp_setup { + setopt LOCAL_OPTIONS + unsetopt XTRACE KSH_ARRAYS + prompt_opts=(cr percent subst) + + autoload -Uz add-zsh-hook + + add-zsh-hook precmd prompt_skwp_precmd + + # Use extended color pallete if available. + if [[ $TERM = *256color* || $TERM = *rxvt* ]]; then + __PROMPT_SKWP_COLORS=( + "%F{81}" # turquoise + "%F{166}" # orange + "%F{135}" # purple + "%F{161}" # hotpink + "%F{118}" # limegreen + ) + else + __PROMPT_SKWP_COLORS=( + "%F{cyan}" + "%F{yellow}" + "%F{magenta}" + "%F{red}" + "%F{green}" + ) + fi + + # git + zstyle ':prezto:module:git:info:branch' format "${__PROMPT_SKWP_COLORS[1]}%b%f" + zstyle ':prezto:module:git:info:added' format "${__PROMPT_SKWP_COLORS[5]}●%f" + zstyle ':prezto:module:git:info:deleted' format "${__PROMPT_SKWP_COLORS[2]}●%f" + zstyle ':prezto:module:git:info:modified' format "${__PROMPT_SKWP_COLORS[4]}●%f" + zstyle ':prezto:module:git:info:untracked' format "${__PROMPT_SKWP_COLORS[3]}●%f" + zstyle ':prezto:module:git:info:keys' format 'prompt' '(%b%d%a%m%u)' + + # ruby info (rvm, rbenv) + zstyle ':prezto:module:ruby:info:version' format '[%v]' + + PROMPT="${__PROMPT_SKWP_COLORS[3]}%n%f@${__PROMPT_SKWP_COLORS[2]}%m%f ${__PROMPT_SKWP_COLORS[5]}%~%f "'$git_info[prompt]'"$ " + RPROMPT='%F{blue}${ruby_info[version]}' +} + +prompt_skwp_setup "$@" diff --git a/.zsh.prompts/prompt_steeef_simplified_setup b/.zsh.prompts/prompt_steeef_simplified_setup new file mode 100644 index 0000000..14b16da --- /dev/null +++ b/.zsh.prompts/prompt_steeef_simplified_setup @@ -0,0 +1,98 @@ +# +# A theme based on Steve Losh's Extravagant Prompt with vcs_info integration. +# +# Authors: +# Steve Losh <steve@stevelosh.com> +# Bart Trojanowski <bart@jukie.net> +# Brian Carper <brian@carper.ca> +# steeef_simplified <steeef_simplified@gmail.com> +# Sorin Ionescu <sorin.ionescu@gmail.com> +# +# Screenshots: +# http://i.imgur.com/HyRvv.png +# + +function prompt_steeef_simplified_precmd { + # Check for untracked files or updated submodules since vcs_info does not. + if [[ -n $(git ls-files --other --exclude-standard 2> /dev/null) ]]; then + branch_format="(${_prompt_steeef_simplified_colors[1]}%b%f%u%c${_prompt_steeef_simplified_colors[4]}●%f)" + else + branch_format="(${_prompt_steeef_simplified_colors[1]}%b%f%u%c)" + fi + + zstyle ':vcs_info:*:prompt:*' formats "${branch_format}" + + vcs_info 'prompt' + + if (( $+functions[python-info] )); then + python-info + fi + + # Get ruby information + if (( $+functions[ruby-info] )); then + ruby-info + fi +} + +function prompt_steeef_simplified_setup { + setopt LOCAL_OPTIONS + unsetopt XTRACE KSH_ARRAYS + prompt_opts=(cr percent subst) + + # Load required functions. + autoload -Uz add-zsh-hook + autoload -Uz vcs_info + + # Add hook for calling vcs_info before each command. + add-zsh-hook precmd prompt_steeef_simplified_precmd + + # Use extended color pallete if available. + if [[ $TERM = *256color* || $TERM = *rxvt* ]]; then + _prompt_steeef_simplified_colors=( + "%F{81}" # Turquoise + "%F{166}" # Orange + "%F{135}" # Purple + "%F{161}" # Hotpink + "%F{118}" # Limegreen + ) + else + _prompt_steeef_simplified_colors=( + "%F{cyan}" + "%F{yellow}" + "%F{magenta}" + "%F{red}" + "%F{green}" + ) + fi + + # Formats: + # %b - branchname + # %u - unstagedstr (see below) + # %c - stagedstr (see below) + # %a - action (e.g. rebase-i) + # %R - repository path + # %S - path in the repository + local branch_format="(${_prompt_steeef_simplified_colors[1]}%b%f%u%c)" + local action_format="(${_prompt_steeef_simplified_colors[5]}%a%f)" + local unstaged_format="${_prompt_steeef_simplified_colors[2]}●%f" + local staged_format="${_prompt_steeef_simplified_colors[5]}●%f" + + # Set vcs_info parameters. + zstyle ':vcs_info:*' enable bzr git hg svn + zstyle ':vcs_info:*:prompt:*' check-for-changes true + zstyle ':vcs_info:*:prompt:*' unstagedstr "${unstaged_format}" + zstyle ':vcs_info:*:prompt:*' stagedstr "${staged_format}" + zstyle ':vcs_info:*:prompt:*' actionformats "${branch_format}${action_format}" + zstyle ':vcs_info:*:prompt:*' formats "${branch_format}" + zstyle ':vcs_info:*:prompt:*' nvcsformats "" + + # Set python-info parameters. + zstyle ':prezto:module:python:info:virtualenv' format '(%v)' + + # Define prompts. + PROMPT="${_prompt_steeef_simplified_colors[3]}%n%f@${_prompt_steeef_simplified_colors[2]}%m%f ${_prompt_steeef_simplified_colors[5]}%~%f "'${vcs_info_msg_0_}'"$ " + RPROMPT='%F{blue}${ruby_info[version]}' +} + +prompt_steeef_simplified_setup "$@" + @@ -0,0 +1,12 @@ +# +# Defines environment variables. +# +# Authors: +# Sorin Ionescu <sorin.ionescu@gmail.com> +# + +# 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 + @@ -0,0 +1,16 @@ +# +# Executes commands at the start of an interactive session. +# +# Authors: +# Sorin Ionescu <sorin.ionescu@gmail.com> +# + +# Source Prezto. +if [[ -s "${ZDOTDIR:-$HOME}/.zprezto/init.zsh" ]]; then + source "${ZDOTDIR:-$HOME}/.zprezto/init.zsh" +fi + +# Customize to your needs... + +for config_file ($HOME/.zsh.before/*.zsh) source $config_file +for config_file ($HOME/.zsh.after/*.zsh) source $config_file |