forked from colonelpanic/dotfiles
Update setup script, make do_the_brew bash compatible.
This commit is contained in:
parent
202b217520
commit
b165c4c4ac
41
bootstrap.sh
41
bootstrap.sh
@ -1,41 +0,0 @@
|
|||||||
#!/usr/bin/env bash
|
|
||||||
cd `dirname $BASH_SOURCE` && source resources/bootstrapping.sh
|
|
||||||
DOTFILES_DIRECTORY="$(dotfiles_abspath)/dotfiles"
|
|
||||||
|
|
||||||
|
|
||||||
function symlink_dotfiles() {
|
|
||||||
cd $DOTFILES_DIRECTORY
|
|
||||||
[ -a ~/.dotfiles-backups ] && mv ~/.dotfiles-backups ~/.dotfiles-backups.old
|
|
||||||
mkdir ~/.dotfiles-backups
|
|
||||||
for filename in *; do
|
|
||||||
local link_destination="$HOME/.$filename"
|
|
||||||
local link_target=$(${readlink_command} -f $filename)
|
|
||||||
echo "linking $link_destination to $link_target"
|
|
||||||
# Using only test -e doesn't work here because it will return
|
|
||||||
# false if the destination of the symbolic link at does not exist.
|
|
||||||
test -e $link_destination || test -L $link_destination && mv $link_destination ~/.dotfiles-backups
|
|
||||||
ln -si $link_target $link_destination
|
|
||||||
done
|
|
||||||
[ -a ~/.dotfiles-backups.old ] && mv ~/.dotfiles-backups.old ~/.dotfiles-backups/.dotfiles-backups
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
function parse_options() {
|
|
||||||
while getopts "f" OPTCHAR; do
|
|
||||||
case $optchar in
|
|
||||||
f)
|
|
||||||
symlink_dotfiles
|
|
||||||
return
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
done
|
|
||||||
shift $((OPTIND-1))
|
|
||||||
|
|
||||||
read -p "Symlinking files from $DOTFILES_DIRECTORY. This may overwrite existing files in your home directory. Do you wish to proceed? (y/n) " -n 1
|
|
||||||
if [[ $REPLY =~ ^[Yy]$ ]]; then
|
|
||||||
echo
|
|
||||||
symlink_dotfiles
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
parse_options
|
|
@ -1,11 +1,13 @@
|
|||||||
function brew_install_items() {
|
function brew_install_items() {
|
||||||
echo $@
|
|
||||||
for package_install_string in $@;
|
for package_install_string in $@;
|
||||||
do
|
do
|
||||||
# Horrible hack to induce word splitting.
|
package_args=$package_install_string
|
||||||
eval "package_args=($package_install_string)"
|
if is_zsh;
|
||||||
|
then
|
||||||
|
# Horrible hack to induce word splitting.
|
||||||
|
eval "package_args=($package_install_string)"
|
||||||
|
fi
|
||||||
brew install $package_args;
|
brew install $package_args;
|
||||||
brew link $package_args[1];
|
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -18,68 +20,67 @@ function fix_brew_htop() {
|
|||||||
|
|
||||||
function do_the_brew() {
|
function do_the_brew() {
|
||||||
ESSENTIAL=(
|
ESSENTIAL=(
|
||||||
"emacs"
|
"emacs" \
|
||||||
"git"
|
"tmux" \
|
||||||
"tmux"
|
"python --with-brewed-openssl" \
|
||||||
"python --with-brewed-openssl"
|
"htop" \
|
||||||
"htop"
|
"greadlink" \
|
||||||
"greadlink"
|
"vim --override-system-vi" \
|
||||||
"vim --override-system-vi"
|
"zsh" \
|
||||||
"zsh"
|
"make" \
|
||||||
"make"
|
|
||||||
)
|
)
|
||||||
# `find`, `locate`, `updatedb`, and `xargs`, g-prefixed
|
# `find`, `locate`, `updatedb`, and `xargs`, g-prefixed
|
||||||
# core utilities (those that come with OS X are outdated)
|
# core utilities (those that come with OS X are outdated)
|
||||||
BASICS=(
|
BASICS=(
|
||||||
"findutils"
|
"findutils" \
|
||||||
"coreutils"
|
"coreutils" \
|
||||||
"binutils"
|
"binutils" \
|
||||||
"diffutils"
|
"diffutils" \
|
||||||
"ed --default-names"
|
"ed --default-names" \
|
||||||
"gawk"
|
"gawk" \
|
||||||
"gnu-indent --default-names"
|
"gnu-indent --default-names" \
|
||||||
"gnu-sed --default-names"
|
"gnu-sed --default-names" \
|
||||||
"gnu-tar --default-names"
|
"gnu-tar --default-names" \
|
||||||
"gnu-which --default-names"
|
"gnu-which --default-names" \
|
||||||
"gnutls --default-names"
|
"gnutls --default-names" \
|
||||||
"grep --default-names"
|
"grep --default-names" \
|
||||||
"gzip"
|
"gzip" \
|
||||||
"watch"
|
"watch" \
|
||||||
"wdiff --with-gettext"
|
"wdiff --with-gettext" \
|
||||||
"wget --enable-iri"
|
"wget --enable-iri" \
|
||||||
)
|
)
|
||||||
SHOULD_INSTALL=(
|
SHOULD_INSTALL=(
|
||||||
"nmap"
|
"nmap" \
|
||||||
"readline"
|
"readline" \
|
||||||
"netcat"
|
"netcat" \
|
||||||
"reattach-to-user-namespace"
|
"reattach-to-user-namespace" \
|
||||||
"daemonize"
|
"daemonize" \
|
||||||
"ngrep"
|
"ngrep" \
|
||||||
"gist"
|
"gist" \
|
||||||
"gawk"
|
"gawk" \
|
||||||
"pstree"
|
"pstree" \
|
||||||
"ack"
|
"ack" \
|
||||||
"hub"
|
"hub" \
|
||||||
"tig"
|
"tig" \
|
||||||
"heroku"
|
"heroku" \
|
||||||
"scala"
|
"scala" \
|
||||||
"sbt"
|
"sbt" \
|
||||||
"node"
|
"node" \
|
||||||
"npm"
|
"npm" \
|
||||||
)
|
)
|
||||||
MISC=(
|
MISC=("file-formula" \
|
||||||
"file-formula"
|
"less" \
|
||||||
"git"
|
"openssh --with-brewed-openssl" \
|
||||||
"less"
|
"perl518" \
|
||||||
"openssh --with-brewed-openssl"
|
"rsync" \
|
||||||
"perl518"
|
"svn" \
|
||||||
"rsync"
|
"unzip" \
|
||||||
"svn"
|
"macvim --override-system-vim --custom-system-icons" \
|
||||||
"unzip"
|
|
||||||
"macvim --override-system-vim --custom-system-icons"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
install_items=()
|
install_items=()
|
||||||
|
OPTIND=1
|
||||||
|
echo "${MISC[@]}"
|
||||||
while getopts "uebsmah" OPTCHAR;
|
while getopts "uebsmah" OPTCHAR;
|
||||||
do
|
do
|
||||||
case $OPTCHAR in
|
case $OPTCHAR in
|
||||||
@ -103,7 +104,20 @@ function do_the_brew() {
|
|||||||
install_items=("${install_items[@]}" "${ESSENTIAL[@]}" "${BASICS[@]}" "${SHOULD_INSTALL[@]}" "${MISC[@]}")
|
install_items=("${install_items[@]}" "${ESSENTIAL[@]}" "${BASICS[@]}" "${SHOULD_INSTALL[@]}" "${MISC[@]}")
|
||||||
;;
|
;;
|
||||||
h)
|
h)
|
||||||
echo "Usage:
|
do_the_brew_help
|
||||||
|
return
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
echo "Installing the following packages:"
|
||||||
|
for package_name in "${install_items[@]}"; do echo $package_name; done;
|
||||||
|
brew update
|
||||||
|
brew_install_items $install_items
|
||||||
|
brew cleanup
|
||||||
|
}
|
||||||
|
|
||||||
|
function do_the_brew_help() {
|
||||||
|
echo "do_the_brew Usage:
|
||||||
-a install all packages.
|
-a install all packages.
|
||||||
-u upgrade brew packages.
|
-u upgrade brew packages.
|
||||||
-e install essential packages
|
-e install essential packages
|
||||||
@ -112,12 +126,4 @@ function do_the_brew() {
|
|||||||
-m install very non-essential packages.
|
-m install very non-essential packages.
|
||||||
-h display this help message.
|
-h display this help message.
|
||||||
"
|
"
|
||||||
return
|
|
||||||
esac
|
|
||||||
done
|
|
||||||
echo "Installing:"
|
|
||||||
for package_name in $install_items; do echo $package_name; done;
|
|
||||||
brew update
|
|
||||||
brew_install_items $install_items
|
|
||||||
brew cleanup
|
|
||||||
}
|
}
|
||||||
|
@ -1,2 +1,2 @@
|
|||||||
local dircolors_file="$HOME/.dircolors"
|
dircolors_file="$HOME/.dircolors"
|
||||||
test -r $dircolors_files && eval "$(dircolors $dircolors_file)"
|
test -r $dircolors_files && eval "$(dircolors $dircolors_file)"
|
||||||
|
@ -1,9 +1,3 @@
|
|||||||
function dotfiles_abspath() {
|
|
||||||
readlink_command='readlink'
|
|
||||||
command -v greadlink > /dev/null && readlink_command="greadlink"
|
|
||||||
echo "$(${readlink_command} -f "$BASH_SOURCE" | xargs dirname | xargs dirname)"
|
|
||||||
}
|
|
||||||
|
|
||||||
function go2dotfiles() {
|
function go2dotfiles() {
|
||||||
cd $(dirname `readlink -f ~/.zshrc | xargs dirname`)
|
cd $(dirname `readlink -f ~/.zshrc | xargs dirname`)
|
||||||
}
|
}
|
||||||
@ -42,6 +36,7 @@ function confirm() {
|
|||||||
|
|
||||||
function get_cols() {
|
function get_cols() {
|
||||||
FS=' '
|
FS=' '
|
||||||
|
OPTIND=1
|
||||||
while getopts "F:" OPTCHAR; do
|
while getopts "F:" OPTCHAR; do
|
||||||
case $OPTCHAR in
|
case $OPTCHAR in
|
||||||
F)
|
F)
|
||||||
@ -129,6 +124,7 @@ function git_root() {
|
|||||||
function git_diff_replacing() {
|
function git_diff_replacing() {
|
||||||
local original_sha='HEAD~1'
|
local original_sha='HEAD~1'
|
||||||
local new_sha='HEAD'
|
local new_sha='HEAD'
|
||||||
|
OPTIND=1
|
||||||
while getopts "do:n:" OPTCHAR;
|
while getopts "do:n:" OPTCHAR;
|
||||||
do
|
do
|
||||||
case $OPTCHAR in
|
case $OPTCHAR in
|
||||||
@ -154,6 +150,7 @@ function git_diff_replacing() {
|
|||||||
function git_reset_author() {
|
function git_reset_author() {
|
||||||
local should_update_command=''
|
local should_update_command=''
|
||||||
local update_command=''
|
local update_command=''
|
||||||
|
OPTIND=1
|
||||||
while getopts "a:e:A:E:h" OPTCHAR;
|
while getopts "a:e:A:E:h" OPTCHAR;
|
||||||
do
|
do
|
||||||
case $OPTCHAR in
|
case $OPTCHAR in
|
||||||
|
@ -1,17 +1,16 @@
|
|||||||
ESSENTIAL=(ipdb ipython virtualenv)
|
|
||||||
FOR_EDITOR=(jedi pyflakes)
|
|
||||||
USEFUL=(
|
|
||||||
Flask
|
|
||||||
ddg
|
|
||||||
ouimeaux
|
|
||||||
readline
|
|
||||||
simplejson
|
|
||||||
tox
|
|
||||||
numpy
|
|
||||||
)
|
|
||||||
|
|
||||||
function install_python_packages() {
|
function install_python_packages() {
|
||||||
sudo pip install $ESSENTIAL
|
ESSENTIAL=(ipdb ipython virtualenv)
|
||||||
|
FOR_EDITOR=(jedi pyflakes)
|
||||||
|
USEFUL=(
|
||||||
|
Flask
|
||||||
|
ddg
|
||||||
|
ouimeaux
|
||||||
|
readline
|
||||||
|
simplejson
|
||||||
|
tox
|
||||||
|
numpy
|
||||||
|
)
|
||||||
|
OPTIND=1
|
||||||
while getopts "uea" OPTCHAR;
|
while getopts "uea" OPTCHAR;
|
||||||
do
|
do
|
||||||
case $OPTCHAR in
|
case $OPTCHAR in
|
||||||
@ -24,8 +23,18 @@ function install_python_packages() {
|
|||||||
a)
|
a)
|
||||||
sudo pip install $FOR_EDITOR
|
sudo pip install $FOR_EDITOR
|
||||||
sudo pip install $USEFUL
|
sudo pip install $USEFUL
|
||||||
|
install_pygame
|
||||||
|
install_powerline
|
||||||
|
;;
|
||||||
|
h)
|
||||||
|
echo "
|
||||||
|
-u Install useful but non essential python.
|
||||||
|
-e Install editor python packages.
|
||||||
|
-a Install all python utilities."
|
||||||
|
;;
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
|
sudo pip install $ESSENTIAL
|
||||||
}
|
}
|
||||||
|
|
||||||
function install_pygame() {
|
function install_pygame() {
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
function make_me_synergy() {
|
function make_me_synergy() {
|
||||||
local new_host_name="$(echo $SSH_CONNECTION | get_cols 1)"
|
local new_host_name="$(echo $SSH_CONNECTION | get_cols 1)"
|
||||||
|
OPTIND=1
|
||||||
while getopts "h:" OPTCHAR; do
|
while getopts "h:" OPTCHAR; do
|
||||||
case $OPTCHAR in
|
case $OPTCHAR in
|
||||||
h)
|
h)
|
||||||
|
@ -5,6 +5,6 @@ done
|
|||||||
alias srczsh="source ~/.zshrc"
|
alias srczsh="source ~/.zshrc"
|
||||||
|
|
||||||
# Online help.
|
# Online help.
|
||||||
unalias run-help
|
unalias run-help 2> /dev/null 1>/dev/null
|
||||||
autoload run-help
|
autoload run-help
|
||||||
HELPDIR=/usr/local/share/zsh/helpfiles
|
HELPDIR=/usr/local/share/zsh/helpfiles
|
||||||
|
98
setup.sh
98
setup.sh
@ -1,33 +1,85 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
function setup() {
|
cd `dirname $BASH_SOURCE` && source resources/bootstrapping.sh
|
||||||
cd `dirname $BASH_SOURCE` && source resources/bootstrapping.sh
|
source dotfiles/lib/shellrc/functions.sh
|
||||||
source dotfiles/lib/shellrc/functions.sh
|
source dotfiles/lib/shellrc/brew.sh
|
||||||
source dotfiles/lib/shellrc/brew.sh
|
source dotfiles/lib/shellrc/python.sh
|
||||||
source dotfiles/lib/shellrc/python.sh
|
DOTFILES_DIRECTORY="$(dotfiles_abspath)/dotfiles"
|
||||||
|
|
||||||
case `uname` in
|
|
||||||
'Darwin')
|
|
||||||
osx_setup
|
|
||||||
;;
|
|
||||||
'Linux')
|
|
||||||
source resources/apt-get.sh
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
|
|
||||||
install_powerline
|
function symlink_dotfiles() {
|
||||||
source bootstrap.sh
|
cd $DOTFILES_DIRECTORY
|
||||||
|
[ -a ~/.dotfiles-backups ] && mv ~/.dotfiles-backups ~/.dotfiles-backups.old
|
||||||
|
mkdir ~/.dotfiles-backups
|
||||||
|
for filename in *; do
|
||||||
|
local link_destination="$HOME/.$filename"
|
||||||
|
local link_target=$(${readlink_command} -f $filename)
|
||||||
|
echo "linking $link_destination to $link_target"
|
||||||
|
# Using only test -e doesn't work here because it will return
|
||||||
|
# false if the destination of the symbolic link at does not exist.
|
||||||
|
test -e $link_destination || test -L $link_destination && mv $link_destination ~/.dotfiles-backups
|
||||||
|
ln -si $link_target $link_destination
|
||||||
|
done
|
||||||
|
[ -a ~/.dotfiles-backups.old ] && mv ~/.dotfiles-backups.old ~/.dotfiles-backups/.dotfiles-backups
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function osx_setup() {
|
function symlink_dotfiles_prompt() {
|
||||||
while getopts "uebsmaho" OPTCHAR;
|
read -p "Symlinking files from $DOTFILES_DIRECTORY. This may overwrite existing files in your home directory. Do you wish to proceed? (y/n) " -n 1
|
||||||
|
if [[ $REPLY =~ ^[Yy]$ ]]; then
|
||||||
|
echo
|
||||||
|
symlink_dotfiles
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
function setup_help() {
|
||||||
|
echo "setup Usage:
|
||||||
|
-a Install apt-get packages.
|
||||||
|
-o Run OSX configuration commands.
|
||||||
|
-s Symlink dotfiles to home directory.
|
||||||
|
-b Install brew packages.
|
||||||
|
-p Install python packages.
|
||||||
|
-h display this help message."
|
||||||
|
}
|
||||||
|
|
||||||
|
function setup() {
|
||||||
|
if [[ $# -eq 0 ]] ; then
|
||||||
|
setup_help
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
while getopts "aosbp" OPTCHAR;
|
||||||
do
|
do
|
||||||
case $OPTCHAR in
|
case $OPTCHAR in
|
||||||
h)
|
a)
|
||||||
echo "brew options:"
|
source resources/apt-get.sh
|
||||||
do_the_brew -h
|
|
||||||
exit
|
|
||||||
;;
|
;;
|
||||||
source resources/osx.sh
|
b)
|
||||||
do_the_brew $@
|
do_the_brew_help
|
||||||
|
read -p "Enter flags for brew package installation:
|
||||||
|
"
|
||||||
|
[[ $REPLY[0] != '-' ]] && REPLY="-$REPLY"
|
||||||
|
do_the_brew $REPLY
|
||||||
|
;;
|
||||||
|
o)
|
||||||
|
sudo -v
|
||||||
|
source resources/osx.sh
|
||||||
|
;;
|
||||||
|
s)
|
||||||
|
symlink_dotfiles_prompt
|
||||||
|
;;
|
||||||
|
p)
|
||||||
|
install_python_packages -h
|
||||||
|
read -p "Enter flags for python package installation"
|
||||||
|
if [[ $REPLY[0] != '-' ]]; then
|
||||||
|
REPLY="-$REPLY"
|
||||||
|
fi
|
||||||
|
install_python_packages $REPLY
|
||||||
|
;;
|
||||||
|
h)
|
||||||
|
setup_help
|
||||||
|
return
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
|
setup $@
|
||||||
|
Loading…
Reference in New Issue
Block a user