pulltermcolors() { file="$HOME/bin/terminal-colors" if ! [ -d $HOME/bin ] ; then mkdir $HOME/bin fi pull -u ${UPDATE_URL}/terminal-colors -f $file chmod +x $file } 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" pull -u "${UPDATE_URL}${file}" -f "$HOME/.${file}" } _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" } updatetmuxconf() { pulldotfile "tmux.conf" pulldotfile "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 $VIM_GIT_URL .vim if [ $? -gt 0 ] ; then cd $HOME/.vim git pull origin master else cd $HOME/.vim fi ./setup.sh && \ ./link-vimrc.sh cd $OLDWD } updatevimrc_basic() { pull -u "$VIM_BASIC_URL" -f ~/.vimrc } placebasicvimrc() { if [ -z "$1" ] ; then echo All arguments are passed to SSH, but you need at least one return fi _TMP="$(mktemp)" if [ -z "$_TMP" ] ; then echo Cannot continue, temp file cannot be zero length!; return fi pull -u "$VIM_BASIC_URL" -f "$_TMP" cat "$_TMP" | ssh "$@" "cat - > ~/.vimrc" rm "$_TMP" }