2022-05-07 16:19:39 +08:00
|
|
|
export TERM="xterm-256color"
|
|
|
|
export LC_ALL=C.UTF-8
|
|
|
|
export LANG=C.UTF-8
|
|
|
|
|
|
|
|
# antigen
|
|
|
|
|
|
|
|
# if test -z "$NO_WALL"; then
|
|
|
|
# ANTIGEN_OMZ_REPO_URL="https://mirrors.tuna.tsinghua.edu.cn/git/ohmyzsh.git"
|
|
|
|
# ANTIGEN_URL="https://raw.fastgit.org/zsh-users/antigen/master/bin/antigen.zsh"
|
|
|
|
# GIHUB_PROXY="https://hub.fastgit.xyz/"
|
|
|
|
# else
|
|
|
|
# ANTIGEN_URL="git.io/antigen"
|
|
|
|
# GIHUB_PROXY=""
|
|
|
|
# fi
|
|
|
|
# antigen bundle ${GIHUB_PROXY}zsh-users/zsh-syntax-highlighting
|
|
|
|
# antigen bundle ${GIHUB_PROXY}zsh-users/zsh-completions
|
|
|
|
# antigen bundle ${GIHUB_PROXY}zsh-users/zsh-autosuggestions
|
2022-05-11 11:46:21 +08:00
|
|
|
ANTIGEN_OMZ_REPO_URL="https://gitee.com/dictxiong/ohmyzsh.git"
|
2022-05-11 16:57:31 +08:00
|
|
|
ANTIGEN_URL="https://gitee.com/dictxiong/antigen/raw/develop/bin/antigen.zsh"
|
2022-05-07 16:19:39 +08:00
|
|
|
ANTIGEN="$HOME/antigen.zsh"
|
|
|
|
# Install antigen.zsh if not exist
|
|
|
|
if [ ! -f "$ANTIGEN" ]; then
|
2022-08-14 20:34:18 +08:00
|
|
|
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"
|
2022-05-07 16:19:39 +08:00
|
|
|
fi
|
|
|
|
# config and enable antigen
|
|
|
|
source "$ANTIGEN"
|
|
|
|
antigen use oh-my-zsh
|
|
|
|
# enable plugins
|
2022-05-22 00:53:55 +08:00
|
|
|
antigen_plugins=( \
|
|
|
|
"command-not-found" \
|
|
|
|
"docker" \
|
|
|
|
"extract" \
|
|
|
|
"fzf" \
|
|
|
|
"git" \
|
|
|
|
"ripgrep" \
|
|
|
|
"tmux" \
|
|
|
|
"ufw" \
|
|
|
|
"z" \
|
|
|
|
"https://gitee.com/dictxiong/zsh-syntax-highlighting" \
|
|
|
|
"https://gitee.com/dictxiong/zsh-completions" \
|
|
|
|
"https://gitee.com/dictxiong/zsh-autosuggestions" \
|
|
|
|
)
|
|
|
|
for i in ${antigen_plugins[*]}
|
|
|
|
do
|
|
|
|
if [[ -z $ANTIGEN_EXCLUDE || ! $i =~ $ANTIGEN_EXCLUDE ]]; then
|
|
|
|
antigen bundle $i
|
|
|
|
fi
|
|
|
|
done
|
2022-05-07 16:19:39 +08:00
|
|
|
# select theme
|
2022-05-17 18:22:43 +08:00
|
|
|
antigen theme ${ZSH_THEME:-ys}
|
2022-05-07 16:19:39 +08:00
|
|
|
# apply
|
|
|
|
antigen apply
|
2022-05-14 20:26:25 +08:00
|
|
|
# end of antigen config
|
|
|
|
|
2022-08-26 20:43:00 +08:00
|
|
|
# env
|
2022-05-14 20:26:25 +08:00
|
|
|
export DOTFILES=$( cd "$( dirname "${BASH_SOURCE[0]:-${(%):-%x}}" )" && pwd )
|
2022-08-26 20:43:00 +08:00
|
|
|
export PATH=$PATH:$DOTFILES/scripts
|
2022-06-02 16:03:36 +08:00
|
|
|
|
2022-08-26 20:43:00 +08:00
|
|
|
# alias
|
|
|
|
alias "pls"='sudo $(fc -ln -1)'
|
|
|
|
alias "se"='sudo -sE'
|
|
|
|
alias "pbd"='ping baidu.com'
|
|
|
|
alias "p114"='ping 114.114.114.114'
|
|
|
|
alias "p666"='ping6 2001:da8::666'
|
|
|
|
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
|
2022-08-25 00:23:29 +08:00
|
|
|
|
2022-08-26 20:43:00 +08:00
|
|
|
# key bindings
|
|
|
|
bindkey "^b" beginning-of-line
|
|
|
|
bindkey "^e" end-of-line
|
|
|
|
bindkey "^[[H" beginning-of-line
|
|
|
|
bindkey "^[[F" end-of-line
|
|
|
|
bindkey "^[[1~" beginning-of-line
|
|
|
|
bindkey "^[[4~" end-of-line
|
|
|
|
bindkey "^[OH" beginning-of-line
|
|
|
|
bindkey "^[OF" end-of-line
|
2022-08-25 00:23:29 +08:00
|
|
|
|
2022-08-26 20:43:00 +08:00
|
|
|
# dfs
|
2022-05-14 20:26:25 +08:00
|
|
|
dfs()
|
|
|
|
{
|
2022-08-14 20:34:18 +08:00
|
|
|
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" ;;
|
2022-08-26 20:43:00 +08:00
|
|
|
log ) "$DOTFILES/tools/common.sh" "post_log" "INFO" "dfs" "$2" ;;
|
2022-08-14 20:34:18 +08:00
|
|
|
* ) echo "unknown command \"$1\". available: update, force-update, version, reset, cd, log" ;;
|
|
|
|
esac
|
2022-05-14 20:26:25 +08:00
|
|
|
}
|