diff --git a/dot_local/scripts/zsh/aliases.zsh b/dot_local/scripts/zsh/aliases.zsh index cadc876..2d6a867 100644 --- a/dot_local/scripts/zsh/aliases.zsh +++ b/dot_local/scripts/zsh/aliases.zsh @@ -3,5 +3,25 @@ alias rm="garbage put" alias cm="chezmoi" alias kill-gpg-agent="gpgconf --kill gpg-agent" -ced() { chezmoi edit $1 && chezmoi -v apply } +function ced() { + # if the file doesn't exist, prompt to make a new one + if [ ! -f "$1" ]; then + read "?$1 doesn't exist.. create file? [yN] " yn + case $yn in + [Yy]* ) + echo "creating new file" + install -D /dev/null $1 + echo "\n" > $1 + chezmoi add $1;; + * ) + echo "nah" + return;; + esac + fi + + chezmoi edit $1 + echo "applying changes..." + chezmoi apply +} + cpush() { chezmoi git add . -- -A && chezmoi git commit -- -m "update" && chezmoi git push } diff --git a/dot_local/scripts/zsh/executable_check-update.zsh b/dot_local/scripts/zsh/executable_check-update.zsh new file mode 100644 index 0000000..ae3cc9d --- /dev/null +++ b/dot_local/scripts/zsh/executable_check-update.zsh @@ -0,0 +1,21 @@ +function checkUpdate() { + lastUpdateFile=$HOME/.config/last-system-update + + if [ ! -f "$lastUpdateFile" ]; then + echo "this system hasn't ever been updated using system-upgrade.sh" + echo "run system-upgrade.sh now" + return + fi + + lastUpdate=$(cat $lastUpdateFile) + now=$(date "+%s") + + if [ $(( $now - $lastUpdate > 604800 )) ]; then + echo "this system hasn't been updated for over a week" + echo "run system-upgrade.sh asap" + return + fi +} + +checkUpdate + diff --git a/dot_zshrc b/dot_zshrc index 119a86b..e2518e8 100644 --- a/dot_zshrc +++ b/dot_zshrc @@ -1,4 +1,5 @@ source $HOME/.local/scripts/zsh/zsh-prelude.zsh +source $HOME/.local/scripts/zsh/check-update.zsh export LANG=en_US.UTF-8 export ZSH="/home/michael/.oh-my-zsh"