Tue, 01 Jul 2014 22:11:03 -0400
Try to make setup easier, unify shell environments
.bashrc | file | annotate | diff | comparison | revisions | |
.homedir-setup.rb | file | annotate | diff | comparison | revisions | |
.zshrc | file | annotate | diff | comparison | revisions |
new file mode 100644 --- /dev/null +++ b/.bashrc @@ -0,0 +1,27 @@ +# .bashrc: executed for non-login shells +# probably sourced by .bash_profile though + +if [ -f ~/.bashrc.dist ]; then + source ~/.bashrc.dist +fi + + +if [ -d ~/bin ]; then + export PATH="$HOME/bin:$PATH" +fi + +if [ -d ~/.plenv ]; then + export PATH="$HOME/.plenv/bin:$PATH" + eval "$(plenv init -)" +fi + +if [ -d ~/.rbenv ]; then + export PATH="$HOME/.rbenv/bin:$PATH" + eval "$(rbenv init -)" +fi + + +if [ -f ~/.bashrc.local ]; then + source ~/.bashrc.local +fi +
new file mode 100755 --- /dev/null +++ b/.homedir-setup.rb @@ -0,0 +1,171 @@ +#!/usr/bin/env ruby +# vim: et sts=2 sw=2 fdm=marker +# encoding: UTF-8 + +# we don't yet have rbenv so keep safe for ruby 1.8 + +if `which git` == '' + puts "please install git" + exit 1 +end + + +# util {{{ + # just checks and bails after each call + def do_cmds (*cmds) + cmds.each do |cmd| + puts "$ #{cmd}" + system( cmd ) or exit $? + end + end + + #checks for the first line and if it's not there, appends the whole set + def add_if_missing (fn, lines) + match = lines.lines.first.chomp + add = false + + if File.exists?(fn) + File.open(fn) do |file| + if file.each_line.none? { |line| line.chomp == match } + add = true + end + end + else + add = true + end + + if add == true + File.open(fn, 'a') do |append| + append << lines + append << $/ + end + + puts "Added to #{fn}:" + puts lines + $/ + end + + end + + def replace_line (fn, match, replace) + buf = [] + changed = false + + File.open(fn) do |file| + file.each_line do |line| + buf << if line.match(match) + changed = true + replace + else + line + end + end + end + + if changed + File.open( fn + ".tmp~", 'w' ) do |file| + buf.each do |line| + file.puts line + end + end + puts 'changes in #{fn}.tmp~' + else + puts 'no change' + end + end +# }}} + + +# oh-my-zsh {{{ + # i have a custom theme and the omz install complains about already + # having a directory there. remove, install, then revert my stuff + # out of hg + + if Dir.exists?('.oh-my-zsh/.git') + puts "oh-my-zsh already installed" + else + puts "Installing oh-my-zsh..." + + do_cmds \ + 'rm -r .oh-my-zsh', + 'git clone git://github.com/robbyrussell/oh-my-zsh.git .oh-my-zsh', + 'hg stat -dn0 -I .oh-my-zsh/ | xargs -0 hg revert' + + end + +# }}} + + +add_if_missing '.bash_profile', 'export PATH=~/bin:$PATH' + +add_if_missing '.zshrc', <<END +typeset -U path +path=(~/bin "$path[@]") +END + + +# plenv {{{ + + if Dir.exists?('.plenv') + puts "plenv already installed" + else + puts "Installing plenv..." + + do_cmds \ + 'git clone git://github.com/tokuhirom/plenv.git .plenv', + 'git clone git://github.com/tokuhirom/Perl-Build.git .plenv/plugins/perl-build/' + + + add_if_missing '.bash_profile', <<END +export PATH="$HOME/.plenv/bin:$PATH" +eval "$(plenv init -)" +END + + add_if_missing '.zshrc', <<END +path=(~/.plenv "$path[@]") +eval "$(plenv init - zsh)" +END + + end + +# }}} + + +# rbenv {{{ + +# git clone https://github.com/sstephenson/rbenv.git ~/.rbenv +# git clone https://github.com/sstephenson/ruby-build.git ~/.rbenv/plugins/ruby-build +# echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bash_profile +# echo 'eval "$(rbenv init -)"' >> ~/.bash_profile + if Dir.exists?('.rbenv') + puts "rbenv already installed" + else + puts "Installing rbenv..." + + do_cmds \ + 'git clone https://github.com/sstephenson/rbenv.git .rbenv', + 'git clone https://github.com/sstephenson/ruby-build.git .rbenv/plugins/ruby-build/' + + + add_if_missing '.bash_profile', <<END +export PATH="$HOME/.rbenv/bin:$PATH" +eval "$(rbenv init -)" +END + + add_if_missing '.zshrc', <<END +path=(~/.rbenv "$path[@]") +eval "$(rbenv init - zsh)" +END + + end + +# }}} + + + + +# vundle {{{ + +# }}} + + +
new file mode 100644 --- /dev/null +++ b/.zshrc @@ -0,0 +1,53 @@ +# Path to your oh-my-zsh installation. +export ZSH=$HOME/.oh-my-zsh + +ZSH_THEME="mhoward" +ZSH_CUSTOM=~/.oh-my-zsh.custom + +plugins=( common-aliases mercurial git mosh ) + +if [ -f ~/.zshrc.local-pre ]; + source ~/.zshrc.local-pre +fi + +# Uncomment the following line to disable auto-setting terminal title. +# DISABLE_AUTO_TITLE="true" + +# Uncomment the following line to display red dots whilst waiting for completion. +# COMPLETION_WAITING_DOTS="true" + +# Uncomment the following line if you want to disable marking untracked files +# under VCS as dirty. This makes repository status check for large repositories +# much, much faster. +# DISABLE_UNTRACKED_FILES_DIRTY="true" + + + +source $ZSH/oh-my-zsh.sh + +# User configuration + +export PATH="$HOME/bin:/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games" +# export MANPATH="/usr/local/man:$MANPATH" + +# export LANG=en_US.UTF-8 + +export EDITOR='vim' + +typeset -U path + +if [ -d ~/.plenv ]; then + path=( ~/.plenv/bin "$path[@]" ) + eval "$(plenv init - zsh)" +fi + +if [ -d ~/.rbenv ]; then + path=( ~/.rbenv/bin "$path[@]" ) + eval "$(rbenv init - zsh)" +fi + + +if [ -f ~/.zshrc.local ]; then + source ~/.zshrc.local +fi +