From 2fb1cd65995ecd4ff33a7883501ec9531687603e Mon Sep 17 00:00:00 2001 From: Dict Xiong Date: Fri, 29 Jul 2022 01:01:00 +0800 Subject: [PATCH] add unknown command "version". available: update, force-update, reset, cd and replace tabs with spaces --- .zshrc2 | 73 +++++++++++++++++++++++++++++---------------------------- 1 file changed, 37 insertions(+), 36 deletions(-) diff --git a/.zshrc2 b/.zshrc2 index eca7bae..4b405e6 100644 --- a/.zshrc2 +++ b/.zshrc2 @@ -20,23 +20,23 @@ ANTIGEN_URL="https://gitee.com/dictxiong/antigen/raw/develop/bin/antigen.zsh" ANTIGEN="$HOME/antigen.zsh" # Install antigen.zsh if not exist if [ ! -f "$ANTIGEN" ]; then - echo "Installing antigen ..." - TMPFILE="/tmp/antigen.zsh" - if [ -x "$(which curl)" ]; then - curl -L "$ANTIGEN_URL" -o "$TMPFILE" - elif [ -x "$(which wget)" ]; then - wget "$ANTIGEN_URL" -O "$TMPFILE" - else - echo "ERROR: please install curl or wget before installation !!" - exit - fi - if [ ! $? -eq 0 ]; then - echo "" - echo "ERROR: downloading antigen.zsh ($ANTIGEN_URL) failed !!" - exit - fi; - echo "move $TMPFILE to $ANTIGEN" - mv "$TMPFILE" "$ANTIGEN" + echo "Installing antigen ..." + TMPFILE="/tmp/antigen.zsh" + if [ -x "$(which curl)" ]; then + curl -L "$ANTIGEN_URL" -o "$TMPFILE" + elif [ -x "$(which wget)" ]; then + wget "$ANTIGEN_URL" -O "$TMPFILE" + else + echo "ERROR: please install curl or wget before installation !!" + exit + fi + if [ ! $? -eq 0 ]; then + echo "" + echo "ERROR: downloading antigen.zsh ($ANTIGEN_URL) failed !!" + exit + fi; + echo "move $TMPFILE to $ANTIGEN" + mv "$TMPFILE" "$ANTIGEN" fi # config and enable antigen source "$ANTIGEN" @@ -79,29 +79,30 @@ fi dfs() { - case $1 in - update ) $DOTFILES/update.sh ;; - force-update ) (cd "$DOTFILES" && git fetch --all && git reset --hard origin/main && git pull) ;; - reset ) - antigen reset 1> /dev/null - rm -rf $HOME/.antigen - $DOTFILES/install.sh -r - dfs update - $DOTFILES/install.sh -i - echo 'Done. Please open a new shell to see the changes.' - ;; - cd ) cd "$DOTFILES" ;; - * ) echo "unknown command \"$1\". available: update, force-update, reset, cd" ;; - esac + case $1 in + update ) $DOTFILES/update.sh ;; + force-update ) (cd "$DOTFILES" && git fetch --all && git reset --hard origin/main && git pull) ;; + version ) (cd "$DOTFILES" && git rev-parse HEAD) ;; + reset ) + antigen reset 1> /dev/null + rm -rf $HOME/.antigen + $DOTFILES/install.sh -r + dfs update + $DOTFILES/install.sh -i + echo 'Done. Please open a new shell to see the changes.' + ;; + cd ) cd "$DOTFILES" ;; + * ) echo "unknown command \"$1\". available: update, force-update, reset, cd" ;; + esac } dogo() { - if [[ -z "$1" || "$1" =~ "-h|--help" ]]; then - echo "usage: dogo " - else - $SUDO docker exec -it $1 zsh - fi + if [[ -z "$1" || "$1" =~ "-h|--help" ]]; then + echo "usage: dogo " + else + $SUDO docker exec -it $1 zsh + fi } # alias