[dev] dfs config; trash (#30)

* install.sh: fix install dep

* update.sh: alternative channel 'dev'

* zshrc: dfs config

* lint: remove endline \

* if trash, disable rm

* update.sh: fallback to main if dev not exists

* bug fix

* to-install.sh; v2ray -> v2fly

* gitconfig: quotepath=false

* git log using iso date; dfs vversion
This commit is contained in:
Dict Xiong 2022-11-24 20:51:35 +08:00 committed by GitHub
parent f39193f28f
commit 56e2b217eb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 39 additions and 25 deletions

View File

@ -6,6 +6,7 @@
# test this by `git update-index --test-untracked-cache`
# disable this by setting `GIT_DISABLE_UNTRACKED_CACHE`
untrackedCache = true
quotepath = false # chinese chars
[push]
autoSetupRemote = true
[branch]
@ -15,3 +16,5 @@
autocorrect = 1
[init]
defaultBranch = main
[log]
date = iso

View File

@ -19,6 +19,7 @@ fi
# get the specified commit id
case $DFS_UPDATE_CHANNEL in
"main" ) DFS_COMMIT=$(curl -fsSL https://api.beardic.cn/get-var/dfs-commit-id) ;;
"dev" ) DFS_COMMIT=$(git rev-parse origin/dev 2> /dev/null) || DFS_COMMIT=$(git rev-parse origin/main) ;;
"latest" ) DFS_COMMIT=$(git for-each-ref --sort=-committerdate refs/heads refs/remotes --format='%(objectname)' | head -n 1) ;;
* ) fmt_fatal "invalid update channel: $DFS_UPDATE_CHANNEL" ;;
esac

48
.zshrc2
View File

@ -14,18 +14,18 @@ export LESS_TERMCAP_md=$'\E[01;33m'
if [[ -z "$DFS_NO_WALL" ]]; then
ANTIGEN_URL="https://gitee.com/dictxiong/antigen/raw/develop/bin/antigen.zsh"
ANTIGEN_OMZ_REPO_URL="https://gitee.com/dictxiong/ohmyzsh.git"
ANTIGEN_PLUGINS=( \
"https://gitee.com/dictxiong/zsh-syntax-highlighting" \
"https://gitee.com/dictxiong/zsh-completions" \
"https://gitee.com/dictxiong/zsh-autosuggestions" \
ANTIGEN_PLUGINS=(
"https://gitee.com/dictxiong/zsh-syntax-highlighting"
"https://gitee.com/dictxiong/zsh-completions"
"https://gitee.com/dictxiong/zsh-autosuggestions"
)
else
ANTIGEN_URL="https://raw.githubusercontent.com/zsh-users/antigen/develop/bin/antigen.zsh"
ANTIGEN_OMZ_REPO_URL="https://github.com/ohmyzsh/ohmyzsh.git"
ANTIGEN_PLUGINS=( \
"https://github.com/zsh-users/zsh-syntax-highlighting" \
"https://github.com/zsh-users/zsh-completions" \
"https://github.com/zsh-users/zsh-autosuggestions" \
ANTIGEN_PLUGINS=(
"https://github.com/zsh-users/zsh-syntax-highlighting"
"https://github.com/zsh-users/zsh-completions"
"https://github.com/zsh-users/zsh-autosuggestions"
)
fi
ANTIGEN="$HOME/antigen.zsh"
@ -53,16 +53,16 @@ fi
source "$ANTIGEN"
# enable plugins
antigen use oh-my-zsh
ANTIGEN_PLUGINS+=( \
"command-not-found" \
"docker" \
"extract" \
"fzf" \
"git" \
"ripgrep" \
"tmux" \
"ufw" \
"z" \
ANTIGEN_PLUGINS+=(
"command-not-found"
"docker"
"extract"
"fzf"
"git"
"ripgrep"
"tmux"
"ufw"
"z"
)
for i in ${ANTIGEN_PLUGINS[*]}; do
if [[ -z $ANTIGEN_EXCLUDE || ! $i =~ $ANTIGEN_EXCLUDE ]]; then
@ -92,6 +92,9 @@ 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"' ;;
esac
if [[ -x $(command -v trash) ]]; then
alias "rm"="echo use the full path i.e. '/bin/rm'\; consider using trash"
fi
sibd() { ssh -p 12022 root@$1${1:+.}ibd.ink }
sob() { ssh -p 24022 root@$1${1:+.}ob.ac.cn }
snasp() { ssh -o ProxyJump="ssh@nasp.ob.ac.cn:36022" dictxiong@$1 }
@ -142,7 +145,14 @@ bindkey "\ed" delete-char # alt+d
dfs()
{
case $1 in
cd ) cd "$DOTFILES" ;;
update ) "$DOTFILES/update.sh" ;;
version ) (cd "$DOTFILES" && git rev-parse HEAD) ;;
vversion ) (cd "$DOTFILES" && git show) ;;
config )
mkdir -p ~/.config/dotfiles
$EDITOR ~/.config/dotfiles/env
;;
force-update ) (
cd "$DOTFILES"
git fetch --all
@ -150,7 +160,6 @@ dfs()
for i in $(git for-each-ref refs/heads --format='%(refname)') ; do git checkout ${i#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
@ -159,7 +168,6 @@ dfs()
"$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

@ -67,8 +67,8 @@ install_dependencies()
preinstall_check()
{
fmt_note "checking requirements ..."
mandatory_commands=( "git" "zsh" "curl" "ping" )
optional_commands=( "python3" "vim" "tmux" )
local mandatory_commands=( "git" "zsh" "curl" )
local optional_commands=( "python3" "vim" "tmux" "ping" )
for i in "${mandatory_commands[@]}"; do
if [[ ! -x "$(command -v $i)" ]]; then
fmt_info "all this utils are required: ${mandatory_commands[@]}"
@ -233,6 +233,7 @@ uninstall_update(){
install(){
install_update
if [[ "$INSTALL_DEP" == "1" ]]; then install_dependencies; fi
preinstall_check
install_crontab
install_file_content
@ -258,13 +259,14 @@ uninstall(){
parse_arg "$@"
FUNC=install
INSTALL_DEP=0
for i in ${PARSE_ARG_RET[@]}; do
case $i in
-i ) FUNC=install ;;
-r ) FUNC=uninstall ;;
-d|--dev ) export DFS_DEV=1 ;;
-l|--lite ) export DFS_LITE=1 ;;
-a|--auto ) install_dependencies ;;
-a|--auto ) INSTALL_DEP=1 ;;
* ) fmt_fatal "unknown option \"$i\". available: -i, -r, -q, -d, -l, -a" ;;
esac
done

View File

@ -7,7 +7,7 @@ INSTALL_COMMANDS=(\
[acme.sh]="curl https://get.acme.sh | sh -s email=${EMAIL:-me@beardic.cn}" \
[oh-my-zsh]='sh -c "$(curl -fsSL https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"' \
[oh-my-tuna]='wget https://tuna.moe/oh-my-tuna/oh-my-tuna.py && sudo python oh-my-tuna.py --global' \
[v2ray]="bash <(curl -L https://raw.githubusercontent.com/v2fly/fhs-install-v2ray/master/install-release.sh) #--remove" \
[v2fly]="bash <(curl -L https://raw.githubusercontent.com/v2fly/fhs-install-v2ray/master/install-release.sh) #--remove" \
[zerotier-one]='curl -s https://install.zerotier.com | sudo bash' \
[docker-ce]='curl -fsSL https://get.docker.com -o get-docker.sh && sudo sh get-docker.sh #--mirror Aliyun #--dry-run' \
[lemonbench]='curl -fsSL https://ilemonra.in/LemonBenchIntl | bash -s fast # or full' \