From 5da20b9dddb1f7a9110675ded5df59c4c3ed1b83 Mon Sep 17 00:00:00 2001 From: Robby Russell Date: Fri, 28 Aug 2009 11:14:17 -0700 Subject: [PATCH] Importing initial files after reorganizing stuff. --- README.textile | 8 ++++++++ aliases.zsh | 44 ++++++++++++++++++++++++++++++++++++++++++++ colors.zsh | 4 ++++ completion.zsh | 27 +++++++++++++++++++++++++++ functions.zsh | 26 ++++++++++++++++++++++++++ git.zsh | 19 +++++++++++++++++++ grep.zsh | 6 ++++++ history.zsh | 15 +++++++++++++++ projects.zsh-example | 5 +++++ prompt.zsh | 29 +++++++++++++++++++++++++++++ rake_completion.zsh | 42 ++++++++++++++++++++++++++++++++++++++++++ zshrc | 34 ++++++++++++++++++++++++++++++++++ 12 files changed, 259 insertions(+) create mode 100644 README.textile create mode 100644 aliases.zsh create mode 100644 colors.zsh create mode 100644 completion.zsh create mode 100644 functions.zsh create mode 100644 git.zsh create mode 100644 grep.zsh create mode 100644 history.zsh create mode 100644 projects.zsh-example create mode 100644 prompt.zsh create mode 100644 rake_completion.zsh create mode 100644 zshrc diff --git a/README.textile b/README.textile new file mode 100644 index 00000000..740070d8 --- /dev/null +++ b/README.textile @@ -0,0 +1,8 @@ +h2. Setup + +# Clone the repository to ~/zsh +# Symlink the zsh config with: @ln -s ~/zsh/zshrc .zshrc@ +# Reload zsh (open a new terminal) + + + diff --git a/aliases.zsh b/aliases.zsh new file mode 100644 index 00000000..2319823f --- /dev/null +++ b/aliases.zsh @@ -0,0 +1,44 @@ +alias c='cd' +alias pu='pushd' +alias po='popd' +alias sc='ruby script/console' +alias ss='ruby script/server' + +alias mr='mate CHANGELOG app config db lib public script spec test' +alias .='pwd' +alias ...='cd ../..' +alias ....='cd ../../..' +alias .....='cd ../../../..' +alias ......='cd ../../../../..' +alias .......='cd ../../../../../..' + +alias _='sudo' +alias ss='setsid' + +alias g='grep -in' + +alias s='svn' +alias e='mate' + +alias history='fc -l 1' + +# Git aliases + +alias utb='tar jxvf' +alias utz='tar zxvf' + +alias ls='ls -GF' +alias ll='ls -al' + +alias sgem='sudo gem' + +alias rfind='find . -name *.rb | xargs grep -n' + +alias xenon='ssh rrussell@xenon.planetargon.com' + +alias git-svn-dcommit-push='git svn dcommit && git push github master:svntrunk' + +bindkey '\ew' kill-region + +bindkey -s '\el' "ls\n" +bindkey -s '\e.' "..\n" \ No newline at end of file diff --git a/colors.zsh b/colors.zsh new file mode 100644 index 00000000..b2b08f92 --- /dev/null +++ b/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/completion.zsh b/completion.zsh new file mode 100644 index 00000000..e0edc763 --- /dev/null +++ b/completion.zsh @@ -0,0 +1,27 @@ +setopt noautomenu +setopt COMPLETE_IN_WORD +setopt ALWAYS_TO_END + +unsetopt flowcontrol + +WORDCHARS='' + +autoload -U compinit +compinit + +zmodload -i zsh/complist + +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 new file mode 100644 index 00000000..5c349e80 --- /dev/null +++ b/functions.zsh @@ -0,0 +1,26 @@ +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 )" +} \ No newline at end of file diff --git a/git.zsh b/git.zsh new file mode 100644 index 00000000..94409633 --- /dev/null +++ b/git.zsh @@ -0,0 +1,19 @@ +# get the name of the branch we are on +function git_prompt_info() { + ref=$(git symbolic-ref HEAD 2> /dev/null) || return + branch=${ref#refs/heads/} + + if [[ -d .git ]]; then + CURRENT_BRANCH="%{$fg[red]%}git:(%{$fg[green]${branch}%{$fg[red])" + else + CURRENT_BRANCH='' + fi + + + #echo "%{$fg[red]%}git:(%{$fg[green]$CURRENT_BRANCH%{$fg[red])" + echo $CURRENT_BRANCH +} + +parse_git_dirty () { + [[ $(git status | tail -n1) != "nothing to commit (working directory clean)" ]] && echo "%{$fg[white] ♻ " +} diff --git a/grep.zsh b/grep.zsh new file mode 100644 index 00000000..93c4270b --- /dev/null +++ b/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/history.zsh b/history.zsh new file mode 100644 index 00000000..a093aa27 --- /dev/null +++ b/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/projects.zsh-example b/projects.zsh-example new file mode 100644 index 00000000..28ffcae2 --- /dev/null +++ b/projects.zsh-example @@ -0,0 +1,5 @@ +# Add yourself some shortcuts to projects you often work on +# Example: +# +# brainstormr=/Users/robbyrussell/Projects/development/planetargon/brainstormr +# \ No newline at end of file diff --git a/prompt.zsh b/prompt.zsh new file mode 100644 index 00000000..a36e97f8 --- /dev/null +++ b/prompt.zsh @@ -0,0 +1,29 @@ +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" + +PROMPT='%{$fg_bold[red]%}➜ %{$fg_bold[green]%}%p %{$fg[cyan]%}%c %{$fg_bold[blue]%}$(git_prompt_info)%{$fg_bold[blue]%} % %{$reset_color%}' diff --git a/rake_completion.zsh b/rake_completion.zsh new file mode 100644 index 00000000..a94b4889 --- /dev/null +++ b/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 +} + +compdef _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 +} + +compdef _cap cap diff --git a/zshrc b/zshrc new file mode 100644 index 00000000..e2fd0fc5 --- /dev/null +++ b/zshrc @@ -0,0 +1,34 @@ +export EDITOR=/opt/local/bin/joe +export PAGER=less +export ZSH=$HOME/zsh +export LC_CTYPE=en_US.UTF-8 + +# TODO: Refactor this sometimes soon... +source $ZSH/colors.zsh +source $ZSH/aliases.zsh +source $ZSH/completion.zsh +source $ZSH/rake_completion.zsh +source $ZSH/functions.zsh +source $ZSH/git.zsh +source $ZSH/history.zsh +source $ZSH/grep.zsh +source $ZSH/prompt.zsh + +# Uncomment if you have a projects.zsh file +# source $ZSH/projects.zsh + +# Directory stuff. + +setopt AUTO_NAME_DIRS + +# Speed stuff. + +#setopt NO_BEEP +setopt AUTO_CD +setopt MULTIOS +setopt CDABLEVARS + +# Customize to your needs... +export PATH=~/bin:/opt/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/local/sbin:/opt/local/lib/postgresql83/bin + +