restructuring
This commit is contained in:
76
internal_bin/check_for_upgrade.sh
Executable file
76
internal_bin/check_for_upgrade.sh
Executable 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
16
internal_bin/install.arch
Executable 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
14
internal_bin/install.deb
Executable 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
42
internal_bin/upgrade.sh
Executable 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
|
Reference in New Issue
Block a user