Skip to content

Commit

Permalink
[dev] dfs config; trash (#30)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
DictXiong authored Nov 24, 2022
1 parent f39193f commit 56e2b21
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 25 deletions.
5 changes: 4 additions & 1 deletion .gitconfig2
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand All @@ -14,4 +15,6 @@
[help]
autocorrect = 1
[init]
defaultBranch = main
defaultBranch = main
[log]
date = iso
1 change: 1 addition & 0 deletions .update.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
48 changes: 28 additions & 20 deletions .zshrc2
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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="[email protected]:36022" dictxiong@$1 }
Expand Down Expand Up @@ -142,15 +145,21 @@ 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
ref=$(git symbolic-ref --short HEAD 2> /dev/null) || ref=$(git rev-parse --short HEAD 2> /dev/null) || return 0
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
Expand All @@ -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
Expand Down
8 changes: 5 additions & 3 deletions install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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[@]}"
Expand Down Expand Up @@ -233,6 +233,7 @@ uninstall_update(){

install(){
install_update
if [[ "$INSTALL_DEP" == "1" ]]; then install_dependencies; fi
preinstall_check
install_crontab
install_file_content
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion tools/install.sh → tools/to-install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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' \
Expand Down

0 comments on commit 56e2b21

Please sign in to comment.