Skip to content

Commit

Permalink
split monolithic zshrc file into many smaller ones
Browse files Browse the repository at this point in the history
  • Loading branch information
sunaku committed Oct 20, 2011
1 parent 364c443 commit 0c87fc5
Show file tree
Hide file tree
Showing 15 changed files with 142 additions and 165 deletions.
4 changes: 2 additions & 2 deletions .gitmodules
@@ -1,6 +1,6 @@
[submodule ".zsh-history-substring-search"]
path = .zsh-history-substring-search
path = .zsh/bundle/zsh-history-substring-search
url = git://github.com/zsh-users/zsh-history-substring-search.git
[submodule ".zsh-syntax-highlighting"]
path = .zsh-syntax-highlighting
path = .zsh/bundle/zsh-syntax-highlighting
url = git://github.com/zsh-users/zsh-syntax-highlighting.git
Submodule zsh-syntax-highlighting updated from 000000 to d2715e
9 changes: 9 additions & 0 deletions .zsh/config.zsh
@@ -0,0 +1,9 @@
# load bundles
for dir in ~/.zsh/bundle/*; do
source $dir/${dir##*/}.zsh
done

# delegate configuration to files in config/
for file in ~/.zsh/config/**/*.zsh; do
source $file
done
37 changes: 37 additions & 0 deletions .zsh/config/0-defaults.zsh
@@ -0,0 +1,37 @@
# Lines configured by zsh-newuser-install
HISTFILE=~/.zsh_history
HISTSIZE=9999
SAVEHIST=9999
setopt appendhistory autocd nomatch notify
bindkey -e
# End of lines configured by zsh-newuser-install

# The following lines were added by compinstall
zstyle :compinstall filename ~/.zshrc
autoload -Uz compinit
compinit
# End of lines added by compinstall

# stuff from default oh-my-zsh configuration
setopt alwaystoend
setopt autocd
setopt autopushd
setopt cdablevars
setopt completeinword
setopt correctall
setopt extendedglob
setopt extendedhistory
setopt noflowcontrol
setopt histexpiredupsfirst
setopt histignorealldups
setopt histignoredups
setopt histignorespace
setopt histverify
setopt incappendhistory
setopt interactive
setopt kshglob
setopt longlistjobs
setopt monitor
setopt promptsubst
setopt pushdignoredups
setopt sharehistory
8 changes: 8 additions & 0 deletions .zsh/config/1-interaction.zsh
@@ -0,0 +1,8 @@
# bind special keys according to readline configuration
eval "$(sed -n 's/^/bindkey /; s/: / /p' /etc/inputrc)"

# do not erase entire line when Control-U is pressed
bindkey '^U' backward-kill-line

# keep command history unique to fit more items in it!
setopt histignorealldups
4 changes: 4 additions & 0 deletions .zsh/config/alias.zsh
@@ -0,0 +1,4 @@
source ~/.alias
setopt nocompletealiases # treat `gco` like `git checkout`
compdef _git tig=git-checkout # treat `tig` like `git checkout`
compdef hub=git # treat `hub` like `git`
4 changes: 4 additions & 0 deletions .zsh/config/bundle/zsh-history-substring-search.zsh
@@ -0,0 +1,4 @@
if test $TERM != linux; then
HISTORY_SUBSTRING_SEARCH_HIGHLIGHT_FOUND='fg=yellow,standout'
HISTORY_SUBSTRING_SEARCH_HIGHLIGHT_NOT_FOUND='fg=red,standout'
fi
2 changes: 2 additions & 0 deletions .zsh/config/bundle/zsh-syntax-highlighting.zsh
@@ -0,0 +1,2 @@
ZSH_HIGHLIGHT_STYLES[single-hyphen-option]='bold'
ZSH_HIGHLIGHT_STYLES[double-hyphen-option]='bold'
2 changes: 2 additions & 0 deletions .zsh/config/nvm.zsh
@@ -0,0 +1,2 @@
# Node Version Manager
source ~/.nvm/nvm.sh
3 changes: 3 additions & 0 deletions .zsh/config/precmd.zsh
@@ -0,0 +1,3 @@
# show current command, directory, and user in terminal title
precmd() { print -Pn "\e]2;$0 (%~) %n@%m\a" }
preexec() { print -Pn "\e]2;$1 (%~) %n@%m\a" }
64 changes: 64 additions & 0 deletions .zsh/config/prompt.zsh
@@ -0,0 +1,64 @@
# my "sunaku" prompt from oh-my-zsh (see http://ompldr.org/vOHcwZg)
PROMPT='%(?..%B%F{red}exit %?%f%b
)'\
'$(vcs_info && echo $vcs_info_msg_0_)'\
"%F{$(test $UID -eq 0 && echo red || echo green)}%~%f"\
'%(!.#.>) '
RPROMPT='%F{cyan}%@%f'

# VCS integration for ZSH command prompt
autoload -Uz vcs_info
zstyle ':vcs_info:*' check-for-changes true
zstyle ':vcs_info:*' stagedstr '%B%F{green}^%f%b'
zstyle ':vcs_info:*' unstagedstr '%B%F{yellow}*%f%b'
zstyle ':vcs_info:*' formats '%c%u%b%m '
zstyle ':vcs_info:*' actionformats '%c%u%b%m %B%s-%a%%b '
zstyle ':vcs_info:git*+set-message:*' hooks git-untracked git-aheadbehind git-remotebranch

# http://zsh.git.sourceforge.net/git/gitweb.cgi?p=zsh/zsh;a=blob_plain;f=Misc/vcs_info-examples

### git: Show marker (T) if there are untracked files in repository
# Make sure you have added staged to your 'formats': %c
function +vi-git-untracked(){
if [[ $(git rev-parse --is-inside-work-tree 2> /dev/null) == 'true' ]] && \
git status --porcelain | grep '??' &> /dev/null ; then
# This will show the marker if there are any untracked files in repo.
# If instead you want to show the marker only if there are untracked
# files in $PWD, use:
#[[ -n $(git ls-files --others --exclude-standard) ]] ; then
hook_com[unstaged]+='%B%F{magenta},%f%b'
fi
}

### git: Show +N/-N when your local branch is ahead-of or behind remote HEAD.
# Make sure you have added misc to your 'formats': %m
function +vi-git-aheadbehind() {
local ahead behind
local -a gitstatus

# for git prior to 1.7
# ahead=$(git rev-list origin/${hook_com[branch]}..HEAD | wc -l)
ahead=$(git rev-list ${hook_com[branch]}@{upstream}..HEAD 2>/dev/null | wc -l)
(( $ahead )) && gitstatus+=( "%B%F{blue}+${ahead}%f%b" )

# for git prior to 1.7
# behind=$(git rev-list HEAD..origin/${hook_com[branch]} | wc -l)
behind=$(git rev-list HEAD..${hook_com[branch]}@{upstream} 2>/dev/null | wc -l)
(( $behind )) && gitstatus+=( "%B%F{red}-${behind}%f%b" )

hook_com[misc]+=${(j::)gitstatus}
}

### git: Show remote branch name for remote-tracking branches
# Make sure you have added staged to your 'formats': %b
function +vi-git-remotebranch() {
local remote

# Are we on a remote-tracking branch?
remote=${$(git rev-parse --verify ${hook_com[branch]}@{upstream} \
--symbolic-full-name 2>/dev/null)/refs\/remotes\/}

if [[ -n ${remote} && ${remote#*/} != ${hook_com[branch]} ]] ; then
hook_com[branch]="${hook_com[branch]}(%F{cyan}${remote}%f)"
fi
}
4 changes: 4 additions & 0 deletions .zsh/config/rvm.zsh
@@ -0,0 +1,4 @@
# Ruby Version Manager
unsetopt auto_name_dirs
source ~/.rvm/scripts/rvm
cd $PWD # trigger .rvmrc loading
2 changes: 2 additions & 0 deletions .zsh/config/z-fortune.zsh
@@ -0,0 +1,2 @@
# fortune cookie ;-)
fortune -s | cowsay
163 changes: 0 additions & 163 deletions .zshrc

This file was deleted.

1 change: 1 addition & 0 deletions .zshrc

0 comments on commit 0c87fc5

Please sign in to comment.