From 8debd097fbea09032c27b2c8d69d8430d7ea0551 Mon Sep 17 00:00:00 2001 From: Robby Russell Date: Wed, 23 Sep 2009 07:43:36 -0700 Subject: Moving all zsh config options into a lib/ subdirectory to make way for some upcoming changes to directory structure and configuration options --- aliases.zsh | 43 ----------------------------------- colors.zsh | 4 ---- completion.zsh | 30 ------------------------- functions.zsh | 59 ------------------------------------------------- git.zsh | 25 --------------------- grep.zsh | 6 ----- history.zsh | 15 ------------- key-bindings.zsh | 14 ------------ lib/aliases.zsh | 43 +++++++++++++++++++++++++++++++++++ lib/colors.zsh | 4 ++++ lib/completion.zsh | 30 +++++++++++++++++++++++++ lib/functions.zsh | 59 +++++++++++++++++++++++++++++++++++++++++++++++++ lib/git.zsh | 25 +++++++++++++++++++++ lib/grep.zsh | 6 +++++ lib/history.zsh | 15 +++++++++++++ lib/key-bindings.zsh | 14 ++++++++++++ lib/prompt.zsh | 32 +++++++++++++++++++++++++++ lib/rake_completion.zsh | 42 +++++++++++++++++++++++++++++++++++ oh-my-zsh.sh | 2 +- prompt.zsh | 32 --------------------------- rake_completion.zsh | 42 ----------------------------------- 21 files changed, 271 insertions(+), 271 deletions(-) delete mode 100644 aliases.zsh delete mode 100644 colors.zsh delete mode 100644 completion.zsh delete mode 100644 functions.zsh delete mode 100644 git.zsh delete mode 100644 grep.zsh delete mode 100644 history.zsh delete mode 100644 key-bindings.zsh create mode 100644 lib/aliases.zsh create mode 100644 lib/colors.zsh create mode 100644 lib/completion.zsh create mode 100644 lib/functions.zsh create mode 100644 lib/git.zsh create mode 100644 lib/grep.zsh create mode 100644 lib/history.zsh create mode 100644 lib/key-bindings.zsh create mode 100644 lib/prompt.zsh create mode 100644 lib/rake_completion.zsh delete mode 100644 prompt.zsh delete mode 100644 rake_completion.zsh diff --git a/aliases.zsh b/aliases.zsh deleted file mode 100644 index 253c2ac64..000000000 --- a/aliases.zsh +++ /dev/null @@ -1,43 +0,0 @@ -alias pu='pushd' -alias po='popd' - -alias sc='ruby script/console' -alias sd='ruby script/server --debugger' -alias ss='thin --stats "/thin/stats" start' - -alias mr='mate CHANGELOG app config db lib public script spec test' -alias .='pwd' -alias ...='cd ../..' - -alias _='sudo' - -#alias g='grep -in' - -alias g='git' -alias gst='git status' -alias gl='git pull' -alias gp='git push' -alias gd='git diff | mate' -alias gc='git commit -v' -alias gca='git commit -v -a' -alias gb='git branch' -alias gba='git branch -a' - -alias history='fc -l 1' - -alias ls='ls -F' -alias ll='ls -al' - -alias sgem='sudo gem' - -alias rfind='find . -name *.rb | xargs grep -n' - -alias git-svn-dcommit-push='git svn dcommit && git push github master:svntrunk' - -alias et='mate . &' -alias ett='mate app config lib db public spec test Rakefile Capfile Todo &' -alias etp='mate app config lib db public spec test vendor/plugins vendor/gems Rakefile Capfile Todo &' -alias etts='mate app config lib db public script spec test vendor/plugins vendor/gems Rakefile Capfile Todo &' - - - diff --git a/colors.zsh b/colors.zsh deleted file mode 100644 index b2b08f929..000000000 --- a/colors.zsh +++ /dev/null @@ -1,4 +0,0 @@ -autoload colors; colors; - -unset LSCOLORS -export LS_COLORS='di=34:ln=35:so=32:pi=33:ex=31:bd=46;34:cd=43;34:su=41;30:sg=46;30:tw=42;30:ow=43;30' diff --git a/completion.zsh b/completion.zsh deleted file mode 100644 index dff71cfd3..000000000 --- a/completion.zsh +++ /dev/null @@ -1,30 +0,0 @@ -setopt noautomenu -setopt COMPLETE_IN_WORD -setopt ALWAYS_TO_END - -unsetopt flowcontrol - -WORDCHARS='' - -autoload -U compinit -compinit - -zmodload -i zsh/complist - -## case-insensitive (all),partial-word and then substring completion -zstyle ':completion:*' matcher-list 'm:{a-zA-Z}={A-Za-z}' 'r:|[._-]=* r:|=*' 'l:|=* r:|=*' - -zstyle ':completion:*' list-colors '' -zstyle ':completion:*' hosts $( sed 's/[, ].*$//' $HOME/.ssh/known_hosts ) - -unsetopt MENU_COMPLETE -setopt AUTO_MENU - -bindkey -M menuselect '^o' accept-and-infer-next-history - -zstyle ':completion:*:*:*:*:*' menu yes select -# zstyle ':completion:*:*:*:*:processes' force-list always - -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" -zstyle ':completion:*:*:(ssh|scp):*:*' hosts `sed 's/^\([^ ,]*\).*$/\1/' ~/.ssh/known_hosts` diff --git a/functions.zsh b/functions.zsh deleted file mode 100644 index e3891f6fc..000000000 --- a/functions.zsh +++ /dev/null @@ -1,59 +0,0 @@ -function title { - if [[ $TERM == "screen" ]]; then - # Use these two for GNU Screen: - print -nR $'\033k'$1$'\033'\\\ - - print -nR $'\033]0;'$2$'\a' - elif [[ $TERM == "xterm" || $TERM == "rxvt" ]]; then - # Use this one instead for XTerms: - print -nR $'\033]0;'$*$'\a' - fi -} - -function precmd { - title zsh "$PWD" -} - -function preexec { - emulate -L zsh - local -a cmd; cmd=(${(z)1}) - title $cmd[1]:t "$cmd[2,-1]" -} - -function remote_console() { - /usr/bin/env ssh $1 "( cd $2 && ruby script/console production )" -} - -function zsh_stats() { - history | awk '{print $2}' | sort | uniq -c | sort -rn | head -} - -function uninstall_oh_my_zsh() { - /bin/sh $ZSH/tools/uninstall.sh -} - -function upgrade_oh_my_zsh() { - /bin/sh $ZSH/tools/upgrade.sh -} - -function tab() { - osascript 2>/dev/null < /dev/null) || return - echo "$ZSH_THEME_GIT_PROMPT_PREFIX${ref#refs/heads/}$(parse_git_dirty)$ZSH_THEME_GIT_PROMPT_SUFFIX" -} - -parse_git_dirty () { - if [[ $(git status | tail -n1) != "nothing to commit (working directory clean)" ]]; then - echo "$ZSH_THEME_GIT_PROMPT_DIRTY" - else - echo "$ZSH_THEME_GIT_PROMPT_CLEAN" - fi -} - diff --git a/grep.zsh b/grep.zsh deleted file mode 100644 index 93c4270b6..000000000 --- a/grep.zsh +++ /dev/null @@ -1,6 +0,0 @@ -# -# Color grep results -# Examples: http://rubyurl.com/ZXv -# -export GREP_OPTIONS='--color=auto' -export GREP_COLOR='1;32' \ No newline at end of file diff --git a/history.zsh b/history.zsh deleted file mode 100644 index a093aa27c..000000000 --- a/history.zsh +++ /dev/null @@ -1,15 +0,0 @@ -# History stuff. -setopt HIST_VERIFY -setopt INC_APPEND_HISTORY -setopt SHARE_HISTORY -setopt EXTENDED_HISTORY -setopt HIST_IGNORE_DUPS - -## Command history configuration -# -HISTFILE=$ZSH/log/.zsh_history -HISTSIZE=2500 -SAVEHIST=2500 -setopt hist_ignore_dups # ignore duplication command history list -setopt share_history # share command history data - diff --git a/key-bindings.zsh b/key-bindings.zsh deleted file mode 100644 index 20caad11f..000000000 --- a/key-bindings.zsh +++ /dev/null @@ -1,14 +0,0 @@ -# TODO: Explain what some of this does.. -autoload -U compinit -compinit -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 \ No newline at end of file diff --git a/lib/aliases.zsh b/lib/aliases.zsh new file mode 100644 index 000000000..253c2ac64 --- /dev/null +++ b/lib/aliases.zsh @@ -0,0 +1,43 @@ +alias pu='pushd' +alias po='popd' + +alias sc='ruby script/console' +alias sd='ruby script/server --debugger' +alias ss='thin --stats "/thin/stats" start' + +alias mr='mate CHANGELOG app config db lib public script spec test' +alias .='pwd' +alias ...='cd ../..' + +alias _='sudo' + +#alias g='grep -in' + +alias g='git' +alias gst='git status' +alias gl='git pull' +alias gp='git push' +alias gd='git diff | mate' +alias gc='git commit -v' +alias gca='git commit -v -a' +alias gb='git branch' +alias gba='git branch -a' + +alias history='fc -l 1' + +alias ls='ls -F' +alias ll='ls -al' + +alias sgem='sudo gem' + +alias rfind='find . -name *.rb | xargs grep -n' + +alias git-svn-dcommit-push='git svn dcommit && git push github master:svntrunk' + +alias et='mate . &' +alias ett='mate app config lib db public spec test Rakefile Capfile Todo &' +alias etp='mate app config lib db public spec test vendor/plugins vendor/gems Rakefile Capfile Todo &' +alias etts='mate app config lib db public script spec test vendor/plugins vendor/gems Rakefile Capfile Todo &' + + + diff --git a/lib/colors.zsh b/lib/colors.zsh new file mode 100644 index 000000000..b2b08f929 --- /dev/null +++ b/lib/colors.zsh @@ -0,0 +1,4 @@ +autoload colors; colors; + +unset LSCOLORS +export LS_COLORS='di=34:ln=35:so=32:pi=33:ex=31:bd=46;34:cd=43;34:su=41;30:sg=46;30:tw=42;30:ow=43;30' diff --git a/lib/completion.zsh b/lib/completion.zsh new file mode 100644 index 000000000..dff71cfd3 --- /dev/null +++ b/lib/completion.zsh @@ -0,0 +1,30 @@ +setopt noautomenu +setopt COMPLETE_IN_WORD +setopt ALWAYS_TO_END + +unsetopt flowcontrol + +WORDCHARS='' + +autoload -U compinit +compinit + +zmodload -i zsh/complist + +## case-insensitive (all),partial-word and then substring completion +zstyle ':completion:*' matcher-list 'm:{a-zA-Z}={A-Za-z}' 'r:|[._-]=* r:|=*' 'l:|=* r:|=*' + +zstyle ':completion:*' list-colors '' +zstyle ':completion:*' hosts $( sed 's/[, ].*$//' $HOME/.ssh/known_hosts ) + +unsetopt MENU_COMPLETE +setopt AUTO_MENU + +bindkey -M menuselect '^o' accept-and-infer-next-history + +zstyle ':completion:*:*:*:*:*' menu yes select +# zstyle ':completion:*:*:*:*:processes' force-list always + +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" +zstyle ':completion:*:*:(ssh|scp):*:*' hosts `sed 's/^\([^ ,]*\).*$/\1/' ~/.ssh/known_hosts` diff --git a/lib/functions.zsh b/lib/functions.zsh new file mode 100644 index 000000000..e3891f6fc --- /dev/null +++ b/lib/functions.zsh @@ -0,0 +1,59 @@ +function title { + if [[ $TERM == "screen" ]]; then + # Use these two for GNU Screen: + print -nR $'\033k'$1$'\033'\\\ + + print -nR $'\033]0;'$2$'\a' + elif [[ $TERM == "xterm" || $TERM == "rxvt" ]]; then + # Use this one instead for XTerms: + print -nR $'\033]0;'$*$'\a' + fi +} + +function precmd { + title zsh "$PWD" +} + +function preexec { + emulate -L zsh + local -a cmd; cmd=(${(z)1}) + title $cmd[1]:t "$cmd[2,-1]" +} + +function remote_console() { + /usr/bin/env ssh $1 "( cd $2 && ruby script/console production )" +} + +function zsh_stats() { + history | awk '{print $2}' | sort | uniq -c | sort -rn | head +} + +function uninstall_oh_my_zsh() { + /bin/sh $ZSH/tools/uninstall.sh +} + +function upgrade_oh_my_zsh() { + /bin/sh $ZSH/tools/upgrade.sh +} + +function tab() { + osascript 2>/dev/null < /dev/null) || return + echo "$ZSH_THEME_GIT_PROMPT_PREFIX${ref#refs/heads/}$(parse_git_dirty)$ZSH_THEME_GIT_PROMPT_SUFFIX" +} + +parse_git_dirty () { + if [[ $(git status | tail -n1) != "nothing to commit (working directory clean)" ]]; then + echo "$ZSH_THEME_GIT_PROMPT_DIRTY" + else + echo "$ZSH_THEME_GIT_PROMPT_CLEAN" + fi +} + diff --git a/lib/grep.zsh b/lib/grep.zsh new file mode 100644 index 000000000..93c4270b6 --- /dev/null +++ b/lib/grep.zsh @@ -0,0 +1,6 @@ +# +# Color grep results +# Examples: http://rubyurl.com/ZXv +# +export GREP_OPTIONS='--color=auto' +export GREP_COLOR='1;32' \ No newline at end of file diff --git a/lib/history.zsh b/lib/history.zsh new file mode 100644 index 000000000..a093aa27c --- /dev/null +++ b/lib/history.zsh @@ -0,0 +1,15 @@ +# History stuff. +setopt HIST_VERIFY +setopt INC_APPEND_HISTORY +setopt SHARE_HISTORY +setopt EXTENDED_HISTORY +setopt HIST_IGNORE_DUPS + +## Command history configuration +# +HISTFILE=$ZSH/log/.zsh_history +HISTSIZE=2500 +SAVEHIST=2500 +setopt hist_ignore_dups # ignore duplication command history list +setopt share_history # share command history data + diff --git a/lib/key-bindings.zsh b/lib/key-bindings.zsh new file mode 100644 index 000000000..20caad11f --- /dev/null +++ b/lib/key-bindings.zsh @@ -0,0 +1,14 @@ +# TODO: Explain what some of this does.. +autoload -U compinit +compinit +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 \ No newline at end of file diff --git a/lib/prompt.zsh b/lib/prompt.zsh new file mode 100644 index 000000000..31c33feb5 --- /dev/null +++ b/lib/prompt.zsh @@ -0,0 +1,32 @@ +export PAGER=less +export LC_CTYPE=en_US.UTF-8 + +bindkey -e + +# Directory stuff. +setopt AUTO_NAME_DIRS + +# Speed stuff. + +#setopt NO_BEEP +setopt AUTO_CD +setopt MULTIOS +setopt CDABLEVARS + +bindkey -e + +if [[ x$WINDOW != x ]] +then + SCREEN_NO="%B$WINDOW%b " +else + SCREEN_NO="" +fi + +PS1="%n@%m:%~%# " + +# Setup the prompt with pretty colors +setopt prompt_subst + +export LSCOLORS="Gxfxcxdxbxegedabagacad" + +source "$ZSH/themes/$ZSH_THEME.zsh-theme" diff --git a/lib/rake_completion.zsh b/lib/rake_completion.zsh new file mode 100644 index 000000000..c425a625e --- /dev/null +++ b/lib/rake_completion.zsh @@ -0,0 +1,42 @@ +_rake_does_task_list_need_generating () { + if [ ! -f .rake_tasks~ ]; then return 0; + else + accurate=$(stat -f%m .rake_tasks~) + changed=$(stat -f%m Rakefile) + return $(expr $accurate '>=' $changed) + fi +} + +_rake () { + if [ -f Rakefile ]; then + if _rake_does_task_list_need_generating; then + echo "\nGenerating .rake_tasks~..." > /dev/stderr + rake --silent --tasks | cut -d " " -f 2 > .rake_tasks~ + fi + compadd `cat .rake_tasks~` + fi +} + +compctl -K _rake rake + +function _cap_does_task_list_need_generating () { + if [ ! -f .cap_tasks~ ]; then return 0; + else + accurate=$(stat -f%m .cap_tasks~) + changed=$(stat -f%m config/deploy.rb) + return $(expr $accurate '>=' $changed) + fi +} + +function _cap () { + if [ -f config/deploy.rb ]; then + if _cap_does_task_list_need_generating; then + echo "\nGenerating .cap_tasks~..." > /dev/stderr + cap show_tasks -q | cut -d " " -f 1 | sed -e '/^ *$/D' -e '1,2D' +> .cap_tasks~ + fi + compadd `cat .cap_tasks~` + fi +} + +compctl -K _cap cap diff --git a/oh-my-zsh.sh b/oh-my-zsh.sh index b931f558a..40c73cb49 100644 --- a/oh-my-zsh.sh +++ b/oh-my-zsh.sh @@ -2,4 +2,4 @@ # Load all of the config files in ~/oh-my-zsh that end in .zsh # TIP: Add files you don't want in git to .gitignore -for config_file ($ZSH/*.zsh) source $config_file +for config_file ($ZSH/lib/*.zsh) source $config_file diff --git a/prompt.zsh b/prompt.zsh deleted file mode 100644 index 31c33feb5..000000000 --- a/prompt.zsh +++ /dev/null @@ -1,32 +0,0 @@ -export PAGER=less -export LC_CTYPE=en_US.UTF-8 - -bindkey -e - -# Directory stuff. -setopt AUTO_NAME_DIRS - -# Speed stuff. - -#setopt NO_BEEP -setopt AUTO_CD -setopt MULTIOS -setopt CDABLEVARS - -bindkey -e - -if [[ x$WINDOW != x ]] -then - SCREEN_NO="%B$WINDOW%b " -else - SCREEN_NO="" -fi - -PS1="%n@%m:%~%# " - -# Setup the prompt with pretty colors -setopt prompt_subst - -export LSCOLORS="Gxfxcxdxbxegedabagacad" - -source "$ZSH/themes/$ZSH_THEME.zsh-theme" diff --git a/rake_completion.zsh b/rake_completion.zsh deleted file mode 100644 index c425a625e..000000000 --- a/rake_completion.zsh +++ /dev/null @@ -1,42 +0,0 @@ -_rake_does_task_list_need_generating () { - if [ ! -f .rake_tasks~ ]; then return 0; - else - accurate=$(stat -f%m .rake_tasks~) - changed=$(stat -f%m Rakefile) - return $(expr $accurate '>=' $changed) - fi -} - -_rake () { - if [ -f Rakefile ]; then - if _rake_does_task_list_need_generating; then - echo "\nGenerating .rake_tasks~..." > /dev/stderr - rake --silent --tasks | cut -d " " -f 2 > .rake_tasks~ - fi - compadd `cat .rake_tasks~` - fi -} - -compctl -K _rake rake - -function _cap_does_task_list_need_generating () { - if [ ! -f .cap_tasks~ ]; then return 0; - else - accurate=$(stat -f%m .cap_tasks~) - changed=$(stat -f%m config/deploy.rb) - return $(expr $accurate '>=' $changed) - fi -} - -function _cap () { - if [ -f config/deploy.rb ]; then - if _cap_does_task_list_need_generating; then - echo "\nGenerating .cap_tasks~..." > /dev/stderr - cap show_tasks -q | cut -d " " -f 1 | sed -e '/^ *$/D' -e '1,2D' -> .cap_tasks~ - fi - compadd `cat .cap_tasks~` - fi -} - -compctl -K _cap cap -- cgit v1.2.3-70-g09d2