Permalink
Browse files

Switch to Bash-It

## Additions
* LWRP for bash-it aliases, completion, plugins
* LWRP for custom plugin installation

## Removals
* The `bash_profile_include` LWRP
* `arch_flags` for Snow Leopard
* `lang_en`
* `ree_settings`
* recipe `gem_no_rdoc_no_ri` (replaced by `gem_setup`)

## Ported to Bash-It
* `better_history`
* `ctrl-o`
* `ctrl-s`
* `no_sudo_gem_install` (called by `gem_setup` now)
* `ec2_api_tools`

## Reimplemented by Bash-It
* bash path order
* PS1 management
* aliases
* git completion
* rbenv integration
* `rvm`
  • Loading branch information...
Doc Ritezel & aram price
Doc Ritezel & aram price committed Dec 2, 2012
1 parent 4240a44 commit d45343c5eed431b31c0a37cbdb99d60a57c5e291
Showing with 104 additions and 2,812 deletions.
  1. +7 −3 attributes/bash_it.rb
  2. +11 −0 providers/bash_it_custom_plugin.rb
  3. +30 −0 providers/bash_it_enable_feature.rb
  4. +21 −24 recipes/bash_it.rb
  5. +0 −12 recipes/bash_path_order.rb
  6. +0 −1 recipes/bash_profile-aliases.rb
  7. +0 −1 recipes/bash_profile-arch_flags.rb
  8. +0 −1 recipes/bash_profile-better_history.rb
  9. +0 −1 recipes/bash_profile-ctrl-o.rb
  10. +0 −1 recipes/bash_profile-ctrl-s.rb
  11. +0 −1 recipes/bash_profile-git_completion.rb
  12. +0 −1 recipes/bash_profile-lang_en.rb
  13. +0 −1 recipes/bash_profile-no_sudo_gem_install.rb
  14. +0 −1 recipes/bash_profile-ps1.rb
  15. +0 −1 recipes/bash_profile-ree_settings.rb
  16. +1 −1 recipes/ec2_api_tools.rb
  17. +2 −0 recipes/{gem_no_rdoc_no_ri.rb → gem_setup.rb}
  18. +1 −1 recipes/git_config_global_defaults.rb
  19. +1 −4 recipes/meta_osx_base.rb
  20. +1 −1 recipes/meta_osx_development.rb
  21. +1 −2 recipes/meta_ruby_development.rb
  22. +1 −2 recipes/rbenv.rb
  23. +1 −1 recipes/rvm.rb
  24. +2 −2 recipes/vim.rb
  25. +0 −1 resources/{bash_profile_include.rb → bash_it_custom_plugin.rb}
  26. +9 −0 resources/bash_it_enable_feature.rb
  27. 0 templates/default/{bash_profile-ctrl-s.sh.erb → bash_it/custom/disable_ctrl-s_output_control.bash}
  28. 0 templates/default/{bash_profile-ctrl-o.sh.erb → bash_it/custom/enable_ctrl-o_history_execution.bash}
  29. +14 −0 templates/default/bash_it/custom/ensure_usr_local_bin_first.bash
  30. 0 templates/default/{bash_profile-better_history.sh.erb → bash_it/custom/history_settings.bash}
  31. +1 −0 templates/default/bash_it/theme.erb
  32. +0 −4 templates/default/bash_profile-aliases.sh.erb
  33. +0 −3 templates/default/bash_profile-arch_flags.sh.erb
  34. +0 −2,714 templates/default/bash_profile-git_completion.sh.erb
  35. +0 −2 templates/default/bash_profile-lang_en.sh.erb
  36. +0 −8 templates/default/bash_profile-ps1.sh.erb
  37. +0 −2 templates/default/bash_profile-rbenv.sh.erb
  38. +0 −6 templates/default/bash_profile-ree_settings.sh.erb
  39. +0 −3 templates/default/bash_profile-rvm.sh.erb
  40. +0 −6 templates/default/bash_profile.erb
  41. 0 templates/default/{bash_profile-ec2_tools.sh.erb → ec2_tools-export_paths_and_credentials.bash}
  42. 0 templates/default/{bash_profile-no_sudo_gem_install.sh.erb → gem_setup-warn_on_sudo.bash}
  43. 0 templates/default/{bash_profile-git_vim.sh.erb → git-export_editor.bash}
  44. 0 templates/default/{bash_profile-vi_is_minimal_vim.sh.erb → vim-alias_vi_to_minimal_vim.bash}
  45. 0 templates/default/{bash_profile-vim_tmux.sh.erb → vim-source_tmux_config.bash}
View
@@ -4,7 +4,11 @@
'completion' => %w[defaults git],
'plugins' => %w[ssh]
},
- 'custom_plugins' => [
- # template files added here will be installed under <bash-it dir>/custom/
- ]
+ 'custom_plugins' => %w[
+ bash_it/custom/disable_ctrl-s_output_control.bash
+ bash_it/custom/enable_ctrl-o_history_execution.bash
+ bash_it/custom/history_settings.bash
+ bash_it/custom/ensure_usr_local_bin_first.bash
+ ],
+ 'theme' => 'bobby'
}
@@ -0,0 +1,11 @@
+action :create do
+ include_recipe "pivotal_workstation::bash_it"
+
+ bash_it_custom_dir = ::File.join(::BASH_IT_DIR, "custom")
+
+ template ::File.expand_path(custom_script, bash_it_custom_dir) do
+ source custom_script
+ owner WS_USER
+ only_if { custom_script =~ /\.bash$/ && ::File.directory?(bash_it_custom_dir) }
+ end
+end
@@ -0,0 +1,30 @@
+# Usage:
+# pivotal_workstation_bash_it_enable "plugins/foo"
+
+action :create do
+ type, name = new_resource.name.split("/")
+ # TODO: complain if type is not in [aliases, completion, plugins]
+
+ def script_type(type)
+ (type == 'plugins') ? 'plugin' : type
+ end
+
+ type_dir = ::File.expand_path(type, BASH_IT_DIR)
+ enabled_dir = ::File.expand_path("enabled", type_dir)
+ available_dir = ::File.expand_path("available", type_dir)
+
+ script_name = "#{name}.#{script_type(type)}.bash"
+ enabled_script_path = ::File.expand_path(script_name, enabled_dir)
+
+ directory enabled_dir do
+ recursive true
+ user WS_USER
+ not_if { ::File.directory?(enabled_dir) }
+ end
+
+ link ::File.expand_path(script_name, available_dir) do
+ to enabled_script_path
+ user WS_USER
+ not_if { ::File.symlink?(enabled_script_path) }
+ end
+end
View
@@ -1,4 +1,4 @@
-bash_it_dir = "#{WS_HOME}/.bash_it"
+::BASH_IT_DIR = ::File.expand_path(".bash_it", WS_HOME)
bash_it_version = version_string_for('bash_it')
git "#{Chef::Config[:file_cache_path]}/bash_it" do
@@ -8,35 +8,32 @@
action :sync
end
-execute "Copying bash-it's .git to #{bash_it_dir}" do
- command "rsync -axSH #{Chef::Config[:file_cache_path]}/bash_it/ #{bash_it_dir}"
+execute "Copying bash-it's .git to #{BASH_IT_DIR}" do
+ command "rsync -axSH #{Chef::Config[:file_cache_path]}/bash_it/ #{BASH_IT_DIR}"
user WS_USER
end
-node['bash_it']['enabled_plugins'].each do |type, scripts|
- type_dir = "#{bash_it_dir}/#{type}"
- enabled_dir = "#{type_dir}/enabled"
-
- execute "created enabled dir for bash-it #{type}" do
- command "mkdir -p #{enabled_dir}"
- user WS_USER
- end
+template ::File.expand_path(".bash_it_theme", WS_HOME) do
+ source "bash_it/theme.erb"
+ owner WS_USER
+end
- scripts.each do |script|
- available_script_path = "#{type_dir}/available/#{script}.#{type}.bash"
- enabled_script_path = "#{enabled_dir}/#{script}.#{type}.bash"
+execute "add BASH_IT configuration to .bash_profile" do
+ configuration = <<-CONFIGURATION.gsub(/^\s+/, '')
+ # START-BASH_IT
+ export BASH_IT=$HOME/.bash_it
+ source $HOME/.bash_it_theme
- execute "enable bash-it #{available_script_path}" do
- command "ln -s #{available_script_path} #{enabled_script_path}"
- user WS_USER
- not_if { ::File.symlink?(enabled_script_path) }
- end
- end
+ source $BASH_IT/bash_it.sh
+ # END-BASH_IT
+ CONFIGURATION
+ command "echo '#{configuration}' >> #{WS_HOME}/.bash_profile"
+ user WS_USER
+ not_if "grep 'START-BASH_IT' #{WS_HOME}/.bash_profile"
end
-node['bash_it']['custom_plugins'].each do |custom_script|
- template "#{bash_it_dir}/custom/#{custom_script}.bash" do
- source custom_script
- owner WS_USER
+node['bash_it']['enabled_plugins'].each do |feature_type, features|
+ features.each do |feature_name|
+ pivotal_workstation_bash_it_enable_feature "#{feature_type}/#{feature_name}"
end
end
View
@@ -1,12 +0,0 @@
-ruby_block "put /usr/local/bin first in path" do
- block do
- ENV['PATH']="/usr/local/bin:#{ENV['PATH']}"
- new_contents = ""
- File.open("/etc/paths", "r") do |file|
- new_contents = "/usr/local/bin\n"+file.read.gsub("/usr/local/bin\n", "")
- end
- File.open("/etc/paths", "w") do |file|
- file.write(new_contents)
- end
- end
-end
@@ -1 +0,0 @@
-pivotal_workstation_bash_profile_include "aliases"
@@ -1 +0,0 @@
-pivotal_workstation_bash_profile_include "arch_flags"
@@ -1 +0,0 @@
-pivotal_workstation_bash_profile_include "better_history"
@@ -1 +0,0 @@
-pivotal_workstation_bash_profile_include "ctrl-o"
@@ -1 +0,0 @@
-pivotal_workstation_bash_profile_include "ctrl-s"
@@ -1 +0,0 @@
-pivotal_workstation_bash_profile_include "git_completion"
@@ -1 +0,0 @@
-pivotal_workstation_bash_profile_include "lang_en"
@@ -1 +0,0 @@
-pivotal_workstation_bash_profile_include "no_sudo_gem_install"
@@ -1 +0,0 @@
-pivotal_workstation_bash_profile_include "ps1"
@@ -1 +0,0 @@
-pivotal_workstation_bash_profile_include "ree_settings"
View
@@ -1,3 +1,3 @@
brew_install "ec2-api-tools"
-pivotal_workstation_bash_profile_include "ec2_tools"
+pivotal_workstation_bash_it_custom_plugin "ec2_tools-export_paths_and_credentials.bash"
@@ -1,3 +1,5 @@
+pivotal_workstation_bash_it_custom "gem_setup-warn_on_sudo.bash"
+
file "/etc/gemrc" do
owner "root"
group "wheel"
@@ -1,5 +1,5 @@
include_recipe "pivotal_workstation::git"
-pivotal_workstation_bash_profile_include "git_vim"
+pivotal_workstation_bash_it_custom_plugin "git-export_editor.bash"
template "#{WS_HOME}/.gitignore_global" do
source "gitignore_global.erb"
View
@@ -1,14 +1,11 @@
+include_recipe "pivotal_workstation::bash_it"
include_recipe "pivotal_workstation::create_var_chef_cache"
include_recipe "pivotal_workstation::java"
include_recipe "pivotal_workstation::sshd_on"
include_recipe "pivotal_workstation::screen_sharing_app"
include_recipe "pivotal_workstation::skype"
include_recipe "pivotal_workstation::shiftit"
include_recipe "pivotal_workstation::firefox"
-include_recipe "pivotal_workstation::bash_profile-better_history"
-include_recipe "pivotal_workstation::bash_profile-aliases"
-include_recipe "pivotal_workstation::bash_profile-ps1"
-include_recipe "pivotal_workstation::bash_profile-ctrl-o"
include_recipe "pivotal_workstation::inputrc"
include_recipe "pivotal_workstation::locate_on"
include_recipe "pivotal_workstation::dropbox"
@@ -1,4 +1,4 @@
-include_recipe "pivotal_workstation::bash_profile-git_completion"
+include_recipe "pivotal_workstation::bash_it"
include_recipe "pivotal_workstation::ccmenu"
include_recipe "pivotal_workstation::git_config_global_defaults"
include_recipe "pivotal_workstation::git_scripts"
@@ -1,10 +1,9 @@
include_recipe "pivotal_workstation::rvm"
-include_recipe "pivotal_workstation::bash_profile-no_sudo_gem_install"
+include_recipe "pivotal_workstation::gem_setup"
include_recipe "pivotal_workstation::mysql"
include_recipe "pivotal_workstation::postgres"
include_recipe "pivotal_workstation::rubymine"
include_recipe "pivotal_workstation::rubymine_preferences_pivotal"
include_recipe "pivotal_workstation::imagemagick"
-include_recipe "pivotal_workstation::gem_no_rdoc_no_ri"
include_recipe "pivotal_workstation::node_js"
include_recipe "pivotal_workstation::qt"
View
@@ -3,11 +3,10 @@
::RBENV_HOME = "#{WS_HOME}/.rbenv"
::RBENV_COMMAND = "/usr/local/bin/rbenv"
-
brew_install("rbenv")
brew_install("ruby-build")
-pivotal_workstation_bash_profile_include "rbenv"
+pivotal_workstation_bash_it_enable_feature "plugins/rbenv"
node["rbenv"]["rubies"].each do |version, options|
rbenv_ruby_install version do
View
@@ -6,7 +6,7 @@
::RVM_HOME = "#{WS_HOME}/.rvm"
::RVM_COMMAND = "#{::RVM_HOME}/bin/rvm"
-pivotal_workstation_bash_profile_include "rvm"
+pivotal_workstation_bash_it_enable_feature "plugins/rvm"
run_unless_marker_file_exists(marker_version_string_for("rvm")) do
recursive_directories [RVM_HOME, 'src', 'rvm'] do
View
@@ -100,5 +100,5 @@
end
end
-pivotal_workstation_bash_profile_include "vi_is_minimal_vim"
-pivotal_workstation_bash_profile_include "vim_tmux"
+pivotal_workstation_bash_it_custom "vim-alias_vi_to_minimal_vim.bash"
+pivotal_workstation_bash_it_custom "vim-source_tmux_config.bash"
@@ -2,7 +2,6 @@
attribute :name, :kind_of => String, :name_attribute => true
-
def initialize(name, run_context=nil)
super
@action = :create
@@ -0,0 +1,9 @@
+actions :create
+
+attribute :name, :kind_of => String, :name_attribute => true
+attribute :type, :kind_of => String
+
+def initialize(name, run_context=nil)
+ super
+ @action = :create
+end
@@ -0,0 +1,14 @@
+# Move /usr/local/bin to the front so homebrew programs are found first
+function path_without_usr_local_bin () {
+ IFS=':'
+ t=($PATH)
+ unset IFS
+ t=(${t[@]%%*/usr/local/bin*})
+ IFS=':'
+ echo "${t[*]}"
+ unset IFS
+}
+
+export PATH=/usr/local/bin:`path_without_usr_local_bin`
+
+unset path_without_usr_local_bin
@@ -0,0 +1 @@
+export BASH_IT_THEME="<%= node["bash_it"]["theme"] %>"
@@ -1,4 +0,0 @@
-alias ll='ls -lhA'
-
-alias grep='grep --color=auto'
-alias egrep='egrep --color=auto'
@@ -1,3 +0,0 @@
-# This resolves issues install the mysql, postgres, and other gems with native non universal binary extensions
-# You only want this if you are on Snow Leopard
-export ARCHFLAGS='-arch x86_64'
Oops, something went wrong.

0 comments on commit d45343c

Please sign in to comment.