mirror of
https://git.decapod.one/brethil/dotfiles
synced 2024-11-21 19:11:30 +01:00
zsh: make update mechanism less annoying
move .zsh file to extras/ so that it doesn't get sourced twice because of the ZSH_CUSTOM bug
This commit is contained in:
parent
b50a9dec24
commit
3df7a304c4
|
@ -1,9 +1,6 @@
|
|||
# vim:ft=zsh ts=2 sw=2 sts=2
|
||||
export LANG=en_US.UTF-8
|
||||
|
||||
# Set DISABLE_DOTFILES_AUTOUPDATE=true to disable updates
|
||||
source "${DOTFILES}/check_for_update.zsh"
|
||||
|
||||
# theme-related variables
|
||||
export ZSH_CUSTOM="$DOTFILES"
|
||||
export ZSH_THEME="brethil"
|
||||
|
@ -127,3 +124,7 @@ test -f "${ssh_file}" && source "${ssh_file}"
|
|||
export PATH=$PATH:$HOME/bin
|
||||
|
||||
autoload -U compinit && compinit
|
||||
autoload -U bashcompinit && bashcompinit
|
||||
|
||||
# Set DISABLE_DOTFILES_AUTOUPDATE=true to disable updates
|
||||
source "${DOTFILES}/extras/check_for_update.zsh"
|
||||
|
|
|
@ -42,8 +42,6 @@ function update_dotfiles() {
|
|||
return;
|
||||
fi
|
||||
|
||||
emulate -L zsh
|
||||
|
||||
local epoch_target mtime option LAST_EPOCH
|
||||
|
||||
# Remove lock directory if older than a day
|
||||
|
@ -65,8 +63,9 @@ function update_dotfiles() {
|
|||
# assumed to have been handled, and execution continues normally. Otherwise, the shell
|
||||
# will behave as interrupted except that the return status of the trap is retained.
|
||||
trap "
|
||||
unset -f current_epoch _update_dotfiles_update update_dotfiles
|
||||
command rm -rf '$DOTFILES/update.lock'
|
||||
unset -f current_epoch _update_dotfiles_update update_dotfiles &>/dev/null
|
||||
command rmdir '$DOTFILES/update.lock' &>/dev/null
|
||||
echo
|
||||
return 1
|
||||
" EXIT INT QUIT
|
||||
|
||||
|
@ -87,17 +86,13 @@ function update_dotfiles() {
|
|||
if [[ "$DISABLE_UPDATE_PROMPT" = true ]]; then
|
||||
update_dotfiles
|
||||
else
|
||||
# input sink to swallow all characters typed before the prompt
|
||||
# and add a newline if there wasn't one after characters typed
|
||||
while read -t -k 1 option; do true; done
|
||||
[[ "$option" != ($'\n'|"") ]] && echo
|
||||
|
||||
echo -n "[brethil-dotfiles] Would you like to update? [Y/n] "
|
||||
read -r -k 1 option
|
||||
[[ "$option" != $'\n' ]] && echo
|
||||
case "$option" in
|
||||
[yY$'\n']) update_dotfiles ;;
|
||||
[nN]) _update_dotfiles_update ;;
|
||||
*) echo -n "[brethil dotfiles] Skipping. Update using \`dotfiles_selfupdate\`" && echo ;;
|
||||
esac
|
||||
fi
|
||||
}
|
||||
unset -f current_epoch update_dotfiles _update_dotfiles_update
|
Loading…
Reference in New Issue
Block a user