summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorRobby Russell <robby@planetargon.com>2009-09-23 07:43:36 -0700
committerRobby Russell <robby@planetargon.com>2009-09-23 07:43:36 -0700
commit8debd097fbea09032c27b2c8d69d8430d7ea0551 (patch)
tree116ff17dfe29a5906b9a631efa1dd52b8165ec3d /lib
parent2759586aae5bea9ec38bb16403381c73589776ed (diff)
downloadzsh-8debd097fbea09032c27b2c8d69d8430d7ea0551.tar.gz
zsh-8debd097fbea09032c27b2c8d69d8430d7ea0551.tar.bz2
zsh-8debd097fbea09032c27b2c8d69d8430d7ea0551.zip
Moving all zsh config options into a lib/ subdirectory to make way for some upcoming changes to directory structure and configuration options
Diffstat (limited to 'lib')
-rw-r--r--lib/aliases.zsh43
-rw-r--r--lib/colors.zsh4
-rw-r--r--lib/completion.zsh30
-rw-r--r--lib/functions.zsh59
-rw-r--r--lib/git.zsh25
-rw-r--r--lib/grep.zsh6
-rw-r--r--lib/history.zsh15
-rw-r--r--lib/key-bindings.zsh14
-rw-r--r--lib/prompt.zsh32
-rw-r--r--lib/rake_completion.zsh42
10 files changed, 270 insertions, 0 deletions
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 <<EOF
+ tell application "System Events"
+ tell process "Terminal" to keystroke "t" using command down
+ end
+ tell application "Terminal"
+ activate
+ do script with command "cd $PWD; $*" in window 1
+ end tell
+EOF
+}
+
+function take() {
+ mkdir -p $1
+ cd $1
+}
+
+function tm() {
+ cd $1
+ mate $1
+}
diff --git a/lib/git.zsh b/lib/git.zsh
new file mode 100644
index 000000000..9409c92db
--- /dev/null
+++ b/lib/git.zsh
@@ -0,0 +1,25 @@
+# Varables for themeing the git info prompt:
+# ZSH_THEME_GIT_PROMPT_PREFIX - Prefix at the very beginning of the prompt, before the branch name
+# ZSH_THEME_GIT_PROMPT_SUFFIX - At the very end of the prompt
+# ZSH_THEME_GIT_PROMPT_DIRTY - Text to display if the branch is dirty
+# ZSH_THEME_GIT_PROMPT_CLEAN - Text to display if the branch is clean
+
+ZSH_THEME_GIT_PROMPT_PREFIX="git:("
+ZSH_THEME_GIT_PROMPT_SUFFIX=")"
+ZSH_THEME_GIT_PROMPT_DIRTY="*"
+ZSH_THEME_GIT_PROMPT_CLEAN=""
+
+# get the name of the branch we are on
+function git_prompt_info() {
+ ref=$(git symbolic-ref HEAD 2> /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