diff --git a/.zshrc2 b/.zshrc2 index 80493d4..084eddd 100644 --- a/.zshrc2 +++ b/.zshrc2 @@ -92,3 +92,30 @@ bindkey "^[[1~" beginning-of-line bindkey "^[[4~" end-of-line bindkey "^[OH" beginning-of-line bindkey "^[OF" end-of-line + +# dfs +dfs() +{ + case $1 in + update ) "$DOTFILES/update.sh" ;; + force-update ) ( + cd "$DOTFILES" + git fetch --all + ref=$(git symbolic-ref --short HEAD 2> /dev/null) || ref=$(git rev-parse --short HEAD 2> /dev/null) || return 0 + for b in $(git for-each-ref refs/heads --format='%(refname)') ; do git checkout ${b#refs/heads/} ; git pull --ff-only ; done + git checkout -c advice.detachedHead=false $ref) + ;; + 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" ;; + log ) "$DOTFILES/tools/common.sh" "post_log" "INFO" "dfs" "$2" ;; + * ) echo "unknown command \"$1\". available: update, force-update, version, reset, cd, log" ;; + esac +} diff --git a/scripts/dfs b/scripts/dfs deleted file mode 100755 index 02523ae..0000000 --- a/scripts/dfs +++ /dev/null @@ -1,28 +0,0 @@ -#!/bin/bash - -THIS_DIR=$( cd "$( dirname "${BASH_SOURCE[0]:-${(%):-%x}}" )" && pwd ) -DOTFILES=${DOTFILES:-$( cd "$THIS_DIR/.." && pwd )} -source "$DOTFILES/tools/common.sh" - -case $1 in - update ) "$DOTFILES/update.sh" ;; - force-update ) ( - cd "$DOTFILES" - git fetch --all - ref=$(git symbolic-ref --short HEAD 2> /dev/null) || ref=$(git rev-parse --short HEAD 2> /dev/null) || return 0 - for b in $(git for-each-ref refs/heads --format='%(refname)') ; do git checkout ${b#refs/heads/} ; git pull --ff-only ; done - git checkout -c advice.detachedHead=false $ref) - ;; - 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" ;; - log ) post_log "INFO" "dfs" "$2" ;; - * ) echo "unknown command \"$1\". available: update, force-update, version, reset, cd, log" ;; -esac diff --git a/tools/common.sh b/tools/common.sh old mode 100644 new mode 100755 index 59e87ff..468f24f --- a/tools/common.sh +++ b/tools/common.sh @@ -151,7 +151,7 @@ get_linux_dist() { } if [[ "${BASH_SOURCE[0]}" == "${0}" ]]; then - $1 + $1 "${@:2}" else setup_color fi