Prezto support! Make sure you run rake:install

This commit is contained in:
Yan Pritzker 2012-09-26 10:23:39 -07:00
commit ae2076bfd1
20 changed files with 112 additions and 262 deletions

3
.gitmodules vendored
View File

@ -338,3 +338,6 @@
[submodule "vim/bundle/chrisbra-NrrwRgn"]
path = vim/bundle/chrisbra-NrrwRgn
url = https://github.com/chrisbra/NrrwRgn
[submodule "zsh/prezto"]
path = zsh/prezto
url = git://github.com/sorin-ionescu/prezto.git

View File

@ -109,24 +109,16 @@ If that doesn't work, move the OSX supplied ctags [like so](http://www.mattpolit
sudo mv /usr/bin/ctags /usr/bin/ctags_original
```
### [oh-my-zsh](https://github.com/sorin-ionescu/prezto)
```bash
git clone --recursive git://github.com/sorin-ionescu/prezto.git ~/.oh-my-zsh
```
We prefer the @sorin-ionescu rewrite of Oh My Zsh. It will eventually be shipped
as a submodule of YADR, although you can use the original @robbyrussell version as well.
You only need to do the one command above. The rest of the installation is done
by YADR, which ships with a tie-in to sorin's OMZ.
### [fasd](https://github.com/clvv/fasd)
fasd gives you handy shell commands `f`,`a`,`s`,`d`, and `z` to jump to recently used files.
Read more at the project's home page. Or just type `z` followed by a partial reference to
a recent directory to see how it works.
fasd is currently shipped with yadr in the bin directory.
In the future it will be included as a submodule.
## Installation
Installation is automated via `rake` and the `yadr` command. To get
@ -171,6 +163,22 @@ mnemonic aliases. Please feel free to edit them:
ae # alias edit
ar # alias reload
### [ZSH Customizations & Prezto](https://github.com/sorin-ionescu/prezto)
For a more complete Zsh experience we use **[Prezto](http://github.com/sorin-ionescu/prezto)**.
Prezto is included as a submodule.
If you want to customize your zsh experience, yadr provides two hooks via ~/.zsh.after/ and ~/.zsh.before/ directories.
In these directories, you can place files to customize things that load before and after other zsh customizations that come from ~/.yadr/zsh/*
For example, to override the theme, you can do something like this:
```
mkdir ~/.zsh.after
echo "prompt skwp" > ~/.zsh.after/prompt.zsh
```
Next time you load your shell, this file will be read and your prompt will be the skwp prompt. Use `prompt -l` to see the available prompts.
### ZSH Customizations
* Vim mode
@ -178,22 +186,6 @@ mnemonic aliases. Please feel free to edit them:
* Ctrl-x,Ctrl-l to insert output of last command
* Fuzzy matching - if you mistype a directory name, tab completion will fix it
### How To Customize ZSH
YADR allows you to completely customize your ZSH without having to fork and maintain the project. Here's how it works: YADR will
source (include) any files in `.yadr/custom/zsh/before/*` or `.yadr/custom/zsh/after/*`. The `before` files are
useful for setting the theme and plugins. `after` files allow you to override options set by YADR, define your own aliases, etc.
To make your life easier, create a `zsh` folder in your Dropbox (or as a git repo) and symlink it into `~/.yadr/custom`. Do it like this:
```bash
ln -s ~/Dropbox/path/to/zsh ~/.yadr/custom/zsh
```
Create as many `before/whatever.zsh` or `after/whatever.zsh` files as you need within the `zsh` directory. Please see `custom/zsh.sample` for
an example.
## Pry
Pry (http://pry.github.com/) offers a much better out of the box IRB experience
@ -563,7 +555,7 @@ and other places for the cream of the crop of vim awesomeness.
* https://github.com/tpope
* https://github.com/scrooloose
* https://github.com/kana
* https://github.com/robbyrussell
* https://github.com/sorin-ionescu
* https://github.com/nelstrom
And everything that's in the modules included in vim/bundle of course.
@ -574,6 +566,7 @@ Please explore these people's work.
* Initial Version: @skwp
* Cleanup, auto installer: @kylewest
* Switch from oh-my-zsh to Presto: @JeanMertz
### For more tips and tricks

119
Rakefile
View File

@ -9,60 +9,21 @@ task :install => [:submodules] do
puts "be overwritten without your consent."
puts "======================================================"
puts
# this has all the linkables from this directory.
linkables = []
linkables += Dir.glob('git/*') if want_to_install?('git')
linkables += Dir.glob('irb/*') if want_to_install?('irb/pry')
linkables += Dir.glob('ruby/*') if want_to_install?('ruby (gems)')
linkables += Dir.glob('ctags/*') if want_to_install?('ctags config (better js/ruby support)')
linkables += Dir.glob('vimify/*') if want_to_install?('vimification of mysql/irb/command line')
linkables += Dir.glob('{vim,vimrc}') if want_to_install?('vim')
linkables += Dir.glob('zsh/zshrc') if want_to_install?('zsh')
Rake::Task['zsh_themes'].invoke
# this has all the runcoms from this directory.
file_operation(Dir.glob('git/*')) if want_to_install?('git configs (color, aliases)')
file_operation(Dir.glob('irb/*')) if want_to_install?('irb/pry configs (more colorful)')
file_operation(Dir.glob('ruby/*')) if want_to_install?('rubygems config (faster/no docs)')
file_operation(Dir.glob('ctags/*')) if want_to_install?('ctags config (better js/ruby support)')
file_operation(Dir.glob('vimify/*')) if want_to_install?('vimification of command line tools')
file_operation(Dir.glob('{vim,vimrc}')) if want_to_install?('vim configuration (highly recommended)')
skip_all = false
overwrite_all = false
backup_all = false
linkables.each do |linkable|
file = linkable.split('/').last
source = "#{ENV["PWD"]}/#{linkable}"
target = "#{ENV["HOME"]}/.#{file}"
puts "--------"
puts "file: #{file}"
puts "source: #{source}"
puts "target: #{target}"
if File.exists?(target) || File.symlink?(target)
unless skip_all || overwrite_all || backup_all
puts "File already exists: #{target}, what do you want to do? [s]kip, [S]kip all, [o]verwrite, [O]verwrite all, [b]ackup, [B]ackup all"
case STDIN.gets.chomp
when 'o' then overwrite = true
when 'b' then backup = true
when 'O' then overwrite_all = true
when 'B' then backup_all = true
when 'S' then skip_all = true
end
end
FileUtils.rm_rf(target) if overwrite || overwrite_all
run %{ mv "$HOME/.#{file}" "$HOME/.#{file}.backup" } if backup || backup_all
end
run %{ ln -s "#{source}" "#{target}" }
if want_to_install?('zsh enhancements & prezto')
install_prezto
end
success_msg("installed")
end
task :zsh_themes do
if File.exist?("#{ENV['HOME']}/.oh-my-zsh/modules/prompt/functions")
puts "Detected prezto (oh-my-zsh @sorin-ionescu)."
run %{ ln -nfs #{ENV["PWD"]}/oh-my-zsh/modules/prompt/functions/* $HOME/.oh-my-zsh/modules/prompt/functions/ } if want_to_install?('zsh themes')
elsif File.exist?("#{ENV['HOME']}/.oh-my-zsh")
puts "Detected oh-my-zsh @robbyrussell."
run %{ ln -nfs #{ENV["PWD"]}/oh-my-zsh/themes/* $HOME/.oh-my-zsh/themes/ } if want_to_install?('zsh themes')
end
end
desc "Init and update submodules."
task :submodules do
sh('git submodule update --init')
@ -78,11 +39,71 @@ def run(cmd)
`#{cmd}` unless ENV['DEBUG']
end
def install_prezto
puts "Installing Prezto (ZSH Enhancements)..."
unless File.exists?(File.join(ENV['ZDOTDIR'] || ENV['HOME'], ".zprezto"))
run %{ ln -nfs "$HOME/.yadr/zsh/prezto" "${ZDOTDIR:-$HOME}/.zprezto" }
end
file_operation(Dir.glob('zsh/prezto/runcoms/z*'), :copy)
puts "Installing YADR themes for Prezto..."
run %{ ln -nfs $HOME/.yadr/zsh/prezto-themes/modules/prompt/functions/* $HOME/.zprezto/modules/prompt/functions}
end
def want_to_install? (section)
puts "Would you like to install configuration files for: #{section}? [y]es, [n]o"
STDIN.gets.chomp == 'y'
end
def file_operation(files, method = :symlink)
skip_all = false
overwrite_all = false
backup_all = false
files.each do |f|
file = f.split('/').last
source = "#{ENV["PWD"]}/#{f}"
target = "#{ENV["HOME"]}/.#{file}"
puts "--------"
puts "file: #{file}"
puts "source: #{source}"
puts "target: #{target}"
if File.exists?(target) || File.symlink?(target)
unless skip_all || overwrite_all || backup_all
puts "File already exists: #{target}, what do you want to do? [s]kip, [S]kip all, [o]verwrite, [O]verwrite all, [b]ackup, [B]ackup all"
case STDIN.gets.chomp
when 'o' then overwrite = true when 'b' then backup = true
when 'O' then overwrite_all = true
when 'B' then backup_all = true
when 'S' then skip_all = true
end
end
FileUtils.rm_rf(target) if overwrite || overwrite_all
run %{ mv "$HOME/.#{file}" "$HOME/.#{file}.backup" } if backup || backup_all
end
if method == :symlink
run %{ ln -s "#{source}" "#{target}" }
else
run %{ cp -f "#{source}" "#{target}" }
end
# Temporary solution until we find a way to allow customization
# This modifies zshrc to load all of yadr's zsh extensions.
# Eventually yadr's zsh extensions should be ported to prezto modules.
if file == 'zshrc'
File.open(target, 'a') do |f|
f.puts('for config_file ($HOME/.yadr/zsh/*.zsh) source $config_file')
end
end
end
end
def success_msg(action)
puts ""
puts " _ _ _ "

View File

@ -1,20 +0,0 @@
#
# Samples of what you can do in *.after.zsh files.
# You can create as many files as you like, or put everything in one.
#
# define your own aliases or override those provided by YADR.
alias ls='ls -lAhFG'
alias hosts='sudo vim /private/etc/hosts'
# set or override options. two of my favorite are below.
# Automatically cd to frequently used directories http://robots.thoughtbot.com/post/10849086566/cding-to-frequently-used-directories-in-zsh
setopt auto_cd
cdpath=($HOME/Dropbox/code)
# Fancy globbing http://linuxshellaccount.blogspot.com/2008/07/fancy-globbing-with-zsh-on-linux-and.html
setopt extendedglob

View File

@ -1,16 +0,0 @@
#
# Samples of what you can do in *.before.zsh files.
# You can create as many files as you like, or put everything in one.
#
# append your own plugins. the $plugins at the end includes the plugins
# defined by YADR.
plugins=(osx ruby vagrant $plugins)
# ignore plugins defined by YADR and use your own list. Notice there is no
# $plugins at the end.
plugins=(osx ruby vagrant)
# set your theme.
export ZSH_THEME="kennethreitz"

1
functions Symbolic link
View File

@ -0,0 +1 @@
/Users/yan/.yadr/zsh/prezto-themes/modules/prompt/functions/* ~/.zprezto/modules/prompt/functions

View File

@ -1,7 +0,0 @@
The themes/ dir contains themes for oh-my-zsh Robby,
while modules contains themes for oh-my-zsh Sorin Ionescu.
The themes dir will eventually be deprecated in favor
of Sorin's OMZ branch.
See more at: https://github.com/sorin-ionescu/oh-my-zsh

Binary file not shown.

Before

Width:  |  Height:  |  Size: 85 KiB

View File

@ -1,30 +0,0 @@
function zle-line-init zle-keymap-select {
zle reset-prompt
}
zle -N zle-line-init
zle -N zle-keymap-select
bindkey -v
local return_code="%(?..%{$fg[red]%}%? ↵%{$reset_color%})"
ZSH_THEME_GIT_PROMPT_PREFIX="%{$reset_color%}- %{$fg[yellow]%}["
ZSH_THEME_GIT_PROMPT_SUFFIX="]%{$reset_color%} "
ZSH_THEME_GIT_PROMPT_CLEAN=""
ZSH_THEME_GIT_PROMPT_DIRTY="%{$fg[red]%}*%{$fg[yellow]%}"
ZSH_THEME_VI_MODE_COMMAND="%{$fg_bold[magenta]%}<#%{$reset_color%}"
ZSH_THEME_VI_MODE_INSERT="%{$fg_bold[green]%}$>%{$reset_color%}"
vi_mode_prompt_info () {
if [[ ${KEYMAP} = 'vicmd' ]]
then
echo $ZSH_THEME_VI_MODE_COMMAND
else
echo $ZSH_THEME_VI_MODE_INSERT
fi
}
PROMPT='%{$fg[green]%}%c $(git_prompt_info)$(vi_mode_prompt_info) '
PROMPT2='%{$fg[red]%}\ %{$reset_color%}'
RPS1='%{$fg[blue]%}%~%{$reset_color%} ${return_code} '

View File

@ -1,24 +0,0 @@
# Simple theme with RVM prompt
function preexec() {
typeset -gi CALCTIME=1
typeset -gi CMDSTARTTIME=SECONDS
}
function precmd() {
if (( CALCTIME )) ; then
typeset -gi ETIME=SECONDS-CMDSTARTTIME
fi
typeset -gi CALCTIME=0
}
function safe-rvm-prompt() {
if [[ -d ~/.rvm/ ]]; then
rvm-prompt
fi
}
PROMPT='%{$fg[blue]%}%~%{$fg_bold[yellow]%}$(git_prompt_info)%{$reset_color%}%{$fg[blue]%}➤ %{$reset_color%}'
RPROMPT='%{$fg[blue]%}$(safe-rvm-prompt i v p g) [${ETIME}s] %{$reset_color%}'
ZSH_THEME_GIT_PROMPT_PREFIX=" "
ZSH_THEME_GIT_PROMPT_SUFFIX=" "
ZSH_THEME_GIT_PROMPT_DIRTY=" ✗"
ZSH_THEME_GIT_PROMPT_CLEAN=" ✔"

4
zsh/0000_before.zsh Normal file
View File

@ -0,0 +1,4 @@
# Load any user customizations prior to load
if [ -d $HOME/.zsh.before/ ]; then
for config_file ($HOME/.zsh.before/*.zsh) source $config_file
fi

View File

@ -1,3 +1,3 @@
# path, the 0 in the filename causes this to load first
export PATH=/usr/local/sbin:/usr/local/bin:$PATH:$yadr/bin:$yadr/bin/yadr
export PATH=/usr/local/sbin:/usr/local/bin:$PATH:$HOME/.yadr/bin:$HOME/.yadr/bin/yadr

View File

@ -59,6 +59,7 @@ alias gunc='git uncommit'
alias gm='git merge'
alias gms='git merge --squash'
alias gam='git amend --reset-author'
alias grv='git remote -v'
alias gr='git rebase'
alias gra='git rebase --abort'
alias ggrc='git rebase --continue'

View File

@ -1,35 +0,0 @@
# Set the path to Oh My Zsh.
export OMZ="$HOME/.oh-my-zsh"
# Set the key mapping style to 'emacs' or 'vi'.
# zstyle ':omz:module:editor' keymap 'vi'
# Auto convert .... to ../..
zstyle ':omz:module:editor' dot-expansion 'no'
# Set case-sensitivity for completion, history lookup, etc.
zstyle ':omz:*:*' case-sensitive 'no'
# Color output (auto set to 'no' on dumb terminals).
zstyle ':omz:*:*' color 'yes'
# Auto set the tab and window titles.
zstyle ':omz:module:terminal' auto-title 'yes'
# Set the Zsh modules to load (man zshmodules).
# zstyle ':omz:load' zmodule 'attr' 'stat'
# Set the Zsh functions to load (man zshcontrib).
# zstyle ':omz:load' zfunction 'zargs' 'zmv'
# Set the Oh My Zsh modules to load (browse modules).
zstyle ':omz:load' omodule 'environment' 'terminal' 'editor' 'completion' \
'history' 'directory' 'spectrum' 'utility' 'prompt' 'history-substring-search'
# Set the prompt theme to load.
# Setting it to 'random' loads a random theme.
# Auto set to 'off' on dumb terminals.
zstyle ':omz:module:prompt' theme "$ZSH_THEME"
# This will make you shout: OH MY ZSHELL!
source "$OMZ/init.zsh"

1
zsh/prezto Submodule

@ -0,0 +1 @@
Subproject commit cc7e43b2422d044c98da2b5c5a1ebf6e8b2ac40d

View File

@ -0,0 +1,4 @@
modules/prompt/functions contains custom prompts for Prezto
These themes can be submitted to Prezto to be official. Until they are accepted, they can live here.
Learn more at: https://github.com/sorin-ionescu/prezto

1
zsh/theme.zsh Normal file
View File

@ -0,0 +1 @@
prompt skwp

View File

@ -1,51 +0,0 @@
# --------------------------------
#
# DO NOT EDIT THIS FILE.
# If you want to make changes, do so in the custom/zsh directory.
# Fork and send pull requests to add features and fix bugs. Thanks!
#
# ================================
# Don't change. The following determines where YADR is installed.
yadr=$HOME/.yadr
# Source oh-my-zsh if it is installed.
if [[ -d $HOME/.oh-my-zsh ]]; then
# Path to your oh-my-zsh configuration.
ZSH=$HOME/.oh-my-zsh
# Set name of the theme to load.
ZSH_THEME="skwp"
# 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=(vi-mode rvm ruby bundler zsh-syntax-highlighting history-substring-search)
# source every zsh file in user's custom/zsh/before. This is useful for setting theme and plugins.
if [[ -d $yadr/custom/zsh/before ]]; then
for config_file ($yadr/custom/zsh/before/*) source $config_file
fi
# Figure out if we have Robby's or Sorin's Oh-my-zsh
if [[ -f $ZSH/oh-my-zsh.sh ]]; then
source $ZSH/oh-my-zsh.sh # OMZ Robby Russell (https://github.com/robbyrussell/oh-my-zsh)
else
source $yadr/zsh/omz-sorin/omz-sorin.zsh # OMZ Sorin Ionescu (https://github.com/sorin-ionescu/oh-my-zsh)
fi
fi
# Configuration
for config_file ($yadr/zsh/*.zsh) source $config_file
# ------------------
# zsh/after
# ==================
# source every zsh file in user's custom/zsh/after.
if [[ -d $yadr/custom/zsh/after ]]; then
for config_file ($yadr/custom/zsh/after/*) source $config_file
fi
# Put secret configuration settings in ~/.secrets
if [[ -a ~/.secrets ]] then
source ~/.secrets
fi

4
zsh/zzzz_after.zsh Normal file
View File

@ -0,0 +1,4 @@
# Load any custom after code
if [ -d $HOME/.zsh.after/ ]; then
for config_file ($HOME/.zsh.after/*.zsh) source $config_file
fi