zsh_dots 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +25 -0
- data/.gitmodules +3 -0
- data/.rvmrc +47 -0
- data/Gemfile +7 -0
- data/Gemfile.lock +38 -0
- data/README.md +115 -0
- data/Rakefile +9 -0
- data/bin/dots +7 -0
- data/bin/elocal_nightly.sh +12 -0
- data/bin/gbrt +42 -0
- data/bin/git_cwd_info +40 -0
- data/bin/lein +229 -0
- data/bin/reattach-to-user-namespace +0 -0
- data/bin/ssh-copy-id +54 -0
- data/bin/stock +83 -0
- data/config/.dot_file +1 -0
- data/config/aws +0 -0
- data/config/example.aws.zsh +13 -0
- data/config/gemrc +9 -0
- data/config/gitconfig +46 -0
- data/config/railsrc +2 -0
- data/config/rspec +2 -0
- data/config/rvmrc +1 -0
- data/config/screenrc +1 -0
- data/config/tmux.conf +6 -0
- data/config/zlogin +1 -0
- data/config/zshenv +59 -0
- data/config/zshrc +8 -0
- data/etc/mandlebrot.c +59 -0
- data/etc/rails/composer.yml +30 -0
- data/etc/rails/ember_template.rb +60 -0
- data/etc/rails/recipes/haml_views.rb +20 -0
- data/etc/rails/recipes/html5.rb +84 -0
- data/etc/rails/recipes/readme_markdown.rb +87 -0
- data/etc/rails/template.rb +1419 -0
- data/lib/dots/aliases.zsh +40 -0
- data/lib/dots/directories.zsh +28 -0
- data/lib/dots/functions.zsh +41 -0
- data/lib/dots/plugins.zsh +18 -0
- data/lib/dots.sh +11 -0
- data/lib/plugins/aws/aws.plugin.zsh +20 -0
- data/lib/plugins/bundler/_bundler +82 -0
- data/lib/plugins/bundler/bundler.plugin.zsh +7 -0
- data/lib/plugins/git/git.plugin.zsh +126 -0
- data/lib/plugins/git-flow/git-flow.plugin.zsh +340 -0
- data/lib/plugins/knife/_knife +183 -0
- data/lib/plugins/knife/knife.plugin.zsh +1 -0
- data/lib/plugins/macvim/macvim.plugin.zsh +13 -0
- data/lib/plugins/osx/_man-preview +5 -0
- data/lib/plugins/osx/osx.plugin.zsh +101 -0
- data/lib/plugins/rails3/rails3.plugin.zsh +75 -0
- data/lib/plugins/rake/rake.plugin.zsh +6 -0
- data/lib/plugins/ruby/ruby.plugin.zsh +58 -0
- data/lib/ruby/dots/command.rb +58 -0
- data/lib/ruby/dots/dot_file.rb +73 -0
- data/lib/ruby/dots/version.rb +3 -0
- data/lib/ruby/dots.rb +9 -0
- data/lib/tasks/db.rake +55 -0
- data/lib/tasks/dots.rake +32 -0
- data/spec/integration/command_spec.rb +34 -0
- data/spec/models/dot_file_spec.rb +45 -0
- data/spec/spec_helper.rb +6 -0
- data/vendor/antigen.zsh +251 -0
- data/vendor/oh-my-zsh/check_for_upgrade.sh +45 -0
- data/vendor/oh-my-zsh/install.sh +43 -0
- data/vendor/oh-my-zsh/require_tool.sh +161 -0
- data/vendor/oh-my-zsh/uninstall.sh +20 -0
- data/vendor/oh-my-zsh/upgrade.sh +6 -0
- data/zsh_dots.gemspec +28 -0
- metadata +163 -0
@@ -0,0 +1,75 @@
|
|
1
|
+
# Rails 3 aliases, backwards-compatible with Rails 2.
|
2
|
+
|
3
|
+
function _rails_command () {
|
4
|
+
if [ -e "script/server" ]; then
|
5
|
+
ruby script/$@
|
6
|
+
else
|
7
|
+
ruby script/rails $@
|
8
|
+
fi
|
9
|
+
}
|
10
|
+
|
11
|
+
# View the Rails logger
|
12
|
+
RAILS_PAGER='less'
|
13
|
+
rl() {
|
14
|
+
if [[ $RAILS_PAGER == "less" ]] ; then
|
15
|
+
MODES="-R"
|
16
|
+
else
|
17
|
+
MODES="-f"
|
18
|
+
fi
|
19
|
+
|
20
|
+
if [[ $RAILS_ENV != "" ]] ; then
|
21
|
+
$RAILS_PAGER $MODES log/$RAILS_ENV.log;
|
22
|
+
elif [[ $1 != "" ]] ; then
|
23
|
+
$RAILS_PAGER $MODES log/$1.log;
|
24
|
+
else
|
25
|
+
$RAILS_PAGER $MODES log/development.log;
|
26
|
+
fi
|
27
|
+
}
|
28
|
+
|
29
|
+
# Control Thin, our Rails application server
|
30
|
+
thinctl() {
|
31
|
+
local cmd=$2
|
32
|
+
local port=$3
|
33
|
+
|
34
|
+
if [[ $cmd == "start" ]] ; then
|
35
|
+
if [[ $port != "" ]] ; then
|
36
|
+
local port='3000'
|
37
|
+
echo "No port passed, starting Thin on port 3000..."
|
38
|
+
fi
|
39
|
+
thin -p $port -d $cmd
|
40
|
+
echo "Rails app is up on http://localhost:${port}."
|
41
|
+
elif [[ $cmd == 'stop' ]] ; then
|
42
|
+
thin $cmd
|
43
|
+
echo "Rails app server has stopped."
|
44
|
+
else
|
45
|
+
thin $cmd
|
46
|
+
echo "Rails server has been ${cmd}ed."
|
47
|
+
fi
|
48
|
+
}
|
49
|
+
|
50
|
+
# Rails commands
|
51
|
+
alias rc='_rails_command console'
|
52
|
+
alias rd='_rails_command destroy'
|
53
|
+
alias rdb='_rails_command dbconsole'
|
54
|
+
alias rg='_rails_command generate'
|
55
|
+
alias rp='_rails_command plugin'
|
56
|
+
alias ru='_rails_command runner'
|
57
|
+
alias rs='_rails_command server'
|
58
|
+
alias rsd='_rails_command server --debugger'
|
59
|
+
alias rsp='bundle exec foreman start' # Rails Server and Processes
|
60
|
+
|
61
|
+
# Rake tasks
|
62
|
+
alias rdm='rake db:migrate'
|
63
|
+
alias rdr='rake db:rollback'
|
64
|
+
alias rdbm='rake db:migrate db:test:clone'
|
65
|
+
alias rt='rake test'
|
66
|
+
alias rtu='rake test:units'
|
67
|
+
alias rtf='rake test:functionals'
|
68
|
+
alias rti='rake test:integration'
|
69
|
+
alias rts='rtest' # defined in ruby.plugin.zsh
|
70
|
+
alias rr="rake routes | grep $1"
|
71
|
+
alias rra="rake routes"
|
72
|
+
alias rks="rake server" # for storing server command configuration inside Rake
|
73
|
+
|
74
|
+
# 3rd-party processes related to Rails
|
75
|
+
alias redis="redis-server /usr/local/etc/redis.conf"
|
@@ -0,0 +1,6 @@
|
|
1
|
+
alias rake="noglob rake" # allows square brackts for rake task invocation
|
2
|
+
alias brake='noglob bundle exec rake' # execute the bundled rake gem
|
3
|
+
alias srake='noglob sudo rake' # noglob must come before sudo
|
4
|
+
alias sbrake='noglob sudo bundle exec rake' # altogether now ...
|
5
|
+
|
6
|
+
|
@@ -0,0 +1,58 @@
|
|
1
|
+
# TODO: Make this compatible with rvm.
|
2
|
+
# Run sudo gem on the system ruby, not the active ruby.
|
3
|
+
alias sgem='sudo gem'
|
4
|
+
|
5
|
+
# Find ruby file
|
6
|
+
alias rfind='find . -name "*.rb" | xargs grep -n'
|
7
|
+
|
8
|
+
## @robdimarco <http://innovationontherun.com> contributed the following code: ##
|
9
|
+
|
10
|
+
# Run a single Ruby test using Rake. This will also migrate the database and
|
11
|
+
# generally prepare the environment for testing, and is useful for tests
|
12
|
+
# which require a specific database setup to function.
|
13
|
+
_rbtest_with_rake() {
|
14
|
+
if [ -f $1 ]; then
|
15
|
+
case `echo $1 | cut -f 2 -d '/'` in
|
16
|
+
unit)
|
17
|
+
task='test:units'
|
18
|
+
;;
|
19
|
+
functional)
|
20
|
+
task='test:functionals'
|
21
|
+
;;
|
22
|
+
integration)
|
23
|
+
task='test:integration'
|
24
|
+
;;
|
25
|
+
*)
|
26
|
+
task='test'
|
27
|
+
;;
|
28
|
+
esac
|
29
|
+
bundle exec rake $task TEST1
|
30
|
+
else
|
31
|
+
bundle exec rake test
|
32
|
+
fi
|
33
|
+
}
|
34
|
+
eval "function rtest_rake () { _rbtest_with_rake \$@}"
|
35
|
+
|
36
|
+
# Run a single Ruby test using `ruby -Itest`. This is the built-in testing
|
37
|
+
# framework that ships with Ruby 1.9 and is useful for running quick tests
|
38
|
+
# that don't require database connectivity or awareness of the Rails app.
|
39
|
+
_rbtest_without_rake() {
|
40
|
+
if [ -f $1 ]; then
|
41
|
+
bundle exec ruby -Itest $@;
|
42
|
+
else
|
43
|
+
echo "Please specify a file(s) to test"
|
44
|
+
fi;
|
45
|
+
}
|
46
|
+
eval "function rtest_bare () {_rbtest_without_rake \$@}"
|
47
|
+
|
48
|
+
# Disable autocorrect
|
49
|
+
alias rtest='nocorrect rtest_bare'
|
50
|
+
alias rtest_rake='nocorrect rtest_rake'
|
51
|
+
|
52
|
+
# Shorthand aliases
|
53
|
+
alias t='rtest'
|
54
|
+
alias rts='rtest_rake'
|
55
|
+
|
56
|
+
# Run a ruby script
|
57
|
+
alias rb='ruby'
|
58
|
+
|
@@ -0,0 +1,58 @@
|
|
1
|
+
module Dots
|
2
|
+
class Command < Thor
|
3
|
+
include FileUtils
|
4
|
+
|
5
|
+
default_task :usage
|
6
|
+
|
7
|
+
desc :usage, "Show usage information"
|
8
|
+
def usage
|
9
|
+
say <<-TEXT
|
10
|
+
|
11
|
+
The DOTS Project
|
12
|
+
|
13
|
+
DOTS is a ZSH Framework for managing your dotfiles and other shell configuration.
|
14
|
+
It also gives you some nice, sensible defaults and time-saver aliases to better
|
15
|
+
work with and understand your shell environment.
|
16
|
+
|
17
|
+
The following tasks are meant to help you use the shell more efficiently...
|
18
|
+
|
19
|
+
TEXT
|
20
|
+
|
21
|
+
help
|
22
|
+
end
|
23
|
+
|
24
|
+
desc :update, "Update DOTS to the latest version"
|
25
|
+
def update
|
26
|
+
%x(cd ~/.dots && git pull origin master)
|
27
|
+
end
|
28
|
+
|
29
|
+
desc :version, "Show the current version of DOTS"
|
30
|
+
def version
|
31
|
+
say "DOTS version #{Dots::VERSION} - http://tubbo.github.com/dots"
|
32
|
+
end
|
33
|
+
|
34
|
+
desc :persist, "Copy a dotfile to .dots/config and symlink the original location"
|
35
|
+
def persist file_name
|
36
|
+
dot_file = Dots::DotFile.new file_name
|
37
|
+
|
38
|
+
if dot_file.save
|
39
|
+
say "#{dot_file} saved to DOTS!"
|
40
|
+
else
|
41
|
+
say "Error: #{dot_file} could not be symlinked:"
|
42
|
+
dot_file.errors.full_messages.each { |msg| say "- #{msg}" }
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
desc :forget, "Remove the symlink and restore a dotfile back to its original location"
|
47
|
+
def forget file_name
|
48
|
+
dot_file = Dots::DotFile.find file_name
|
49
|
+
|
50
|
+
if dot_file.destroy
|
51
|
+
say "#{dot_file} is no longer being persisted."
|
52
|
+
else
|
53
|
+
say "Error: #{dot_file} could not be forgotten:"
|
54
|
+
dot_file.errors.full_messages.each { |msg| say "- #{msg}" }
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
@@ -0,0 +1,73 @@
|
|
1
|
+
module Dots
|
2
|
+
class DotFile
|
3
|
+
include FileUtils
|
4
|
+
include ActiveModel::Validations
|
5
|
+
|
6
|
+
DOTS_HOME = File.expand_path "~/.dots"
|
7
|
+
USER_HOME = File.expand_path "~/"
|
8
|
+
|
9
|
+
validate :untracked_path_is_a_file
|
10
|
+
|
11
|
+
attr_reader :tracked_path
|
12
|
+
|
13
|
+
# Instantiate the file and make sure it exists.
|
14
|
+
def initialize with_file_name
|
15
|
+
@untracked_path = File.expand_path with_file_name
|
16
|
+
@file_name = File.basename(with_file_name)[1..-1]
|
17
|
+
@tracked_path = "#{DOTS_HOME}/config/#{@file_name}"
|
18
|
+
end
|
19
|
+
|
20
|
+
def to_s
|
21
|
+
@untracked_path
|
22
|
+
end
|
23
|
+
|
24
|
+
def self.find by_file_name
|
25
|
+
new by_file_name
|
26
|
+
end
|
27
|
+
|
28
|
+
# Persist the file in the ~/.dots repository, and symlink to its old
|
29
|
+
# path.
|
30
|
+
def save
|
31
|
+
if valid?
|
32
|
+
move_to_dots and symlink_old_path
|
33
|
+
else
|
34
|
+
false
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
def saved?
|
39
|
+
File.exists? @tracked_path and File.exists? @untracked_path
|
40
|
+
end
|
41
|
+
|
42
|
+
# "Forget" the file, remove its symlink and restore its location.
|
43
|
+
def destroy
|
44
|
+
delete_symlink and restore_to_original_path
|
45
|
+
end
|
46
|
+
|
47
|
+
private
|
48
|
+
def move_to_dots
|
49
|
+
mv @untracked_path, @tracked_path
|
50
|
+
File.exists? @tracked_path
|
51
|
+
end
|
52
|
+
|
53
|
+
def symlink_old_path
|
54
|
+
File.symlink(@tracked_path, @untracked_path) == 0
|
55
|
+
end
|
56
|
+
|
57
|
+
def restore_to_original_path
|
58
|
+
mv @tracked_path, @untracked_path
|
59
|
+
File.exists? @untracked_path and not File.symlink? @untracked_path
|
60
|
+
end
|
61
|
+
|
62
|
+
def delete_symlink
|
63
|
+
rm @untracked_path
|
64
|
+
not File.exists? @untracked_path
|
65
|
+
end
|
66
|
+
|
67
|
+
def untracked_path_is_a_file
|
68
|
+
unless File.exists? @untracked_path
|
69
|
+
errors.add :untracked_file, "does not exist"
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
data/lib/ruby/dots.rb
ADDED
data/lib/tasks/db.rake
ADDED
@@ -0,0 +1,55 @@
|
|
1
|
+
require 'logger'
|
2
|
+
require 'fileutils'
|
3
|
+
|
4
|
+
namespace :db do
|
5
|
+
HOME = ENV['HOME']
|
6
|
+
EMAIL = ENV['EMAIL'] || "tubbo@psychedeli.ca"
|
7
|
+
DRY_RUN = ENV['DRY_RUN'] || false
|
8
|
+
RAILS_ENV = ENV['RAILS_ENV'] || "stage"
|
9
|
+
|
10
|
+
desc "Import the eLocal stage database and send an email when it's done."
|
11
|
+
task :import do
|
12
|
+
puts "Writing logs to #{HOME}/log/tasklog"
|
13
|
+
sh "cat /dev/null > #{HOME}/log/tasklog"
|
14
|
+
logger = Logger.new("#{HOME}/log/tasklog")
|
15
|
+
logger.formatter = proc do |severity, datetime, progname, msg|
|
16
|
+
puts msg
|
17
|
+
"#{severity}: #{msg}\n"
|
18
|
+
end
|
19
|
+
|
20
|
+
logger.info "Entering eLocal app directory"
|
21
|
+
cd "#{HOME}/Code/elocal"
|
22
|
+
|
23
|
+
logger.info "Importing #{RAILS_ENV} database content"
|
24
|
+
sh "bundle exec thor db:import:#{RAILS_ENV} > /dev/null" unless DRY_RUN
|
25
|
+
logger.info "..done"
|
26
|
+
|
27
|
+
logger.info "Migrating database structure"
|
28
|
+
sh "bundle exec rake db:migrate > log/tasklog" unless DRY_RUN
|
29
|
+
logger.info "..done"
|
30
|
+
|
31
|
+
logger.info "Database import complete."
|
32
|
+
|
33
|
+
logger.info "Indexing accounts"
|
34
|
+
sh "bundle exec thor solr:index_accounts > /dev/null" unless DRY_RUN
|
35
|
+
logger.info "..done"
|
36
|
+
|
37
|
+
logger.info "Indexing categories"
|
38
|
+
sh "bundle exec thor solr:index_categories > /dev/null" unless DRY_RUN
|
39
|
+
logger.info "..done"
|
40
|
+
|
41
|
+
logger.info "Indexing profiles"
|
42
|
+
sh "bundle exec thor solr:index_profiles > /dev/null" unless DRY_RUN
|
43
|
+
logger.info "..done"
|
44
|
+
|
45
|
+
logger.info "Solr index complete."
|
46
|
+
|
47
|
+
puts "Building email notification to '#{EMAIL}'"
|
48
|
+
raw_log = IO.read("#{HOME}/log/tasklog")
|
49
|
+
logs = "<code><pre>#{raw_log}</pre></code>"
|
50
|
+
subject = "#{RAILS_ENV.capitalize} database import succeeded."
|
51
|
+
body = "<p>Successfully imported the eLocal #{RAILS_ENV} database to playa.</p><p>#{logs}</p>"
|
52
|
+
sh %x(echo 'To: tubbo@psychedeli.ca\nSubject: #{subject}\nContent-Type: text/html;charset="us-ascii"\n\n<html><body>#{body}</body></html>' | sendmail -t)
|
53
|
+
puts "Delivered email notification to '#{EMAIL}'"
|
54
|
+
end
|
55
|
+
end
|
data/lib/tasks/dots.rake
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
task :config do
|
2
|
+
Dir["config/*"].each do |config_file|
|
3
|
+
unless File.directory? config_file
|
4
|
+
config_file.gsub! /config\/|.example/, ""
|
5
|
+
config_file_path = File.expand_path "~/.dots/config/#{config_file}"
|
6
|
+
dot_file_path = File.expand_path "~/.#{config_file}"
|
7
|
+
global_rake_path = File.expand_path "~/.rake"
|
8
|
+
|
9
|
+
if File.exists? dot_file_path
|
10
|
+
puts "Did not symlink #{config_file} since one already exists"
|
11
|
+
else
|
12
|
+
File.symlink config_file_path, dot_file_path
|
13
|
+
puts "Symlinked ~/.#{config_file}"
|
14
|
+
end
|
15
|
+
|
16
|
+
unless File.exists? global_rake_path
|
17
|
+
File.symlink global_rake_path, File.expand_path("~/.dots/lib/tasks")
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
puts "Please reload your DOTS."
|
22
|
+
end
|
23
|
+
|
24
|
+
desc "Update all installed plugins"
|
25
|
+
task :update do
|
26
|
+
sh "cd ~/.dots && git pull origin master"
|
27
|
+
|
28
|
+
antigen_repos = Dir[File.join(File.expand_path("../.antigen/repos"), "*")]
|
29
|
+
antigen_repos.each do |repo|
|
30
|
+
sh "cd #{repo} && git pull origin master"
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'dots/command'
|
3
|
+
|
4
|
+
describe Dots::Command do
|
5
|
+
before do
|
6
|
+
dot_file = File.expand_path("~/.dot_file")
|
7
|
+
%x(touch #{dot_file}) unless File.exists? dot_file
|
8
|
+
end
|
9
|
+
|
10
|
+
describe "persist PATH" do
|
11
|
+
let(:subject) { %x(./bin/dots persist ~/.dot_file) }
|
12
|
+
|
13
|
+
it "copies the file to the dots repo" do
|
14
|
+
subject.should_not be_blank
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
describe "forget PATH" do
|
19
|
+
let(:subject) { %x(./bin/dots forget ~/.dot_file) }
|
20
|
+
|
21
|
+
it "restores the file to its original location" do
|
22
|
+
subject.should_not be_blank
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
describe "bare invocation" do
|
27
|
+
let(:subject) { %x(./bin/dots) }
|
28
|
+
|
29
|
+
it "shows usage information" do
|
30
|
+
subject.should_not be_blank
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
@@ -0,0 +1,45 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'dots/dot_file'
|
3
|
+
|
4
|
+
describe Dots::DotFile do
|
5
|
+
before do
|
6
|
+
%x(echo "This is my config" >> ~/.dot_file)
|
7
|
+
@file = Dots::DotFile.new "~/.dot_file"
|
8
|
+
end
|
9
|
+
|
10
|
+
describe "Remembering a file" do
|
11
|
+
it "moves the dot file to the repo directory" do
|
12
|
+
@file.should be_valid
|
13
|
+
@file.save.should == true
|
14
|
+
@file.should be_saved
|
15
|
+
end
|
16
|
+
|
17
|
+
it "restores the original file path as a symlink" do
|
18
|
+
@file.save.should == true
|
19
|
+
@file.should be_saved
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
describe "Forgetting a file" do
|
24
|
+
before do
|
25
|
+
%x(touch ~/.dots/config/dot_file && ln -s ~/.dots/config/dot_file ~/.dot_file)
|
26
|
+
@file = Dots::DotFile.find "~/.dot_file"
|
27
|
+
end
|
28
|
+
|
29
|
+
it "removes the dot file from the repo directory" do
|
30
|
+
@file.destroy.should == true
|
31
|
+
@file.should_not be_saved
|
32
|
+
end
|
33
|
+
|
34
|
+
it "moves the tracked file back to its original location" do
|
35
|
+
@file.destroy.should == true
|
36
|
+
@file.should_not be_saved
|
37
|
+
File.exists?(@file.tracked_path).should_not == true
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
after do
|
42
|
+
`rm ~/.dot_file` if File.exists? File.expand_path("~/.dot_file")
|
43
|
+
`rm ~/.dots/config/dot_file` if File.exists? File.expand_path("~/.dots/config/dot_file")
|
44
|
+
end
|
45
|
+
end
|