This commit is contained in:
Dict Xiong 2022-08-26 20:30:22 +08:00
parent a68a9af330
commit 8be06f7d97
3 changed files with 28 additions and 29 deletions

27
.zshrc2
View File

@ -92,3 +92,30 @@ bindkey "^[[1~" beginning-of-line
bindkey "^[[4~" end-of-line bindkey "^[[4~" end-of-line
bindkey "^[OH" beginning-of-line bindkey "^[OH" beginning-of-line
bindkey "^[OF" end-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
}

View File

@ -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

2
tools/common.sh Normal file → Executable file
View File

@ -151,7 +151,7 @@ get_linux_dist() {
} }
if [[ "${BASH_SOURCE[0]}" == "${0}" ]]; then if [[ "${BASH_SOURCE[0]}" == "${0}" ]]; then
$1 $1 "${@:2}"
else else
setup_color setup_color
fi fi