From 952bfabea4ecec4bdd6371e7f01b56dcddffed23 Mon Sep 17 00:00:00 2001 From: Dict Xiong Date: Sat, 10 Dec 2022 19:11:05 +0800 Subject: [PATCH] zshrc: fix locale (#34) * common.sh: export vars in env; zshrc: gdebug * fix error when locale not exists * fix ci Co-authored-by: xiongdian.me --- .zshrc2 | 3 ++- install.sh | 7 ++++++- tools/common.sh | 4 ++-- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/.zshrc2 b/.zshrc2 index 66b879d..5493eff 100644 --- a/.zshrc2 +++ b/.zshrc2 @@ -1,6 +1,6 @@ # env for shell export TERM="xterm-256color" -if ( locale -a | grep -qxE "C.UTF-8|C.utf8" ); then +if (command -v locale >/dev/null) && ( locale -a | grep -qxE "C.UTF-8|C.utf8" ); then export LC_ALL=C.UTF-8 export LANG=C.UTF-8 else @@ -100,6 +100,7 @@ alias "se"='sudo -sE' alias "pbd"='ping baidu.com' alias "p114"='ping 114.114.114.114' alias "p666"='ping6 2001:da8::666' +alias "gdebug"='git add -A; git commit -m "bug fix"' case $(bash "$DOTFILES/tools/common.sh" get_os_type) in macos ) alias l='ls -lAGh -D "%y-%m-%d %H:%M"' ;; * ) alias l='ls -lAGh --time-style="+%y-%m-%d %H:%M"' ;; diff --git a/install.sh b/install.sh index 9297baa..e117f80 100755 --- a/install.sh +++ b/install.sh @@ -206,11 +206,16 @@ install_update() cp "${DOTFILES}/.update.sh" "${DOTFILES}/update.sh" chmod +x "${DOTFILES}/update.sh" fmt_note "running update.sh ..." + set +e DFS_UPDATED_RET=85 ${DOTFILES}/update.sh - if [[ $? == 85 ]]; then + RET=$? + if [[ $RET == 85 ]]; then fmt_note "dfs updated. re-running install.sh ..." "${DOTFILES}/install.sh" "$ORIGIN_ARGS" && exit + elif [[ $RET != 0 ]]; then + fmt_fatal "update.sh failed with exit code $RET" fi + set -e } uninstall_update() diff --git a/tools/common.sh b/tools/common.sh index 87fcdfa..2e38c85 100755 --- a/tools/common.sh +++ b/tools/common.sh @@ -1,8 +1,8 @@ #!/bin/bash - +set -e THIS_DIR_COMMON_SH=$( cd "$( dirname "${BASH_SOURCE[0]:-${(%):-%x}}" )" && pwd ) export DOTFILES=$( cd "$THIS_DIR_COMMON_SH/.." && pwd ) -if [[ -f ~/.config/dotfiles/env ]]; then source ~/.config/dotfiles/env; fi +if [[ -f ~/.config/dotfiles/env ]]; then set -a; source ~/.config/dotfiles/env; set +a; fi # Color settings # Source: https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh