From bb3b34829a0599a2c356a46fdfa75c3f9c525088 Mon Sep 17 00:00:00 2001 From: Matt Singleton Date: Fri, 18 Feb 2011 17:05:47 -0500 Subject: removing dependency on oh-my-zsh --- deploy.sh | 16 ++--------- diff.sh | 4 +-- oh-my-zsh/svn.zsh | 16 ----------- oh-my-zsh/xcolour.zsh-theme | 65 --------------------------------------------- vimrc | 1 + zsh/appearance.zsh | 41 ++++++++++++++++++++++++++++ zsh/completion.zsh | 58 ++++++++++++++++++++++++++++++++++++++++ zsh/correction.zsh | 9 +++++++ zsh/functions.zsh-overrides | 10 +++++++ zsh/git.zsh | 19 +++++++++++++ zsh/history.zsh | 18 +++++++++++++ zsh/key-bindings.zsh | 22 +++++++++++++++ zsh/svn.zsh | 15 +++++++++++ zsh/termsupport.zsh | 23 ++++++++++++++++ zshrc | 39 +++------------------------ 15 files changed, 222 insertions(+), 134 deletions(-) delete mode 100644 oh-my-zsh/svn.zsh delete mode 100644 oh-my-zsh/xcolour.zsh-theme create mode 100644 zsh/appearance.zsh create mode 100644 zsh/completion.zsh create mode 100644 zsh/correction.zsh create mode 100644 zsh/functions.zsh-overrides create mode 100644 zsh/git.zsh create mode 100644 zsh/history.zsh create mode 100644 zsh/key-bindings.zsh create mode 100644 zsh/svn.zsh create mode 100644 zsh/termsupport.zsh diff --git a/deploy.sh b/deploy.sh index 1f220ca..cdcf81e 100755 --- a/deploy.sh +++ b/deploy.sh @@ -2,18 +2,6 @@ set -e -# check for dependencies -echo "Checking for dependencies" -echo " oh-my-zsh..." -if [ ! -e ~/.oh-my-zsh/lib ]; then - echo " not found!" - exit 1 -fi -if [ ! -e ~/.oh-my-zsh/themes ]; then - echo " not found!" - exit 1 -fi - # template git profile echo "enter your global git user name:" read name @@ -28,8 +16,8 @@ do cp $f ~/.${f} done -cp oh-my-zsh/svn.zsh ~/.oh-my-zsh/lib/svn.zsh -cp oh-my-zsh/xcolour.zsh-theme ~/.oh-my-zsh/themes/xcolour.zsh-theme +mkdir -p ~/.zsh +cp oh-my-zsh/* ~/.zsh mkdir -p ~/.vim cp -r vim/* ~/.vim diff --git a/diff.sh b/diff.sh index ae7d660..b5e8984 100755 --- a/diff.sh +++ b/diff.sh @@ -10,9 +10,7 @@ diff -U 0 mostrc ~/.mostrc echo diff -U 0 zshrc ~/.zshrc echo -diff -U 0 oh-my-zsh/svn.zsh ~/.oh-my-zsh/lib/svn.zsh -echo -diff -U 0 oh-my-zsh/xcolour.zsh-theme ~/.oh-my-zsh/themes/xcolour.zsh-theme +diff -U 0 zsh ~/.zsh echo diff -r -U 0 vim ~/.vim diff --git a/oh-my-zsh/svn.zsh b/oh-my-zsh/svn.zsh deleted file mode 100644 index 54d23b4..0000000 --- a/oh-my-zsh/svn.zsh +++ /dev/null @@ -1,16 +0,0 @@ -# utility functions for subversion -# based on oh-my-zsh git lib module - -function svn_dirty { - if [[ -n $(svn status) ]]; then - echo "$ZSH_THEME_SVN_PROMPT_DIRTY" - else - echo "$ZSH_THEME_SVN_PROMPT_CLEAN" - fi -} - -function svn_prompt_info { - info=$(svn info 2>/dev/null) || return - rev=$(echo "$info" | grep Revision | sed 's/Revision: //') - echo "${ZSH_THEME_GIT_PROMPT_PREFIX}r${rev}$(svn_dirty)${ZSH_THEME_GIT_PROMPT_SUFFIX}" -} diff --git a/oh-my-zsh/xcolour.zsh-theme b/oh-my-zsh/xcolour.zsh-theme deleted file mode 100644 index 1578a47..0000000 --- a/oh-my-zsh/xcolour.zsh-theme +++ /dev/null @@ -1,65 +0,0 @@ -# Matt Singleton's oh-my-zsh theme - -function prompt_char { - git branch >/dev/null 2>/dev/null && echo '±' && return - svn info >/dev/null 2>/dev/null && echo 'ϟ' && return - echo '$' -} - -function return_code { - code=$(echo $?) - if [[ $code == "0" ]]; then - return - else - echo "%{$fg[red]%}$code%{$reset_color%} " - fi -} - -function parse_git_branch { - echo "${ref#refs/heads/}" -} - -function parse_git_staged { - $(git diff-index --quiet --cached HEAD) && return - echo "staged" -} -function parse_git_unstaged { - $(git diff-files --quiet) && return - echo "unstaged" -} - -function my_git_prompt_info { - ref=$(git symbolic-ref HEAD 2> /dev/null) || return -# # staged -# git diff-index --quiet --cached HEAD -# if [ $? -eq 1 ]; then -# echo "(%{$fg[yellow]%}${ref#refs/heads/}%{$reset_color%}) " -# return -# fi -# # uunstaged -# git ls-files --exclude-standard --others -# if [ $? -eq 1 ]; then -# echo "(%{$fg[red]%}${ref#refs/heads/}%{$reset_color%}) " -# return -# fi -# # untracked and unignored -# git diff-files --quiet -# if [ $? -eq 1 ]; then -# echo "(%{$fg[red]%}${ref#refs/heads/}%{$reset_color%}) " -# return -# fi - echo "(${ref#refs/heads/}) " -} - -PROMPT='%{$fg[yellow]%}%n%{$reset_color%}@%{$fg[green]%}%m%{$reset_color%}:%{$fg[blue]%}%~%{$reset_color%} -$(return_code)$(my_git_prompt_info)$(prompt_char) %{$reset_color%}' - -ZSH_THEME_GIT_PROMPT_PREFIX="(" -ZSH_THEME_GIT_PROMPT_SUFFIX=") " -ZSH_THEME_GIT_PROMPT_DIRTY="%{$fg[red]%}✘%{$reset_color%}" -ZSH_THEME_GIT_PROMPT_CLEAN="%{$fg[green]%}✔%{$reset_color%}" - -ZSH_THEME_SVN_PROMPT_PREFIX="(" -ZSH_THEME_SVN_PROMPT_SUFFIX=") " -ZSH_THEME_SVN_PROMPT_DIRTY="%{$fg[red]%}✘%{$reset_color%}" -ZSH_THEME_SVN_PROMPT_CLEAN="%{$fg[green]%}✔%{$reset_color%}" diff --git a/vimrc b/vimrc index d47111e..d68dddf 100644 --- a/vimrc +++ b/vimrc @@ -57,6 +57,7 @@ if has("autocmd") " zsh configs and scripts au BufRead,BufNewFile *.zsh-theme setlocal filetype=zsh + au BufRead,BufNewFile *.zsh-overrides setlocal filetype=zsh au BufRead,BufNewFile *.zsh setlocal filetype=zsh " ruby files diff --git a/zsh/appearance.zsh b/zsh/appearance.zsh new file mode 100644 index 0000000..e8d6dff --- /dev/null +++ b/zsh/appearance.zsh @@ -0,0 +1,41 @@ +#done + +autoload colors; colors; +setopt prompt_subst # expansion of color codes, etc. + +# Find the option for using colors in ls, depending on the version: Linux or BSD +ls --color -d . &>/dev/null 2>&1 && alias ls='ls --color=tty' || alias ls='ls -G' +export LSCOLORS="exgxbxdxcxegedxbxgxcxd" + +export GREP_OPTIONS='--color=auto' +export GREP_COLOR='1;32' + +export LESS_TERMCAP_mb=$'\e[0;31m' # begin blinking - red +export LESS_TERMCAP_md=$'\e[0;34m' # begin bold - blue +export LESS_TERMCAP_me=$'\e[0m' # end mode +export LESS_TERMCAP_so=$'\e[38;5;246m' # begin standout mode - info box +export LESS_TERMCAP_se=$'\e[0m' # end standout mode +export LESS_TERMCAP_us=$'\e[4;33m' # begin underline - yellow underline +export LESS_TERMCAP_ue=$'\e[0m' # end underline + +function theme_preexec () { + echo "($fg[magenta]`date +%r`$reset_color) $fg[cyan]$3$reset_color" +} + +function prompt_char { + git branch >/dev/null 2>/dev/null && echo '±' && return + svn info >/dev/null 2>/dev/null && echo 'ϟ' && return + echo '$' +} + +function return_code { + code=$(echo $?) + if [[ $code == "0" ]]; then + return + else + echo "%{$fg[red]%}$code%{$reset_color%} " + fi +} + +PROMPT='%{$fg[yellow]%}%n%{$reset_color%}@%{$fg[green]%}%m%{$reset_color%}:%{$fg[blue]%}%~%{$reset_color%} +$(return_code)$(git_prompt_info)$(prompt_char) %{$reset_color%}' diff --git a/zsh/completion.zsh b/zsh/completion.zsh new file mode 100644 index 0000000..4a6322c --- /dev/null +++ b/zsh/completion.zsh @@ -0,0 +1,58 @@ +# TODO: figure this thing out + +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='' + +autoload -U compinit +compinit -i + +zmodload -i zsh/complist + +zstyle ':completion:*' matcher-list 'r:|[._-]=* r:|=*' 'l:|=* r:|=*' + +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=() +[ -r /etc/hosts ] && : ${(A)_etc_hosts:=${(s: :)${(ps:\t:)${${(f)~~"$( /dev/null) || return + echo "(${ref#refs/heads/}) " +} diff --git a/zsh/history.zsh b/zsh/history.zsh new file mode 100644 index 0000000..0619fbe --- /dev/null +++ b/zsh/history.zsh @@ -0,0 +1,18 @@ +#TODO: optimize these rules. they are redundant + +## Command history configuration +HISTFILE=$HOME/.zsh_history +HISTSIZE=10000 +SAVEHIST=10000 + +setopt hist_ignore_dups # ignore duplication command history list +setopt share_history # share command history data + +setopt hist_verify +setopt inc_append_history +setopt extended_history +setopt hist_expire_dups_first +setopt hist_ignore_space + +setopt SHARE_HISTORY +setopt APPEND_HISTORY diff --git a/zsh/key-bindings.zsh b/zsh/key-bindings.zsh new file mode 100644 index 0000000..b63a68b --- /dev/null +++ b/zsh/key-bindings.zsh @@ -0,0 +1,22 @@ +# TODO: figure these out + +autoload -U compinit +compinit -i + +bindkey -e +bindkey '\ew' kill-region +bindkey -s '\el' "ls\n" +bindkey -s '\e.' "..\n" +bindkey '^r' history-incremental-search-backward +bindkey "^[[5~" up-line-or-history +bindkey "^[[6~" down-line-or-history + +bindkey "^[[H" beginning-of-line +bindkey "^[[1~" beginning-of-line +bindkey "^[[F" end-of-line +bindkey "^[[4~" end-of-line +bindkey ' ' magic-space # also do history expansion on space + +bindkey '^[[Z' reverse-menu-complete + +bindkey "\e[3~" delete-char # make sure delete key works diff --git a/zsh/svn.zsh b/zsh/svn.zsh new file mode 100644 index 0000000..bbcc69f --- /dev/null +++ b/zsh/svn.zsh @@ -0,0 +1,15 @@ +#done + +function svn_dirty { + if [[ -n $(svn status) ]]; then + echo "$ZSH_THEME_SVN_PROMPT_DIRTY" + else + echo "$ZSH_THEME_SVN_PROMPT_CLEAN" + fi +} + +function svn_prompt_info { + info=$(svn info 2>/dev/null) || return + rev=$(echo "$info" | grep Revision | sed 's/Revision: //') + echo "${ZSH_THEME_GIT_PROMPT_PREFIX}r${rev}$(svn_dirty)${ZSH_THEME_GIT_PROMPT_SUFFIX}" +} diff --git a/zsh/termsupport.zsh b/zsh/termsupport.zsh new file mode 100644 index 0000000..6768222 --- /dev/null +++ b/zsh/termsupport.zsh @@ -0,0 +1,23 @@ +#done + +case "$TERM" in + xterm*|rxvt*) + term_preexec () { + print -Pn "\e]0;%n@%m:%~ ($1)\a" # xterm + } + term_precmd () { + print -Pn "\e]0;%n@%m:%~\a" # xterm + } + ;; + screen*) + term_preexec () { + local CMD=${1[(wr)^(*=*|sudo|ssh|-*)]} + echo -ne "\ek$CMD\e\\" + print -Pn "\e]0;%n@%m:%~($1)\a" # xterm + } + term_precmd () { + echo -ne "\ekzsh\e\\" + print -Pn "\e]0;%n@%m:%~\a" # xterm + } + ;; +esac diff --git a/zshrc b/zshrc index 29c3846..c715183 100644 --- a/zshrc +++ b/zshrc @@ -1,47 +1,14 @@ -# Path to your oh-my-zsh configuration. -export ZSH=$HOME/.oh-my-zsh - -# Set to the name theme to load. -# Look in ~/.oh-my-zsh/themes/ -export ZSH_THEME="xcolour" - -# Set to this to use case-sensitive completion -export CASE_SENSITIVE="true" - -# Comment this out to disable weekly auto-update checks -export DISABLE_AUTO_UPDATE="true" - -# Uncomment following line if you want to disable colors in ls -# export DISABLE_LS_COLORS="true" - -# Which plugins would you like to load? (plugins can be found in ~/.oh-my-zsh/plugins/*) -# Example format: plugins=(rails git textmate ruby lighthouse) -plugins=(git) - -source $ZSH/oh-my-zsh.sh - -# Customize to your needs... - -export LSCOLORS="exgxbxdxcxegedxbxgxcxd" +for config_file (~/.zsh/*.zsh) source $config_file export EDITOR=vim -bindkey "\e[3~" delete-char - if [ -e $HOME/.zshrc-local ]; then source $HOME/.zshrc-local fi -# runs after local because 'most' isn't standard, -# and may be provided by a local path addition -if [[ -e $(which most) ]]; then - export PAGER=most -fi - # run after local because local because user bin should # take absolute priority export PATH=$HOME/bin:$PATH -function preexec () { - echo "($fg[magenta]`date +%r`$reset_color) $fg[cyan]$3$reset_color" -} +# override builtin functions (preexec, precmd, etc.) +source ~/.zsh/functions.zsh-overrides -- cgit v1.2.3