From 42104de0aa39d8548fda24250b04db4b99eb5b18 Mon Sep 17 00:00:00 2001 From: Kyle West Date: Wed, 25 Jan 2012 02:04:37 -0500 Subject: [PATCH] YADR can be installed to any directory and everything still works --- .yadr | 0 bin/yadr/default_libs.rb | 2 ++ bin/yadr/yadr | 4 ++-- bin/yadr/yadr-init-plugins | 2 +- bin/yadr/yadr-vim-add-plugin | 4 ++-- bin/yadr/yadr-vim-update-plugins | 7 +++---- zsh/aliases | 7 +++++-- zsh/oh_my_zsh_zshrc | 24 +----------------------- zsh/zshrc | 31 +++++++++++++++++++++++++------ 9 files changed, 41 insertions(+), 40 deletions(-) create mode 100644 .yadr mode change 100644 => 120000 zsh/oh_my_zsh_zshrc diff --git a/.yadr b/.yadr new file mode 100644 index 0000000..e69de29 diff --git a/bin/yadr/default_libs.rb b/bin/yadr/default_libs.rb index 900e095..09ba373 100755 --- a/bin/yadr/default_libs.rb +++ b/bin/yadr/default_libs.rb @@ -1,2 +1,4 @@ Dir[File.join(File.dirname(__FILE__),"lib/**/lib")].each {|dir| $LOAD_PATH << dir} require 'git-style-binary/command' + +$yadr = `find -L ~ -type file -maxdepth 2 -name .yadr | head | sed 's:\.yadr\/::'`.chomp diff --git a/bin/yadr/yadr b/bin/yadr/yadr index 6c706a5..c8db1c4 100755 --- a/bin/yadr/yadr +++ b/bin/yadr/yadr @@ -2,10 +2,10 @@ require File.join(File.dirname(__FILE__), 'default_libs') # GitStyleBinary.primary do -# +# # end # GitStyleBinary.command do -# version "yadr 1.0" +# version "yadr 1.0" # banner <<-EOS # Welcome to YADR, Yet Another Dotfile Repo Manager # Usage: yadr #{all_options_string} diff --git a/bin/yadr/yadr-init-plugins b/bin/yadr/yadr-init-plugins index 4529b08..c609235 100755 --- a/bin/yadr/yadr-init-plugins +++ b/bin/yadr/yadr-init-plugins @@ -6,7 +6,7 @@ GitStyleBinary.command do short_desc "Initialize all submodules. Run this every time you pull a new yadr version." run do |command| - system("cd ~/.dotfiles && git submodule init && git submodule update") + `cd "#{$yadr}" && git submodule update --init` end end diff --git a/bin/yadr/yadr-vim-add-plugin b/bin/yadr/yadr-vim-add-plugin index 31f0924..41a2fbb 100755 --- a/bin/yadr/yadr-vim-add-plugin +++ b/bin/yadr/yadr-vim-add-plugin @@ -2,7 +2,7 @@ require File.join(File.dirname(__FILE__), 'default_libs') GitStyleBinary.command do - version "yadr-add-vim-plugin 1.0" + version "yadr-add-vim-plugin 1.0" short_desc "Add a vim plugin from a github repo" opt :url, "Github url (http:// or git://)", :type => String @@ -14,7 +14,7 @@ GitStyleBinary.command do begin repo=command[:url] bundle_path=repo.gsub("https://github.com/","").gsub(".git","").gsub("/","-").gsub(".vim","") - system("cd ~/.dotfiles && git submodule add #{repo} vim/bundle/#{bundle_path}") + system("cd #{$yadr} && git submodule add #{repo} vim/bundle/#{bundle_path}") rescue puts "Sorry, couldn't parse your path: #{$!}" end diff --git a/bin/yadr/yadr-vim-update-plugins b/bin/yadr/yadr-vim-update-plugins index 235bd14..dbaef08 100755 --- a/bin/yadr/yadr-vim-update-plugins +++ b/bin/yadr/yadr-vim-update-plugins @@ -2,12 +2,11 @@ require File.join(File.dirname(__FILE__), 'default_libs') GitStyleBinary.command do - version "yadr-vim-update-plugins 1.0" - -short_desc "Update all vim plugins to latest versions from github" + version "yadr-vim-update-plugins 1.0" + short_desc "Update all vim plugins to latest versions from github" run do |command| - system("cd ~/.dotfiles && git submodule foreach git pull origin master") + `cd "#{$yadr}" && git submodule foreach git pull origin master` end end diff --git a/zsh/aliases b/zsh/aliases index 0fc9e47..64ea284 100644 --- a/zsh/aliases +++ b/zsh/aliases @@ -1,5 +1,8 @@ # Aliases in this file are bash and zsh compatible +# Don't change. The following determines where YADR is installed. +yadr=`find -L ~ -type file -maxdepth 2 -name .yadr | head | sed 's:\.yadr\/::'` + # YADR support alias yav='yadr vim-add-plugin' alias yuv='yadr vim-update-plugins' @@ -23,8 +26,8 @@ alias du='du -h -d 2' alias lsg='ll | grep' # Alias Editing -alias ae='vi ~/.dotfiles/zsh/aliases' #alias edit -alias ar='source ~/.dotfiles/zsh/aliases' #alias reload +alias ae='vi $yadr/zsh/aliases' #alias edit +alias ar='source $yadr/zsh/aliases' #alias reload # vimrc editing alias ve='vi ~/.vimrc' diff --git a/zsh/oh_my_zsh_zshrc b/zsh/oh_my_zsh_zshrc deleted file mode 100644 index 48ff99f..0000000 --- a/zsh/oh_my_zsh_zshrc +++ /dev/null @@ -1,23 +0,0 @@ -# Path to your oh-my-zsh configuration. -ZSH=$HOME/.oh-my-zsh - -# Set name of the theme to load. -# Look in ~/.oh-my-zsh/themes/ -# skwp theme comes from skwp/oh-my-zsh fork -ZSH_THEME="skwp" - -# Comment this out to disable weekly auto-update checks -DISABLE_AUTO_UPDATE="true" - -# 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=(git rvm ruby rails autojump) - -# Load default oh-my-zsh stuff -source $ZSH/oh-my-zsh.sh - -# Customize to your needs... -export PATH=/usr/local/git/bin:/op/local/bin:/opt/local/sbin:/usr/bin:/Users/yan/dev/cluster/script:/Users/yan/.bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin:/usr/local/git/bin:/opt/local/bin:/opt/local/lib/postgresql84/bin:/usr/local/bin:/Users/yan/dev/ec2/ec2-api/bin:/opt/local/lib/mysql5/bin:/Users/yan/.rvm/bin:/Users/yan/.dotfiles/bin:/Users/yan/.dotfiles/bin/willmorgan/bin - -# Load YADR zshrc -source ~/.dotfiles/zsh/zshrc diff --git a/zsh/oh_my_zsh_zshrc b/zsh/oh_my_zsh_zshrc new file mode 120000 index 0000000..c8b42f4 --- /dev/null +++ b/zsh/oh_my_zsh_zshrc @@ -0,0 +1 @@ +zshrc \ No newline at end of file diff --git a/zsh/zshrc b/zsh/zshrc index 129115d..88775bd 100644 --- a/zsh/zshrc +++ b/zsh/zshrc @@ -1,6 +1,25 @@ +# 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=(git rvm ruby rails autojump) + + # Load default oh-my-zsh stuff + source $ZSH/oh-my-zsh.sh +fi + +# Don't change. The following determines where YADR is installed. +yadr=`find -L ~ -type file -maxdepth 2 -name .yadr | head | sed 's:\.yadr\/::'` + # Configuration -source ~/.dotfiles/zsh/aliases -source ~/.dotfiles/zsh/zsh_aliases +source $yadr/zsh/aliases +source $yadr/zsh/zsh_aliases # Things I don't want to publish to github source ~/.secrets @@ -13,8 +32,8 @@ bindkey '^R' history-incremental-search-backward # Speed up git completion # http://talkings.org/post/5236392664/zsh-and-slow-git-completion -__git_files () { - _wanted files expl 'local files' _files +__git_files () { + _wanted files expl 'local files' _files } # Always pushd when changing directory @@ -26,7 +45,7 @@ zstyle ':completion:*:match:*' original only zstyle ':completion:*:approximate:*' max-errors 1 numeric # RVM -[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" +[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" # Add path to our custom bins -export PATH=$PATH:~/.dotfiles/bin:~/.dotfiles/bin/yadr +export PATH=$PATH:$yadr/bin:$yadr/bin/yadr