helm/rake/pkg/zsh.rake

47 lines
1.2 KiB
Ruby
Raw Normal View History

2014-09-05 14:03:26 -07:00
desc "Ensure zsh & prezto are installed"
2014-04-11 00:31:44 -07:00
task :zsh => 'zsh:update'
2014-09-05 14:03:26 -07:00
ENV["PREZTO_PATH"] = File.expand_path("~/.zprezto")
2014-04-11 00:31:44 -07:00
namespace :zsh do
2014-08-30 23:50:03 -07:00
task :install do
2014-09-05 14:03:26 -07:00
echo "Attempting to install ZSH"
Package.install "zsh"
unless Dir.exists? ENV["PREZTO_PATH"]
echo "Installing prezto", 2
github 'hlissner/prezto', ENV["PREZTO_PATH"]
2014-04-11 00:31:44 -07:00
end
2014-08-30 23:50:03 -07:00
sh_safe '~/.dotfiles/install.sh'
2014-04-11 00:31:44 -07:00
2014-09-08 09:10:36 -07:00
unless `printenv SHELL | grep "/zsh$"`
2014-09-05 14:03:26 -07:00
echo "Setting shell to ZSH", 2
zsh_bin = is_mac? ? "/usr/local/bin/zsh" : "/usr/bin/zsh"
if !File.exists? zsh_bin
error "ZSH isn't in #{File.dirname(zsh_bin)}"
next
end
# Write the new zsh into shells if it isn't already there
if `cat /etc/shells | grep "^#{zsh_bin}$"`
echo "Writing '#{zsh_bin}' to /etc/shells", 3
sh_safe "echo '#{zsh_bin}' | sudo tee -a /etc/shells"
end
sh_safe "chsh -s #{zsh_bin}"
2014-08-30 23:50:03 -07:00
sh_safe "exec /bin/zsh -l"
2014-04-13 08:46:20 -07:00
end
2014-09-05 14:03:26 -07:00
echo "Comment out path_helper to fix PATH in emacs!" if is_mac?
2014-08-30 23:50:03 -07:00
end
task :update => "zsh:install" do
echo "Updating zprezto"
sh_safe 'cd ~/.zprezto && git pull'
end
2014-04-11 00:31:44 -07:00
2014-08-30 23:50:03 -07:00
task :remove do
2014-09-05 14:03:26 -07:00
sh_safe 'rm -rf ~/.zprezto' if Dir.exists? ENV["PREZTO_PATH"]
2014-08-30 23:50:03 -07:00
end
2014-04-11 00:31:44 -07:00
end