Refactor global rakefiles; now ubuntu friendly
This commit is contained in:
parent
4d952faadf
commit
1af5a91d58
|
@ -17,7 +17,7 @@ module Package
|
|||
def installed?(package = nil)
|
||||
return File.exists?(@@brew_bin) if !package
|
||||
|
||||
self.run("list | grep -w '#{package}' >& /dev/null")
|
||||
self.run("list | grep -w '^#{package.split(" ")[0]}$' >& /dev/null")
|
||||
end
|
||||
|
||||
def remove(package)
|
||||
|
@ -42,7 +42,7 @@ module Package
|
|||
end
|
||||
|
||||
def tapped?(repo)
|
||||
self.run("tap | grep -w '#{repo}' >& /dev/null")
|
||||
self.run("tap | grep -w '^#{repo}$' >& /dev/null")
|
||||
end
|
||||
|
||||
# Homebrew-specific functions
|
||||
|
@ -55,12 +55,12 @@ module Package
|
|||
end
|
||||
|
||||
def cask_installed?(cask)
|
||||
self.run("cask list | grep -w '#{cask}' >& /dev/null")
|
||||
self.run("cask list | grep -w '^#{cask}$' >& /dev/null")
|
||||
end
|
||||
|
||||
def run(*args)
|
||||
raise "Homebrew isn't installed!" unless self.installed?
|
||||
|
||||
`#{@@brew_bin} #{args.join(' ')}`
|
||||
system("#{@@brew_bin} #{args.join(' ')}")
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
desc "My main computer"
|
||||
task :io do
|
||||
[ "update",
|
||||
[ "pkg:update",
|
||||
"pkg:osx",
|
||||
"pkg:zsh",
|
||||
"pkg:vim",
|
||||
|
@ -36,18 +36,4 @@ task :io do
|
|||
"suspicious-package"
|
||||
].each { |app| Package.cask_install app }
|
||||
end
|
||||
|
||||
if system("rbenv versions | grep 2.1.2 >/dev/null")
|
||||
sh_safe "rbenv install 2.1.2"
|
||||
sh_safe "rbenv global 2.1.2"
|
||||
|
||||
sh_safe "~/.rbenv/shims/gem install bundler rspec cucumber jekyll"
|
||||
end
|
||||
|
||||
if system("pyenv versions | grep 3.4.1 >/dev/null")
|
||||
sh_safe "pyenv install 3.4.1"
|
||||
sh_safe "pyenv global 3.4.1"
|
||||
|
||||
sh_safe "~/.pyenv/shims/pip install nose cython"
|
||||
end
|
||||
end
|
||||
|
|
|
@ -3,11 +3,11 @@ task :bash => 'bash:update'
|
|||
|
||||
namespace :bash do
|
||||
task :install do
|
||||
if is_mac?
|
||||
echo "Attempting to install bash + completion"
|
||||
Package.install "bash"
|
||||
Package.install "bash-completion"
|
||||
|
||||
if is_mac?
|
||||
# Write the new bash into shells if it isn't already there
|
||||
bash_bin = "/usr/local/bin/bash"
|
||||
if `cat /etc/shells | grep "^#{bash_bin}$"`
|
||||
|
|
|
@ -1,26 +1,43 @@
|
|||
if is_mac?
|
||||
|
||||
ENV['EMACS_D'] = File.expand_path("~/.emacs.d")
|
||||
ENV["EMACS_D"] = File.expand_path("~/.emacs.d")
|
||||
|
||||
desc "Ensure emacs is installed and up to date"
|
||||
def emacs_reqs
|
||||
[
|
||||
"emacs --HEAD --use-git-head --with-gnutls --cocoa --keep-ctags --srgb",
|
||||
"aspell --with-lang-en",
|
||||
"cask",
|
||||
"rsense",
|
||||
"node"
|
||||
]
|
||||
end
|
||||
|
||||
def emacs_installed?
|
||||
Dir.exists?(ENV["EMACS_D"])
|
||||
end
|
||||
|
||||
desc "Ensure emacs 24.4 is installed & up to date"
|
||||
task :emacs => "emacs:update"
|
||||
|
||||
namespace :emacs do
|
||||
task :install do
|
||||
unless Dir.exists? ENV[:EMACS_D]
|
||||
github 'hlissner/emacs.d', '~/.emacs.d'
|
||||
Package.install "homebrew/dupes/tidy --HEAD"
|
||||
emacs_reqs.each { |pkg| Package.install pkg }
|
||||
unless emacs_installed?
|
||||
echo "Installing emacs dependencies"
|
||||
Package.install "homebrew/dupes/tidy --HEAD"
|
||||
|
||||
echo "Setting up Emacs"
|
||||
github 'hlissner/emacs.d', '~/.emacs.d'
|
||||
|
||||
sh_safe "/usr/local/bin/npm install jshint -g"
|
||||
sh_safe "/usr/local/bin/npm install jsonlint -g"
|
||||
sh_safe "cd ~/.emacs.d && cask"
|
||||
sh_safe "cd '#{ENV["EMACS_D"]}' && cask"
|
||||
end
|
||||
end
|
||||
|
||||
task :update do
|
||||
task :update => "emacs:install" do
|
||||
echo "Updating emacs.d & packages"
|
||||
sh_safe "cd ~/.emacs.d && git pull && cask update"
|
||||
sh_safe "cd '#{ENV["EMACS_D"]}' && git pull && cask update"
|
||||
|
||||
# Update rsense config
|
||||
sh_safe "~/.rbenv/shims/ruby `brew --prefix rsense`/libexec/etc/config.rb > ~/.rsense"
|
||||
|
@ -32,17 +49,8 @@ if is_mac?
|
|||
Package.remove "homebrew/dupes/tidy"
|
||||
emacs_reqs.each { |pkg| Package.remove pkg }
|
||||
|
||||
rm_rf "~/.emacs.d" if Dir.exists? ENV['EMACS_D']
|
||||
rm_rf ENV["EMACS_D"] if Dir.exists? ENV["EMACS_D"]
|
||||
end
|
||||
end
|
||||
|
||||
def emacs_reqs
|
||||
[
|
||||
"emacs --with-gnutls --cocoa --keep-ctags --srgb",
|
||||
"aspell --with-lang-en",
|
||||
"cask",
|
||||
"rsense"
|
||||
]
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# coding: utf-8
|
||||
require_relative '../lib/output'
|
||||
|
||||
desc "Set OSX default configuration"
|
||||
|
@ -10,46 +11,89 @@ task :osx do
|
|||
end
|
||||
|
||||
echo "Applying OSX settings"
|
||||
sh_safe 'chflags nohidden "${HOME}/Library"'
|
||||
sh_safe 'defaults write NSGlobalDomain KeyRepeat -int 0'
|
||||
[
|
||||
'chflags nohidden "${HOME}/Library"',
|
||||
# 'defaults write NSGlobalDomain KeyRepeat -int 0',
|
||||
|
||||
# Disable press-and-hold for keys in favor of key repeat
|
||||
sh_safe 'defaults write ApplePressAndHoldEnabled -bool false'
|
||||
'defaults write ApplePressAndHoldEnabled -bool false',
|
||||
|
||||
sh_safe 'defaults write NSGlobalDomain AppleKeyboardUIMode -int 3'
|
||||
sh_safe 'defaults write NSGlobalDomain AppleFontSmoothing -int 2'
|
||||
sh_safe 'defaults write NSGlobalDomain AppleShowAllExtensions -bool true'
|
||||
sh_safe 'defaults write NSGlobalDomain NSNavPanelExpandedStateForSaveMode -bool true'
|
||||
sh_safe 'defaults write com.apple.dock autohide -bool true'
|
||||
'defaults write NSGlobalDomain AppleKeyboardUIMode -int 3',
|
||||
'defaults write NSGlobalDomain AppleFontSmoothing -int 2',
|
||||
'defaults write NSGlobalDomain AppleShowAllExtensions -bool true',
|
||||
'defaults write com.apple.dock autohide -bool true',
|
||||
|
||||
# Expand save panel by default
|
||||
'defaults write NSGlobalDomain NSNavPanelExpandedStateForSaveMode -bool true',
|
||||
'defaults write NSGlobalDomain NSNavPanelExpandedStateForSaveMode2 -bool true',
|
||||
|
||||
# Disable app quarantine
|
||||
sh_safe 'defaults write com.apple.LaunchServices LSQuarantine -bool false'
|
||||
'defaults write com.apple.LaunchServices LSQuarantine -bool false',
|
||||
|
||||
# Disable auto-correct
|
||||
sh_safe 'defaults write NSGlobalDomain NSAutomaticSpellingCorrectionEnabled -bool false'
|
||||
'defaults write NSGlobalDomain NSAutomaticSpellingCorrectionEnabled -bool false',
|
||||
|
||||
# Disable smart quotes
|
||||
'defaults write NSGlobalDomain NSAutomaticQuoteSubstitutionEnabled -bool false',
|
||||
# Disable smart dashes as they're annoying when typing code
|
||||
'defaults write NSGlobalDomain NSAutomaticDashSubstitutionEnabled -bool false',
|
||||
|
||||
# Avoid creating .DS_Store files on network volumes
|
||||
sh_safe 'defaults write com.apple.desktopservices DSDontWriteNetworkStores -bool true'
|
||||
'defaults write com.apple.desktopservices DSDontWriteNetworkStores -bool true',
|
||||
# Disable the warning when changing a file extension
|
||||
sh_safe 'defaults write com.apple.finder FXEnableExtensionChangeWarning -bool false'
|
||||
'defaults write com.apple.finder FXEnableExtensionChangeWarning -bool false',
|
||||
|
||||
sh_safe 'defaults write com.apple.driver.AppleBluetoothMultitouch.trackpad Clicking -bool true'
|
||||
'defaults write com.apple.driver.AppleBluetoothMultitouch.trackpad Clicking -bool true',
|
||||
|
||||
# Disable local Time Machine backups
|
||||
# sh_safe 'hash_safe tmutil &> /dev/null && sudo tmutil disablelocal'
|
||||
# Prevent Time Machine from prompting to use new hard drives as backup volume
|
||||
'defaults write com.apple.TimeMachine DoNotOfferNewDisksForBackup -bool true',
|
||||
|
||||
# Finder: allow text selection in Quick Look
|
||||
sh_safe 'defaults write com.apple.finder QLEnableTextSelection -bool true'
|
||||
'defaults write com.apple.finder QLEnableTextSelection -bool true',
|
||||
|
||||
# When performing a search, search the current folder by default
|
||||
sh_safe 'defaults write com.apple.finder FXDefaultSearchScope -string "SCcf"'
|
||||
'defaults write com.apple.finder FXDefaultSearchScope -string "SCcf"',
|
||||
|
||||
### FINDER ###
|
||||
# Use column view
|
||||
sh_safe 'defaults write com.apple.finder FXPreferredViewStyle -string "clmv"'
|
||||
'defaults write com.apple.finder NewWindowTargetPath -string "file://${HOME}/"', # default location for new finder windows
|
||||
'defaults write com.apple.finder FXPreferredViewStyle -string "clmv"', # column view by default
|
||||
|
||||
sh_safe 'defaults write com.apple.finder ShowStatusBar -bool true'
|
||||
sh_safe 'defaults write com.apple.finder _FXShowPosixPathInTitle -bool true'
|
||||
'defaults write com.apple.finder ShowPathbar -bool true', # path bar
|
||||
'defaults write com.apple.finder ShowStatusBar -bool true', # status bar
|
||||
'defaults write com.apple.finder _FXShowPosixPathInTitle -bool true', # path in window title
|
||||
|
||||
sh_safe 'killall Finder'
|
||||
sh_safe 'killall Dock'
|
||||
# Disable the warning before emptying the Trash
|
||||
'defaults write com.apple.finder WarnOnEmptyTrash -bool false',
|
||||
|
||||
# Disable Dashboard
|
||||
'defaults write com.apple.dashboard mcx-disabled -bool true',
|
||||
# Don’t show Dashboard as a Space
|
||||
'defaults write com.apple.dock dashboard-in-overlay -bool true',
|
||||
|
||||
# Make Dock icons of hidden applications translucent
|
||||
'defaults write com.apple.dock showhidden -bool true',
|
||||
|
||||
# Disable Spotlight indexing for any volume that gets mounted and has not yet
|
||||
# been indexed before.
|
||||
# Use `sudo mdutil -i off "/Volumes/foo"` to stop indexing any volume.
|
||||
'sudo defaults write /.Spotlight-V100/VolumeConfiguration Exclusions -array "/Volumes"',
|
||||
|
||||
### Text edit ###
|
||||
# Use plain text mode for new TextEdit documents
|
||||
'defaults write com.apple.TextEdit RichText -int 0',
|
||||
# Open and save files as UTF-8 in TextEdit
|
||||
'defaults write com.apple.TextEdit PlainTextEncoding -int 4',
|
||||
'defaults write com.apple.TextEdit PlainTextEncodingForWrite -int 4',
|
||||
|
||||
# Disable the sudden motion sensor as it’s not useful for SSDs
|
||||
'sudo pmset -a sms 0',
|
||||
|
||||
# Load new settings before rebuilding the index
|
||||
'killall mds > /dev/null 2>&1',
|
||||
'killall Finder',
|
||||
'killall Dock'
|
||||
].each { |cmd| sh_safe cmd }
|
||||
end
|
||||
|
|
|
@ -2,6 +2,9 @@ require_relative "../lib/package"
|
|||
|
||||
if is_mac?
|
||||
|
||||
desc "Update/setup homebrew"
|
||||
task :homebrew => "homebrew:update"
|
||||
|
||||
namespace :homebrew do
|
||||
task :setup do
|
||||
unless Package.installed?
|
||||
|
@ -21,6 +24,7 @@ if is_mac?
|
|||
"curl",
|
||||
"tree",
|
||||
"git",
|
||||
"hub",
|
||||
"the_silver_searcher",
|
||||
"tmux",
|
||||
"gist",
|
||||
|
@ -55,6 +59,9 @@ if is_mac?
|
|||
|
||||
elsif is_linux?
|
||||
|
||||
desc "Update/setup aptitude"
|
||||
task :aptitude => "aptitude:update"
|
||||
|
||||
namespace :aptitude do
|
||||
task :setup do
|
||||
echo "Updating packages..."
|
||||
|
|
|
@ -14,7 +14,8 @@ def pyenv_plugins
|
|||
end
|
||||
|
||||
def pyenv_version_installed?(version)
|
||||
pyenv_versions.include?(version)
|
||||
versions = pyenv_versions
|
||||
versions.include?(version) if versions
|
||||
end
|
||||
|
||||
###
|
||||
|
@ -35,7 +36,7 @@ namespace :pyenv do
|
|||
"yyuu/pyenv-virtualenv",
|
||||
"yyuu/pyenv-which-ext"
|
||||
].each do |pkg|
|
||||
ech "Installing #{pkg}", 2
|
||||
echo "Installing #{pkg}", 2
|
||||
github pkg, "#{PYENV_ROOT}/plugins/#{pkg.split("/")[1]}"
|
||||
end
|
||||
|
||||
|
|
|
@ -29,7 +29,6 @@ namespace :zsh do
|
|||
end
|
||||
|
||||
sh_safe "chsh -s #{zsh_bin}"
|
||||
sh_safe "exec /bin/zsh -l"
|
||||
end
|
||||
|
||||
echo "Comment out path_helper to fix PATH in emacs!" if is_mac?
|
||||
|
|
Loading…
Reference in a new issue