pull() { url="" file="" while [ $# -gt 0 ] ; do case $1 in -f) file="$2" shift; shift; ;; -u) url="$2" shift; shift; ;; esac done CMD="$(which curl wget fetch 2>/dev/null | tail -n1)" case $CMD in *curl) "$CMD" "$url" > "$file" ;; *wget) "$CMD" "$url" -O "$file" ;; *fetch) "$CMD" "$url" -o "$file" ;; esac } pulldotfile() { file="$1" destfile="$(basename "${file}")" pull -u "${UPDATE_URL}${file}" -f "$HOME/.${destfile}" } _make_ssh_dir_if_not_exists() { auth_keys="$HOME/.ssh/authorized_keys" if ! [ -d $HOME/.ssh ] ; then mkdir $HOME/.ssh ; fi chmod 700 $HOME/.ssh chmod 600 $auth_keys } _pullkeys() { url="$1"; shift _timestamp="$(timestamp)" _make_ssh_dir_if_not_exists auth_keys="$HOME/.ssh/authorized_keys" mv "$auth_keys" "${auth_keys}.${_timestamp}" || \ echo "Authorized Keys do not currently exist" pull -u "$url" -f "$auth_keys" || \ mv "${auth_keys}.${_timestamp}" "$auth_keys" ssh-keygen -lf "$auth_keys" || \ mv "${auth_keys}.${_timestamp}" "$auth_keys" chmod 600 $auth_keys } pullkeys() { file="keys/$1"; shift; url="${UPDATE_URL}${file}" _pullkeys "$url" } pullkeys_github() { _username="$1"; shift; url="https://github.com/${_username}.keys" _pullkeys "$url" } pulltermcolors() { file="$HOME/bin/terminal-colors" if ! [ -d $HOME/bin ] ; then mkdir $HOME/bin fi pull -u ${UPDATE_URL}/util/terminal-colors -f $file chmod +x $file } updatetmuxconf() { pulldotfile "tmux/tmux.conf" pulldotfile "tmux/tmux_helper.sh" if ! [ -e $HOME/.tmux.conf.local ] && [ `id -u` -eq 0 ] ; then # If I ever change the color from green this will have to be updated I guess grep 'green' $HOME/.tmux.conf | sed -e's/green/red/g' > $HOME/.tmux.conf.local elif ! [ -e $HOME/.tmux.conf.local ] ; then touch $HOME/.tmux.conf.local fi } updategitconf() { file="gitconfig/$1" pull -u "${UPDATE_URL}${file}" -f "$HOME/.gitconfig" } updateshell() { pulldotfile "mkshrc" . $HOME/.mkshrc } updatevimrc() { OLDWD="$(pwd)" cd "$HOME" git clone --recurse-submodules "$VIM_GIT_URL" .vim exit="$?" cd $HOME/.vim || { echo "Cannot cd to .vim dir" ; return; } if [ "$exit" -gt 0 ] ; then git pull origin master git submodule update fi ./link-vimrc.sh cd $OLDWD } updatevimrc_basic() { pull -u "$VIM_BASIC_URL" -f ~/.vimrc }