restructuring

This commit is contained in:
David Todd
2020-03-25 14:26:51 -05:00
parent f9660904b3
commit a324612c70
36 changed files with 42 additions and 170 deletions

View File

@@ -0,0 +1,76 @@
#!/usr/bin/env zsh
# Modified from https://github.com/robbyrussell/oh-my-zsh/blob/master/tools/check_for_upgrade.sh
# Original Copyright: (c) 2009-2018 Robby Russell and contributors
# Modified Copyright: (c) 2018 David Todd (c0de)
# License: MIT
zmodload zsh/datetime
function _current_epoch() {
echo $(( $EPOCHSECONDS / 60 / 60 / 24 ))
}
function _update_dotfiles_update() {
echo "export LAST_EPOCH=$(_current_epoch)" > ${HOME}/.dotfiles-update
echo "touched ~/.dotfiles-update"
}
function _upgrade_dotfiles() {
env _DOTFILES=$_DOTFILES sh $_DOTFILES/internal_bin/upgrade.sh
# update the zsh file
_update_dotfiles_update
}
# Configure this in shell/env
epoch_target=$UPDATE_DOTFILES_DAYS
if [[ -z "$epoch_target" ]]; then
# Default to every 2 weeks
epoch_target=13
fi
# Cancel upgrade if the current user doesn't have
# write permissions for the dotfiles directory.
if [[ -w "$_DOTFILES" ]]; then
else
echo "You can't write to $(_dotfiles)!"
return 1
fi
# Cancel upgrade if git is unavailable on the system
if [[ $(whence git >/dev/null) || false ]]; then
else
echo "git is not available"
return 2
fi
if mkdir -p "$_DOTFILES/update.lock" 2>/dev/null; then
if [ -f ${HOME}/.dotfiles-update ]; then
. ${HOME}/.dotfiles-update
if [[ -z "$LAST_EPOCH" ]]; then
echo "Missing \$LAST_EPOCH"
_update_dotfiles_update && return 0;
fi
epoch_diff=$(($(_current_epoch) - $LAST_EPOCH))
if [ $epoch_diff -gt $epoch_target ]; then
if [ "$DISABLE_UPDATE_PROMPT" = "true" ]; then
_upgrade_dotfiles
else
echo "[Dotfiles] Would you like to check for updates? [Y/n]: \c"
read line
if [[ "$line" == Y* ]] || [[ "$line" == y* ]] || [ -z "$line" ]; then
_upgrade_dotfiles
else
_update_dotfiles_update
fi
fi
fi
else
echo "Missing ~/.dotfiles-update"
# create the zsh file
_update_dotfiles_update
fi
rmdir $_DOTFILES/update.lock
fi

16
internal_bin/install.arch Executable file
View File

@@ -0,0 +1,16 @@
#!/usr/bin/env bash
# This ensures that the entire script is downloaded before execution
{
sudo pacman -Syu
sudo pacman -S yay
yay -Syu
yay -S tmux zsh vim git\
terminator rofi feh xcompmgr\
i3lock-fancy i3blocks ffcast
sudo pip install ntfy
}

14
internal_bin/install.deb Executable file
View File

@@ -0,0 +1,14 @@
#!/usr/bin/env bash
# This ensures that the entire script is downloaded before execution
{
sudo apt update
sudo apt upgrade
sudo apt install tmux zsh vim git\
terminator rofi feh xcompmgr\
i3lock-fancy i3blocks
sudo pip install ntfy
}

42
internal_bin/upgrade.sh Executable file
View File

@@ -0,0 +1,42 @@
# Modified from https://github.com/robbyrussell/oh-my-zsh/blob/master/tools/check_for_upgrade.sh
# Original Copyright: (c) 2009-2018 Robby Russell and contributors
# Modified Copyright: (c) 2018 David Todd (c0de)
# License: MIT
# Use colors, but only if connected to a terminal, and that terminal
# supports them.
if which tput >/dev/null 2>&1; then
ncolors=$(tput colors)
fi
if [ -t 1 ] && [ -n "$ncolors" ] && [ "$ncolors" -ge 8 ]; then
RED="$(tput setaf 1)"
GREEN="$(tput setaf 2)"
YELLOW="$(tput setaf 3)"
BLUE="$(tput setaf 4)"
BOLD="$(tput bold)"
NORMAL="$(tput sgr0)"
else
RED=""
GREEN=""
YELLOW=""
BLUE=""
BOLD=""
NORMAL=""
fi
printf "${BLUE}%s${NORMAL}\n" "Updating your dotfiles"
cd "$_DOTFILES"
branch=$(git name-rev --name-only HEAD)
if git pull --rebase --stat origin $branch
then
printf '%s' "$GREEN"
printf '%s\n' ' _____ ______ ______ ______ __ __ ______ ______ '
printf '%s\n' '/\ __-. /\ __ \ /\__ _\ /\ ___\ /\ \ /\ \ /\ ___\ /\ ___\ '
printf '%s\n' '\ \ \/\ \ \ \ \/\ \ \/_/\ \/ \ \ __\ \ \ \ \ \ \____ \ \ __\ \ \___ \ '
printf '%s\n' ' \ \____- \ \_____\ \ \_\ \ \_\ \ \_\ \ \_____\ \ \_____\ \/\_____\ '
printf '%s\n' ' \/____/ \/_____/ \/_/ \/_/ \/_/ \/_____/ \/_____/ \/_____/ '
printf "${BLUE}%s\n" "Hooray! Your dotfiles have been updated and/or is at the current version."
else
printf "${RED}%s${NORMAL}\n" 'There was an error updating. Try again later?'
fi
cd $OLDPWD