Last active
December 23, 2021 14:16
-
-
Save brandondrew/3639058 to your computer and use it in GitHub Desktop.
Script to automatically build your new home directory on Unix or Linux boxes (with Spartan enhancements)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
############################################################### | |
# BUILD HOME script: | |
# This script sets up your home directory fast with basic | |
# necessities and amenities, to give you sanity when you | |
# work on a Unix box where you don't have root access. | |
############################################################### | |
### TO USE: | |
# wget https://gist.github.com/raw/3639058/build_home.sh | |
# bash build_home.sh | |
### OR, if you can get curl to follow redirects... | |
# curl https://gist.github.com/raw/3639058/build_home.sh | bash | |
############################################################### | |
DATE=`date '+%Y%m%d'` | |
# TODO: clean this up with bash's version of files.each :p | |
# clean-up previous installations in case they exist: | |
mv .bash_profile{,.$DATE} 2> /dev/null | |
mv .keep_alive{,.$DATE} 2> /dev/null | |
mv .aliases{,.$DATE} 2> /dev/null | |
mv .functions{,.$DATE} 2> /dev/null | |
mv .prompt{,.$DATE} 2> /dev/null | |
mv .variables{,.$DATE} 2> /dev/null | |
mv .vimrc{,.$DATE} 2> /dev/null | |
mv .ackrc{,.$DATE} 2> /dev/null | |
mv .solaris{,.$DATE} 2> /dev/null | |
mv .profile{,.$DATE} 2> /dev/null #for crazy Solaris boxes with ksh :p | |
mv .bashrc{,.$DATE} 2> /dev/null #TODO: check whether I ever need this | |
mv .local{,.$DATE} 2> /dev/null | |
mv .screenrc{,.$DATE} 2> /dev/null | |
mv .inputrc{,.$DATE} 2> /dev/null | |
mv .spartan{,.$DATE} 2> /dev/null | |
rm bin/rebuild 2> /dev/null | |
rm bin/follow 2> /dev/null | |
rm bin/protect_session 2> /dev/null | |
######### bin ########### | |
mkdir -p ~/bin | |
# in case there are local-only settings we don't want to overwrite | |
# no other file should have been customized locally | |
# TODO: delete .local`datestamp` file if no different from the new one | |
# TODO: ACTUALLY, do that with all of them! | |
# TODO: implement improved strategy for local changes: | |
# each file should source_if a .local version of itself, | |
# so .zshrc sources .zshrc.local if it exists | |
########################################################### | |
# no quotes on END_BASH_PROFILE so variables are interpolated | |
# this means variables NOT to be interpolated need to be escaped | |
cat << END_BASH_PROFILE >> .bash_profile | |
function source_if() { | |
if [[ -f "\$1" ]]; then | |
source "\$1" | |
fi | |
} | |
source_if ~/.bashrc | |
# vi keybindings are PERVERSE! | |
set -o emacs | |
GLOBIGNORE='*/.:*/..' | |
HISTSIZE=100000 | |
HISTCONTROL=ignorespace | |
source_if $HOME/.variables | |
source_if $HOME/.prompt | |
source_if $HOME/.aliases | |
source_if $HOME/.functions | |
source_if $HOME/.spartan | |
source_if $HOME/.local | |
source_if $HOME/.keep_alive | |
source_if $HOME/.projects | |
END_BASH_PROFILE | |
echo "Created new .bash_profile" | |
########################################################### | |
cat << 'END_SPARTAN' >> .spartan | |
# local windows box | |
if [[ `hostname` = 'ws006428' ]]; then | |
ENVIRONMENT="local" | |
HOST_ID='#'; | |
# InSite servers | |
elif [[ `hostname -a` = "spartand3" ]]; then | |
ENVIRONMENT="production" | |
HOST_ID="insite" | |
# Drupal servers | |
elif [[ `hostname -a` = "spartana0" ]]; then | |
ENVIRONMENT="development" | |
HOST_ID="dev.www" | |
elif [[ `hostname -a` = "spartanc6" ]]; then | |
ENVIRONMENT="uat" | |
HOST_ID="uat.www" | |
elif [[ `hostname -a` = "spartanc1" ]]; then | |
ENVIRONMENT="production" | |
HOST_ID="www" | |
fi | |
export ENVIRONMENT | |
export HOST_ID | |
END_SPARTAN | |
echo "Created new .spartan" | |
########################################################### | |
cat << 'END_VARIABLES' >> .variables | |
# ENVIRONMENT VARIABLES # | |
export PATH=$PATH:~/bin:~/usr/bin:~/.ruby/bin | |
export GEM_HOME=~/.gems | |
export TZ=America/Detroit | |
#export RUBYOPT=rubygems | |
# HOST_ID and ENVIRONMENT variables moved to .spartan | |
END_VARIABLES | |
echo "Created new .variables" | |
source $HOME/.variables | |
########################################################### | |
cat << 'END_KEEP_ALIVE' >> .keep_alive | |
# keep alive # | |
#~/bin/protect_session & | |
END_KEEP_ALIVE | |
echo "Created new .keep_alive" | |
########################################################### | |
cat << END_ALIASES >> .aliases | |
alias ls='ls --color' # black and white sucks | |
alias grep='grep --color=auto' | |
alias egrep='egrep --color=auto' | |
alias fgrep='fgrep --color=auto' | |
# TODO: | |
# write a function present such that this makes sense: | |
# if [[ present(colordiff) ]]; then | |
# alias diff='colordiff' | |
# fi | |
# I may already have one somewhere... | |
alias mount='mount | column -t' | |
alias ping='ping -c 4' | |
alias mvi='mv -i' | |
alias rmi='rm -i' | |
# editors # | |
alias e=vi | |
alias vi='vim -u $HOME/.vimrc' # experimental | |
# useful when I source my .bash_profile as another user | |
export EDITOR=vim | |
# ls aliases # | |
alias hal='ls -hal' | |
alias dhal='ls -dhal' | |
alias lsd='ls -d' | |
# cd aliases # | |
alias ..='cd ..' | |
alias ...='cd ../..' | |
alias ....='cd ../../..' | |
alias .....='cd ../../../..' | |
alias ......='cd ../../../../..' | |
alias .......='cd ../../../../../..' | |
alias huntfor='find / -name $1 2> /dev/null 1> $2 &' | |
alias www='cd /var/www/vhosts/${HOST_ID}.spartanstores.com/current' | |
alias apacheconfig='vim /etc/httpd/conf.d/${HOST_ID}.spartanstores.com.conf' | |
alias restart='sudo /usr/sbin/apachectl restart' | |
alias phpconfig='vim /usr/local/zend/etc/php.ini' | |
END_ALIASES | |
# now some without variable interpolation: | |
cat << 'END_ALIASES_LITERAL' >> .aliases | |
alias keys='eval `ssh-agent` && ssh-add ~/.ssh/id_dsa_spartan' | |
# if I've just been using vim, my brain might not switch modes immediately | |
# so this lets me exit the shell the same way I just exited vim: | |
alias ':q'='exit' | |
alias datestamp='date "+%Y%m%d%H%M%S"' | |
alias thediff='diff --suppress-common-lines --side-by-side --ignore-space-change' | |
END_ALIASES_LITERAL | |
echo "Created new .aliases" | |
########################################################### | |
cat << 'END_FUNCTIONS' >> .functions | |
function word() { | |
cat /usr/share/dict/words | grep $1 | |
} | |
function where() { | |
whereis $1 | cut -d':' -f2 | awk '{ print $1 }' | |
} | |
function process() { | |
ps -ef$2 | grep $1 | grep -v 'grep' | |
} | |
# log `cd`: easier to pick up where you left off | |
function cd() { | |
builtin cd $@ | |
echo $(pwd) >> "$HOME/.dirs" | |
} | |
function rdiff() { | |
local_file="$1" | |
server="$2" | |
if [[ -n "$3" ]]; then | |
remote_file="$3" | |
else | |
remote_file="$1" | |
fi | |
diff "$local_file" <(ssh "$server" "cat $remote_file") | |
} | |
function rvimdiff() { | |
#if [[ -z "$1" || -z "$2" ]]; then echo "Usage: $0 <filename> <server>"; fi | |
if [[ "$#" -lt 2 ]]; then echo "Usage: $0 <filename> <server>"; fi | |
local_file="$1" | |
server="$2" | |
if [[ -n "$3" ]]; then | |
remote_file="$3" | |
else | |
remote_file=$(filepath "$1") | |
fi | |
vimdiff "$local_file" scp://"${server}/${remote_file}" | |
} | |
function dirdiff() { | |
diff --suppress-common-lines --side-by-side --ignore-space-change <( tree "$1") <( tree "$2") | |
} | |
function rdirdiff() { | |
# ask for server | |
echo "What server would you like to connect to?" | |
read server | |
for file in `ls -da .*`; do | |
if [[ -f "$file" ]]; then | |
# TODO: check that the file actually even exists on the remote server | |
value=$(diff --brief "$file" <(ssh "$server" "cat $file" 2> /dev/null) ) | |
if [[ $? -ne 0 ]]; then | |
# vimdiff "$file" scp://www//home/bzisad0/"$file" | |
#echo "... $value ...." | |
echo "Comparing $file with scp://$server"/$(filepath "$file") | |
echo "Enter [x] to cancel entire comparison, [s] to skip file, or just [Enter] to Continue." | |
read check | |
if [[ $check = "x" ]]; then break; fi | |
if [[ $check = "s" ]]; then | |
echo "Skipping $file." | |
else | |
rvimdiff "$file" "$server" | |
fi | |
fi | |
fi | |
done | |
} | |
# List all loaded functions, just like in zsh. | |
function functions() { | |
typeset -F | sed -e 's/^declare -f //' | |
} | |
# get the full file path of a given file | |
function filepath() { | |
find `pwd` -name "$@" 2> /dev/null | |
} | |
# get the full directory path for a given file | |
function dirpath() { | |
dirname $(filepath "$@") | |
} | |
END_FUNCTIONS | |
echo "Created new .functions" | |
########################################################### | |
cat << 'ENDPROMPT' >> .prompt | |
ID='\[\033[0;32m\]`echo "$LOGNAME"`@\h' | |
ZONE='`date "+%Z"`' | |
TIME='\[\033[0;34m\]\T' | |
DIRECTORY='\[\033[0;36m\]\w\[\033[00m\]' | |
COLON='\n>: ' | |
USERS=`(users | tr ' ' '\n' | uniq) 2> /dev/null` # no users on Windows | |
OTHERS="${USERS/$USER/}" | |
OTHERS="${OTHERS/$USERNAME/}" # this supports Windows, tho' N/A now. | |
if [[ $OTHERS = "" ]]; then | |
PRESENCE='' | |
elif [[ $OTHERS = "root" ]]; then | |
PRESENCE='\[\033[40;31m\]*\[\033[0m\] ' | |
else | |
PRESENCE='\[\033[41;30m\]*\[\033[0m\] ' | |
fi | |
LOCAL_COLOR_ON='\[\033[40;0;33m\]' | |
LOCAL_COLOR_OFF='\[\033[0m\]' | |
export PS1="${PRESENCE}${LOCAL_COLOR_ON}$(echo -en '${LOCAL_PROMPT_OPEN}')${LOCAL_COLOR_OFF}${ID} $TIME $ZONE $DIRECTORY ${LOCAL_COLOR_ON}$(echo -en '${LOCAL_PROMPT_CLOSE}')${LOCAL_COLOR_OFF}${COLON}" | |
# define LOCAL_PROMPT_OPEN and LOCAL_PROMPT_CLOSE in your .local file, to insert info pertinent to the local box | |
# these variables can change on the fly and will still be updated in your prompt | |
# because it is so hard (impossible) to set the color locally and make it work, | |
# it is set here. Sorry, you're stuck with yellow. :p | |
ENDPROMPT | |
echo "Created new .prompt" | |
########################################################### | |
if [[ ! -f .local ]]; then | |
cat << 'END_LOCAL' >> .local | |
export LOCAL_PROMPT_OPEN="${ENVIRONMENT} " | |
export LOCAL_PROMPT_CLOSE="" | |
END_LOCAL | |
echo "Created new .local" | |
fi | |
########################################################### | |
cat << 'END_PROJECTS' >> .projects | |
unset PROJECTS | |
function project() { | |
# $1 = name of project | |
# $2 = path to project | |
alias ${1}="cd ${2}" | |
# we'll need to filter out duplicates from this... | |
PROJECTS+=( "$1" ) | |
#NEW_PROJECTS=$( awk 'BEGIN{RS=ORS=" "}!a[$0]++' <<<${PROJECTS[@]} ); | |
#PROJECTS=( "${NEW_PROJECTS[*]}" ) | |
} | |
# TODO: uniq the arrays, within the limitations imposed by bash 3 :p | |
# this should be computed to work for newco and insite as well TODO! | |
alias apacheconfig='vim /etc/httpd/conf.d/${HOST_ID}.spartannash.com.conf' | |
# These are examples! edit this to reflect the projects you have on this box.: | |
project www "/var/www/vhosts/${HOST_ID}.spartannash.com/current" | |
project insite "/var/www/vhosts/${HOST_ID/www/insite}.spartannash.com/projects" | |
function projects() { | |
echo "Available projects:" | |
for project in ${PROJECTS[*]}; do | |
echo " $project" | |
done | |
} | |
# specify the function to be called every time the prompt is redrawn | |
PROMPT_COMMAND=project_settings | |
# define the function: | |
project_settings() { | |
# accept two file names... they make equal sense | |
if [[ -f "$PWD/.project" ]]; then | |
source "$PWD/.project" | |
fi | |
if [[ -f "$PWD/.settings" ]]; then | |
source "$PWD/.settings" | |
fi | |
} | |
# TODO: | |
# NEXT we might check for a .project file in the project directory | |
# and create one if none exists, with code to set $PROJECT_HOME | |
# and we might check that ./.project is being run on every `cd` | |
# or move the code to do that into this file. | |
END_PROJECTS | |
echo "Created new .projects" | |
########################################################### | |
cat << 'ENDBASHRC' >> .bashrc | |
# this is needed for remote drush calls | |
# (which don't get .bash_profile) | |
PATH=$PATH:/usr/local/zend/bin | |
ENDBASHRC | |
echo "Created new .bashrc" | |
########################################################### | |
cat << 'ENDSCREEN' >> .screenrc | |
# escape ^Zz | |
escape \e`` | |
# get rid of the annoying splash screen: | |
startup_message off | |
# these provide a visual reminder we're in screen, and good info: | |
caption always "%{= BW}%4n %t%? (%u)%?%?: %h%?" | |
caption alwayslastline | |
hardstatus alwayslastline | |
backtick 1 0 0 uname -sr # platform architecture | |
backtick 2 0 0 echo "$USER" | |
# EXPLANATION: green user host arc ? white TIME | |
hardstatus string '%{= kG}[ %2` %{G}%H (%1`) %{g}][%= %{=kw}%?%-Lw%?%{r}(%{W}%n*%f%t%?(%u)%?%{r})%{w}%?%+Lw%?%?%= %{g}][ %{W}%c %{g}]' | |
# REMOVED FROM HARDSTATUS: DATE | |
# %{B}%Y-%m-%d | |
# detach automatically on hangup | |
autodetach on | |
# change window with ALT-. ALT-, | |
bindkey "^[," prev | |
bindkey "^[." next | |
# Default screens | |
### screen -t shell1 0 | |
### screen -t shell2 1 | |
# remember enough to make scrolling back worthwhile: | |
defscrollback 50000 | |
# easily open screen windows 10 through 19 with Shift- | |
bind ! select 11 | |
bind @ select 12 | |
bind \# select 13 | |
bind $ select 14 | |
bind % select 15 | |
bind \^ select 16 | |
bind & select 17 | |
bind * select 18 | |
bind ( select 19 | |
bind ) select 10 | |
# disable freezing: | |
bind s | |
# makes splitting screen less risky! | |
# stop using A for titles and use T! | |
bind A | |
bind T title | |
# prevent accidentally detaching: | |
bind d | |
# (you still have ^D) | |
################################################# | |
echo " " | |
clear | |
echo "Command character is backtick: `" | |
# echo "Use Option , and Option . (< and > keys) to cycle through windows." | |
# echo "Type 'example screen' for common & useful examples" | |
sleep 1 | |
activity 'Action in window %n' | |
# set the bell message. %n is the window number. | |
bell_msg "ding ding ding! (%n)" | |
ENDSCREEN | |
########################################################### | |
cat << 'ENDVIMRC' >> .vimrc | |
" necessary for some vim features: | |
set nocompatible | |
" might cause pasting problems: | |
set autoindent | |
set smartindent | |
" line-numbering: | |
set number | |
" syntax coloring: | |
syntax on | |
" show rule | |
set ruler | |
" ???: | |
" map! c>`^ | |
" a better escape from insertion mode | |
map! ;; <Esc>`^ | |
" redo: | |
nmap U <C-R> " ^R | |
" show status line always | |
set laststatus=2 | |
" fix jumping-arrow (ABCD) problem (on e.g. Solaris): | |
" set term=iris-ansi "xterm "linux | |
if version >= 700 | |
au InsertEnter * hi StatusLine ctermbg=3 ctermfg=4 | |
" au InsertEnter * set nocuc cul | hi cursorline ctermbg=blue ctermfg=white | |
au InsertLeave * hi StatusLine term=reverse ctermfg=2 ctermbg=0 | |
" au InsertLeave * set nocuc cul | hi cursorline ctermbg=black ctermfg=none | |
endif | |
" use 2 spaces instead of tabs: | |
set cindent | |
set shiftwidth=2 | |
set tabstop=2 | |
set expandtab | |
set softtabstop=2 | |
" TODO: assign a keystroke to toggle this setting: | |
set nowrap | |
" for now I want to experiment with how it is to have this setting | |
" experimental: | |
augroup Makefile | |
au! | |
au BufReadPre Makefile set noexpandtab | |
augroup END | |
" auto-detect filetypes | |
filetype on | |
" colorscheme elflord | |
" colorscheme peachpuff | |
" colorscheme default | |
" Set automatic filetype detection to on | |
filetype on | |
" set the statusline with a bunch of info... | |
set statusline=%{Version()}\ \ \ %1*[%02n]%*\ %(%M%R%H%)\ %F%*\ %=%{Settings()}\ %3*<%l,%c%V>%* | |
fu! Version() | |
return version | |
endf | |
fu! Settings() | |
let settings="" | |
" autoindent | |
if &ai| let settings=settings." autoindent" |endif | |
" expandtab | |
if &et| let settings=settings." expandtab" |endif | |
" highlightsearch | |
if &hls| let settings=settings." highlight" |endif | |
" paste | |
if &paste|let settings=settings." paste"|endif | |
" shiftwidth | |
if &shiftwidth!=8|let settings=settings." ".&shiftwidth|endif | |
" textwidth - show always! | |
let settings=settings." textwidth=".&tw | |
" let settings=settings."\[".&lines.",".&columns."\]" | |
return settings | |
endf | |
" show command you're typing: | |
set showcmd | |
" tab completion: | |
set wildmenu | |
set wildmode=list:longest,full | |
" enable mouse support in console: | |
set mouse=a | |
" ii gets you out of insert mode | |
inoremap ii <Esc> | |
nnoremap IIII <Nop> " ??? | |
" SEARCH | |
set incsearch " find terms as you type them | |
set magic " use * in search/replace patterns | |
" BACKUPS: get them out of the current directory! | |
set backupdir=~/.vim/backup | |
set backup | |
set directory=~/.vim/tmp | |
" show matching brackets | |
set showmatch | |
set cmdheight=2 | |
" add menus to terminal-based vim! | |
:set nocompatible | |
:set wildmenu | |
:set wildmode=full | |
:source $VIMRUNTIME/menu.vim | |
:set wildcharm=<C-Z> | |
:map <F4> :emenu <C-Z> | |
"############################################################################## | |
" Easier split navigation | |
"############################################################################## | |
" Use ctrl-[hjkl] to select the active split! | |
nmap <silent> <c-k> :wincmd k<CR> | |
nmap <silent> <c-j> :wincmd j<CR> | |
nmap <silent> <c-h> :wincmd h<CR> | |
nmap <silent> <c-l> :wincmd l<CR> | |
ENDVIMRC | |
echo "Created new .vimrc" | |
########################################################### | |
# get directories ready, since vim won't create these: | |
mkdir -p ~/.vim/backup ~/.vim/tmp | |
########################################################### | |
cat << 'ENDSOLARIS' >> .solaris | |
# load Solaris-specific settings & make up for its defects ;p # | |
if [[ "`uname`"="SunOS" ]]; then | |
TERM=xterm | |
alias whoami='echo "$LOGNAME"' | |
fi | |
ENDSOLARIS | |
echo "Created new .solaris" | |
########################################################### | |
cat << 'ENDFOLLOW' >> bin/follow | |
#!/usr/bin/perl | |
use Getopt::Long qw(:config pass_through); | |
my %colors = | |
( | |
'red' => '41;37;1m', | |
'green' => '42;37;1m', | |
'yellow' => '43;30;1m', | |
'blue' => '44;37;1m', | |
'magenta' => '45;37;1m', | |
'cyan' => '46;30;1m', | |
'white' => '47;30;1m' | |
); | |
my @highlights; | |
GetOptions ("highlight=s" => \@highlights); | |
my $tailargs; | |
for(my $c = 0; $c < scalar(@ARGV); $c++) | |
{ | |
$tailargs .= ' ' . $ARGV[$c]; | |
} | |
my $highlightargs; | |
for(my $c = 0; $c < scalar(@highlights); $c++) | |
{ | |
my @data = split(/:/, $highlights[$c], 2); | |
my $color = $colors{$data[0]}; | |
my $search = $data[1]; | |
$highlightargs .= "s/(^.*$search.*\$)/\\033\\[$color\$1\\033[0m/gi; "; | |
} | |
my $cmd = 'tail ' . $tailargs . " | ruby -p -e '" . $highlightargs . "'"; | |
#print 'executing: ' . $cmd . "\r\n"; | |
system($cmd); | |
ENDFOLLOW | |
echo "Created new bin/follow" | |
chmod u+x bin/follow | |
########################################################### | |
cat << 'ENDPROTECTSESSION' >> bin/protect_session | |
#!/bin/sh | |
# kill the process for this session | |
PID=`ps | grep protect_session | sed 's/^ *\(.*\) *$/\1/' | cut -d' ' -f 1` | |
# we can't use pgrep above because it returns more than just the current session's PIDs | |
# but we can use it below: | |
# TODO: find a cross-platform alternative to pgrep. it's not installed by default on OS X, and maybe not BSDs or Solaris. | |
# which and whereis give wildly inconsistent return values across these platforms, so they are not much use in detecting pgrep. | |
# it might be better to just create a long version like for PID. | |
PIDS=`pgrep protect_session` | |
if [[ -n $PID ]]; then | |
echo "Killing process $PID." | |
kill $PID | |
fi | |
# offer to remove all other instances of protect_session | |
if [[ -n $PIDS ]]; then | |
echo "If you have other sessions being maintained unnecessarily, you can close them now." | |
killall -iq protect_session | |
fi | |
ENDPROTECTSESSION | |
echo "Created new bin/protect_session" | |
chmod u+x bin/protect_session | |
########################################################### | |
cat << 'ENDPROFILE' >> .profile | |
TERM=xterm | |
SCREEN=$(which screen 2> /dev/null) | |
if [[ -n $SCREEN ]]; then | |
# we've got it installed in the path... | |
screen -s bash -R -A | |
else | |
#echo "Searching for screen in the background..." | |
#sleep 1 | |
#find / -name screen 2> /dev/null & | |
SHELL=`which bash` | |
exec bash -l # we just switch to bash without screen | |
fi | |
ENDPROFILE | |
echo "Created new .profile" | |
########################################################### | |
cat << 'ENDACKRC' >> .ackrc | |
--group | |
--color-filename=BLUE | |
--color-match=RED | |
--follow | |
#--all-types | |
#--nobinary | |
--context=7 | |
# this doesn't work. blech! | |
# --pager="'less -r'" | |
# use when only listing filenames: | |
#--print0 | |
ENDACKRC | |
echo "Created new .ackrc" | |
########################################################### | |
# install ack | |
# TODO: and code to accomodate machines without wget either (perl?) | |
ACK_URL="http://beyondgrep.com/ack-2.12-single-file" | |
# both curl and wget have strange ideas of what constitutes STDERR: | |
if [[ -n $(curl -L http://www.apple.com 2> /dev/null) ]]; then | |
curl "$ACK_URL" > ~/bin/ack && chmod 0755 ~/bin/ack | |
elif [[ -n $(wget -S http://www.apple.com 2> /dev/null) ]]; then | |
wget "$ACK_URL" 1> /dev/null && mv ack-standalone ~/bin/ack && chmod 0755 ~/bin/ack | |
echo "Created new ~/bin/ack" | |
else | |
echo "You can install ack by downloading " | |
echo " $ACK_URL" | |
echo "and renaming the downloaded file to ~/bin/ack" | |
echo "and entering:" | |
echo " chmod 0755 ~/bin/ack" | |
fi | |
########################################################### | |
cat << 'ENDREBUILD' > ~/bin/rebuild | |
#!/bin/bash | |
pushd ~ | |
wget --no-check-certificate http://gist.github.com/raw/3639058/build_home.sh | |
bash build_home.sh | |
rm ./build_home.sh | |
popd | |
ENDREBUILD | |
echo "Created new ~/bin/rebuild" | |
########################################################### | |
chmod u+x bin/rebuild | |
########################################################### | |
# clean up | |
# bash 3.2.25: | |
for file in .keep_alive .aliases .functions .prompt .variables .local .vimrc .solaris .profile .bashrc .bash_profile .ackrc .screenrc .inputrc .spartan ; do | |
if [[ -z `diff $file $file.$DATE 2> /dev/null` ]]; then | |
rm -f $file.$DATE | |
else | |
echo "$file.$DATE has changes you may want to merge into $file:" | |
echo " echo; echo '<' $file '------' $file.$DATE '>'" >> ".diff.$DATE" | |
echo " diff $file $file.$DATE" | tee -a ".diff.$DATE" | |
echo " echo; echo '************************'; sleep 1; echo" >> ".diff.$DATE" | |
DIFFS='true' | |
fi | |
done | |
if [[ $DIFFS = 'true' ]]; then | |
echo "To compare all modified files, type" | |
echo " source .diff.$DATE" | |
fi | |
# TODO: add a counter, and create aliases in the loop like | |
# alias diff1='diff .screenrc .screenrc.20100729' | |
# alias diff2=... | |
########################################################### | |
echo "Done building your home. Here are your current dot files:" | |
sleep 1 | |
ls -d1 .* | |
# here's a faster way to apply this to lots of servers at once; copy this entire line to each one: | |
# wget https://raw.github.com/gist/3639058/build_home.sh && bash build_home.sh && . .bash_profile |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment