Skip to content
Browse files

switching to oh-my-zsh and removing custom zsh files

  • Loading branch information...
1 parent 5133b6c commit fc5740e9d356b947d7ef90c9d3867c611e2c3c1a @ryanb committed Jun 2, 2012
View
2 LICENSE
@@ -1,4 +1,4 @@
-Copyright (c) 2009 Ryan Bates
+Copyright (c) 2012 Ryan Bates
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
View
44 Rakefile
@@ -3,9 +3,11 @@ require 'erb'
desc "install the dot files into user's home directory"
task :install do
+ switch_to_zsh
+ install_oh_my_zsh
replace_all = false
Dir['*'].each do |file|
- next if %w[Rakefile README.rdoc LICENSE].include? file
+ next if %w[Rakefile README.rdoc LICENSE oh-my-zsh].include? file
if File.exist?(File.join(ENV['HOME'], ".#{file.sub('.erb', '')}"))
if File.identical? file, File.join(ENV['HOME'], ".#{file.sub('.erb', '')}")
@@ -48,3 +50,43 @@ def link_file(file)
system %Q{ln -s "$PWD/#{file}" "$HOME/.#{file}"}
end
end
+
+def switch_to_zsh
+ if ENV["SHELL"] =~ /zsh/
+ puts "using zsh"
+ else
+ print "switch to zsh? (recommended) [ynq] "
+ case $stdin.gets.chomp
+ when 'y'
+ puts "switching to zsh"
+ system %Q{chsh -s `which zsh`}
+ when 'q'
+ exit
+ else
+ puts "skipping zsh"
+ end
+ end
+end
+
+def install_oh_my_zsh
+ if File.exist?(File.join(ENV['HOME'], ".oh-my-zsh"))
+ puts "found ~/.oh-my-zsh"
+ else
+ print "install oh-my-zsh? [ynq] "
+ case $stdin.gets.chomp
+ when 'y'
+ puts "installing oh-my-zsh"
+ system %Q{git clone https://github.com/robbyrussell/oh-my-zsh.git #{File.join(ENV['HOME'], ".oh-my-zsh")}}
+ when 'q'
+ exit
+ else
+ puts "skipping oh-my-zsh, you will need to change ~/.zshrc"
+ end
+ end
+ if File.exist?(File.join(ENV['HOME'], ".oh-my-zsh")) && !File.exist?(File.join(ENV['HOME'], ".oh-my-zsh", "custom", "plugins", "rbates"))
+ system %Q{mkdir -p "$HOME/.oh-my-zsh/custom/plugins/rbates"}
+ %w[oh-my-zsh/custom/plugins/rbates oh-my-zsh/custom/rbates.zsh-theme].each |file|
+ system %Q{ln -s "$PWD/#{file}" "$HOME/.#{file}"}
+ end
+ end
+end
View
4 oh-my-zsh/custom/plugins/rbates.zsh-theme
@@ -0,0 +1,4 @@
+PROMPT='%3~$(git_prompt_info)%# '
+
+ZSH_THEME_GIT_PROMPT_PREFIX="["
+ZSH_THEME_GIT_PROMPT_SUFFIX="]"
View
8 oh-my-zsh/custom/plugins/rbates/_rake
@@ -0,0 +1,8 @@
+#compdef rake
+if [[ -f Rakefile ]]; then
+ local recent=$(ls -t .rake_tasks~ Rakefile **/*.rake | head -n 1)
+ if [[ $recent != .rake_tasks~ ]]; then
+ rake --tasks | cut -d ' ' -f 2 > .rake_tasks~
+ fi
+ compadd $(cat .rake_tasks~)
+fi
View
3 oh-my-zsh/custom/plugins/rbates/rbates.plugin.zsh
@@ -0,0 +1,3 @@
+c() { cd ~/code/$1; }
+_c() { _files -W ~/code -/; }
+compdef _c c
View
5 zlogin
@@ -1,5 +0,0 @@
-# go to saved path if there is one
-if [[ -f ~/.current_path~ ]]; then
- cd `cat ~/.current_path~`
- rm ~/.current_path~
-fi
View
33 zsh/aliases
@@ -1,33 +0,0 @@
-# cd
-alias ..='cd ..'
-
-# ls
-alias ls="ls -F"
-alias l="ls -lAh"
-alias ll="ls -l"
-alias la='ls -A'
-
-# git
-alias gl='git pull'
-alias gp='git push'
-alias gd='git diff'
-alias gc='git commit'
-alias gca='git commit -a'
-alias gco='git checkout'
-alias gb='git branch'
-alias gs='git status'
-alias grm="git status | grep deleted | awk '{print \$3}' | xargs git rm"
-alias changelog='git log `git log -1 --format=%H -- CHANGELOG*`..; cat CHANGELOG*'
-
-# rails
-alias sc='script/console'
-alias ss='script/server'
-alias sg='script/generate'
-alias a='autotest -rails'
-alias tlog='tail -f log/development.log'
-alias scaffold='script/generate nifty_scaffold'
-alias migrate='rake db:migrate db:test:clone'
-alias rst='touch tmp/restart.txt'
-
-# commands starting with % for pasting from web
-alias %=' '
View
8 zsh/completion
@@ -1,8 +0,0 @@
-autoload -U compinit
-compinit
-
-# matches case insensitive for lowercase
-zstyle ':completion:*' matcher-list 'm:{a-z}={A-Z}'
-
-# pasting with tabs doesn't perform completion
-zstyle ':completion:*' insert-tab pending
View
46 zsh/config
@@ -1,46 +0,0 @@
-if [[ -n $SSH_CONNECTION ]]; then
- export PS1='%m:%3~$(git_info_for_prompt)%# '
-else
- export PS1='%3~$(git_info_for_prompt)%# '
-fi
-
-export EDITOR='mate_wait'
-export PATH="$HOME/bin:$HOME/.bin:/usr/local/homebrew/bin:/usr/local/bin:/usr/local/sbin:/usr/local/mysql/bin:/usr/local/git/bin:$PATH"
-export MANPATH="/usr/local/man:/usr/local/mysql/man:/usr/local/git/man:$MANPATH"
-
-fpath=(~/.zsh/functions $fpath)
-
-autoload -U ~/.zsh/functions/*(:t)
-
-HISTFILE=~/.zsh_history
-HISTSIZE=1000
-SAVEHIST=1000
-REPORTTIME=10 # print elapsed time when more than 10 seconds
-
-setopt NO_BG_NICE # don't nice background tasks
-setopt NO_HUP
-setopt NO_LIST_BEEP
-setopt LOCAL_OPTIONS # allow functions to have local options
-setopt LOCAL_TRAPS # allow functions to have local traps
-setopt HIST_VERIFY
-setopt SHARE_HISTORY # share history between sessions ???
-setopt EXTENDED_HISTORY # add timestamps to history
-setopt PROMPT_SUBST
-setopt CORRECT
-setopt COMPLETE_IN_WORD
-setopt IGNORE_EOF
-
-setopt APPEND_HISTORY # adds history
-setopt INC_APPEND_HISTORY SHARE_HISTORY # adds history incrementally and share it across sessions
-setopt HIST_IGNORE_ALL_DUPS # don't record dupes in history
-setopt HIST_REDUCE_BLANKS
-
-zle -N newtab
-
-bindkey '^[^[[D' backward-word
-bindkey '^[^[[C' forward-word
-bindkey '^[[5D' beginning-of-line
-bindkey '^[[5C' end-of-line
-bindkey '^[[3~' delete-char
-bindkey '^[^N' newtab
-bindkey '^?' backward-delete-char
View
65 zsh/functions/_brew
@@ -1,65 +0,0 @@
-#compdef brew
-
-# Brew ZSH completion function
-# Drop this somewhere in your $fpath (like /usr/share/zsh/site-functions)
-# and rename it _brew
-#
-# altered from _fink
-
-_brew_all_formulae() {
- formulae=(`brew search`)
-}
-
-_brew_installed_formulae() {
- installed_formulae=(`brew list`)
-}
-
-local -a _1st_arguments
-_1st_arguments=(
- 'install:install a formula'
- 'remove:remove a formula'
- 'search:search for a formula (/regex/ or string)'
- 'list:list files in a formula or not-installed formulae'
- 'link:link a formula'
- 'unlink:unlink a formula'
- 'home:visit the homepage of a formula or the brew project'
- 'info:information about a formula'
- 'prune:remove dead links'
- 'update:freshen up links'
- 'log:git commit log for a formula'
- 'create:create a new formula'
- 'edit:edit a formula'
-)
-
-local expl
-local -a formula installed_formulae
-
-_arguments \
- '(-v --verbose)'{-v,--verbose}'[verbose]' \
- '(--version)--version[version information]' \
- '(--prefix)--prefix[where brew lives on this system]' \
- '(--cache)--cache[brew cache]' \
- '*:: :->subcmds' && return 0
-
-if (( CURRENT == 1 )); then
- _describe -t commands "brew subcommand" _1st_arguments
- return
-fi
-
-case "$words[1]" in
- list)
- _arguments \
- '(--unbrewed)--unbrewed[files in brew --prefix not controlled by brew]' \
- '1: :->forms' && return 0
-
- if [[ "$state" == forms ]]; then
- _brew_installed_formulae
- _requested installed_formulae expl 'installed formulae' compadd -a installed_formulae
- fi ;;
- install|home|log|info)
- _brew_all_formulae
- _wanted formulae expl 'all formulae' compadd -a formulae ;;
- remove|edit|xo)
- _brew_installed_formulae
- _wanted installed_formulae expl 'installed formulae' compadd -a installed_formulae ;;
-esac
View
2 zsh/functions/_c
@@ -1,2 +0,0 @@
-#compdef c
-_files -W ~/code -/
View
8 zsh/functions/_cap
@@ -1,8 +0,0 @@
-#compdef cap
-if [ -f Capfile ]; then
- recent=`last_modified .cap_tasks~ Capfile **/deploy.rb`
- if [[ $recent != '.cap_tasks~' ]]; then
- cap --tasks | grep '#' | cut -d " " -f 2 > .cap_tasks~
- fi
- compadd `cat .cap_tasks~`
-fi
View
2 zsh/functions/_gh
@@ -1,2 +0,0 @@
-#compdef gh
-_github
View
7 zsh/functions/_git-rm
@@ -1,7 +0,0 @@
-#compdef git-rm
-_arguments -S -A '-*' \
- '-f[override the up-to-date check]' \
- "-n[don't actually remove the files, just show if they exist in the index]" \
- '-r[allow recursive removal when a leading directory-name is given]' \
- '--cached[only remove files from the index]' && ret=0
-_files
View
72 zsh/functions/_github
@@ -1,72 +0,0 @@
-#compdef github
-
-_github() {
- if (( CURRENT > 2 )); then
- # shift words so _arguments doesn't have to be concerned with second command
- (( CURRENT-- ))
- shift words
- # use _call_function here in case it doesn't exist
- _call_function 1 _github_${words[1]}
- else
- _values "github command" \
- "fetch[Fetch from a remote to a local branch.]" \
- "ignore[Ignore a SHA (from 'github network commits')]" \
- "fetch_all[Fetch all refs from a user]" \
- "info[Info about this project.]" \
- "browse[Open this repo in a web browser.]" \
- "home[Open this repo's master branch in a web browser.]" \
- "clone[Clone a repo.]" \
- "pull-request[Generate the text for a pull request.]" \
- "network[Project network tools.]" \
- "pull[Pull from a remote.]" \
- "track[Track another user's repository.]"
- fi
-}
-
-_github_pull() {
- _arguments \
- "--merge[Automatically merge remote's changes into your master.]"
-}
-_github_clone() {
- _arguments \
- "--ssh[Clone using the git@github.com style url.]"
-}
-
-_github_track() {
- _arguments \
- "--private[Use git@github.com: instead of git://github.com/.]" \
- "--ssh[Equivalent to --private.]"
-}
-
-_github_network() {
- if (( CURRENT > 2 )); then
- # shift words so _arguments doesn't have to be concerned with second command
- (( CURRENT-- ))
- shift words
- # use _call_function here in case it doesn't exist
- _call_function 1 _github_network_${words[1]}
- else
- _values "github network command" \
- "web[Open network in a web browser.]" \
- "list[List networked repositories.]" \
- "fetch[Fetched commits for a given networked repository.]" \
- "commits[List networked commits not pulled into this repo.]"
- fi
-}
-
-_github_network_commits() {
- _arguments \
- "--project[Filter commits on a certain project.]" \
- "--author[Filter commits on a email address of author.]" \
- "--common[Show common branch point.]" \
- "--nocache[Do not use the cached network data.]" \
- "--sort[How to sort : date(*), branch, author.]" \
- "--thisbranch[Look at branches that match the current one]" \
- "--applies[Filter commits to patches that apply cleanly.]" \
- "--limit[Only look through the first X heads - useful for really large projects]" \
- "--before[Only show commits before a certain date.]" \
- "--after[Only show commits after a certain date.]" \
- "--shas[Only show shas.]" \
- "--cache[Use the network data even if it's expired.]" \
- "--noapply[Filter commits to patches that do not apply cleanly.]"
-}
View
2 zsh/functions/_h
@@ -1,2 +0,0 @@
-#compdef h
-_files -W ~ -/
View
8 zsh/functions/_rake
@@ -1,8 +0,0 @@
-#compdef rake
-if [ -f Rakefile ]; then
- recent=`last_modified .rake_tasks~ Rakefile **/*.rake`
- if [[ $recent != '.rake_tasks~' ]]; then
- rake --silent --tasks | cut -d " " -f 2 > .rake_tasks~
- fi
- compadd `cat .rake_tasks~`
-fi
View
1 zsh/functions/c
@@ -1 +0,0 @@
-cd ~/code/$1;
View
1 zsh/functions/gam
@@ -1 +0,0 @@
-curl $1 | git am
View
1 zsh/functions/gfp
@@ -1 +0,0 @@
-git format-patch master --stdout > $1
View
48 zsh/functions/git_info_for_prompt
@@ -1,48 +0,0 @@
-local g="$(git rev-parse --git-dir 2>/dev/null)"
-if [ -n "$g" ]; then
- local r
- local b
- if [ -d "$g/../.dotest" ]
- then
- if test -f "$g/../.dotest/rebasing"
- then
- r="|REBASE"
- elif test -f "$g/../.dotest/applying"
- then
- r="|AM"
- else
- r="|AM/REBASE"
- fi
- b="$(git symbolic-ref HEAD 2>/dev/null)"
- elif [ -f "$g/.dotest-merge/interactive" ]
- then
- r="|REBASE-i"
- b="$(cat "$g/.dotest-merge/head-name")"
- elif [ -d "$g/.dotest-merge" ]
- then
- r="|REBASE-m"
- b="$(cat "$g/.dotest-merge/head-name")"
- elif [ -f "$g/MERGE_HEAD" ]
- then
- r="|MERGING"
- b="$(git symbolic-ref HEAD 2>/dev/null)"
- else
- if [ -f "$g/BISECT_LOG" ]
- then
- r="|BISECTING"
- fi
- if ! b="$(git symbolic-ref HEAD 2>/dev/null)"
- then
- if ! b="tag: $(git describe --exact-match HEAD 2>/dev/null)"
- then
- b="$(cut -c1-7 "$g/HEAD")..."
- fi
- fi
- fi
-
- if [ -n "$1" ]; then
- printf "$1" "${b##refs/heads/}$r"
- else
- printf "[%s]" "${b##refs/heads/}$r"
- fi
-fi
View
1 zsh/functions/h
@@ -1 +0,0 @@
-cd ~/$1;
View
1 zsh/functions/last_modified
@@ -1 +0,0 @@
-ls -t $* 2> /dev/null | head -n 1
View
26 zsh/functions/newtab
@@ -1,26 +0,0 @@
-savepath
-osascript >/dev/null <<EOF
-on do_submenu(app_name, menu_name, menu_item, submenu_item)
- -- bring the target application to the front
- tell application app_name
- activate
- end tell
- tell application "System Events"
- tell process app_name
- tell menu bar 1
- tell menu bar item menu_name
- tell menu menu_name
- tell menu item menu_item
- tell menu menu_item
- click menu item submenu_item
- end tell
- end tell
- end tell
- end tell
- end tell
- end tell
- end tell
-end do_submenu
-
-do_submenu("Terminal", "Shell", "New Tab", 1)
-EOF
View
1 zsh/functions/railsapp
@@ -1 +0,0 @@
-rails $2 -m http://github.com/ryanb/rails-templates/raw/master/$1.rb $*[3,-1]
View
1 zsh/functions/savepath
@@ -1 +0,0 @@
-pwd > ~/.current_path~
View
5 zsh/functions/verbose_completion
@@ -1,5 +0,0 @@
-zstyle ':completion:*' verbose yes
-zstyle ':completion:*:descriptions' format '%B%d%b'
-zstyle ':completion:*:messages' format '%d'
-zstyle ':completion:*:warnings' format 'No matches for: %d'
-zstyle ':completion:*' group-name ''
View
13 zshrc
@@ -1,6 +1,13 @@
-. ~/.zsh/config
-. ~/.zsh/aliases
-. ~/.zsh/completion
+ZSH=$HOME/.oh-my-zsh
+ZSH_THEME="rbates"
+DISABLE_AUTO_UPDATE="true"
+DISABLE_LS_COLORS="true"
+
+plugins=(git bundler brew gem rbates)
+
+source $ZSH/oh-my-zsh.sh
+
+export EDITOR='mate -w'
# use .localrc for settings specific to one system
[[ -f ~/.localrc ]] && . ~/.localrc

0 comments on commit fc5740e

Please sign in to comment.
Something went wrong with that request. Please try again.