mirror of
https://github.com/DictXiong/dotfiles.git
synced 2024-11-24 10:27:00 +08:00
Dev (#6)
* .gitconfig; tools/alpine.sh; mkdir -p when install; restruct ubuntu.sh * spelling * tpm requires make; set-tz; lemonbench * ANTIGEN_EXCLUDE * dfs force-update
This commit is contained in:
parent
d5bf057e65
commit
c8cf824e62
3
.gitconfig2
Normal file
3
.gitconfig2
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
[user]
|
||||||
|
email = me@beardic.cn
|
||||||
|
name = Dict Xiong
|
37
.zshrc2
37
.zshrc2
|
@ -42,19 +42,27 @@ fi
|
||||||
source "$ANTIGEN"
|
source "$ANTIGEN"
|
||||||
antigen use oh-my-zsh
|
antigen use oh-my-zsh
|
||||||
# enable plugins
|
# enable plugins
|
||||||
antigen bundle command-not-found
|
antigen_plugins=( \
|
||||||
antigen bundle docker
|
"command-not-found" \
|
||||||
antigen bundle extract
|
"docker" \
|
||||||
antigen bundle fzf
|
"extract" \
|
||||||
antigen bundle git
|
"fzf" \
|
||||||
antigen bundle ripgrep
|
"git" \
|
||||||
antigen bundle thefuck
|
"ripgrep" \
|
||||||
antigen bundle tmux
|
"thefuck" \
|
||||||
antigen bundle ufw
|
"tmux" \
|
||||||
antigen bundle z
|
"ufw" \
|
||||||
antigen bundle https://gitee.com/dictxiong/zsh-syntax-highlighting
|
"z" \
|
||||||
antigen bundle https://gitee.com/dictxiong/zsh-completions
|
"https://gitee.com/dictxiong/zsh-syntax-highlighting" \
|
||||||
antigen bundle https://gitee.com/dictxiong/zsh-autosuggestions
|
"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
|
||||||
# select theme
|
# select theme
|
||||||
antigen theme ${ZSH_THEME:-ys}
|
antigen theme ${ZSH_THEME:-ys}
|
||||||
# apply
|
# apply
|
||||||
|
@ -67,6 +75,7 @@ dfs()
|
||||||
{
|
{
|
||||||
case $1 in
|
case $1 in
|
||||||
update ) (cd "$DOTFILES" && git pull) ;;
|
update ) (cd "$DOTFILES" && git pull) ;;
|
||||||
|
force-update ) (cd "$DOTFILES" && git fetch --all && git reset --hard origin/main && git pull) ;;
|
||||||
reset )
|
reset )
|
||||||
antigen reset 1> /dev/null
|
antigen reset 1> /dev/null
|
||||||
rm -rf $HOME/.antigen
|
rm -rf $HOME/.antigen
|
||||||
|
@ -76,7 +85,7 @@ dfs()
|
||||||
echo 'Done. Please open a new shell to see the changes.'
|
echo 'Done. Please open a new shell to see the changes.'
|
||||||
;;
|
;;
|
||||||
cd ) cd "$DOTFILES" ;;
|
cd ) cd "$DOTFILES" ;;
|
||||||
* ) echo "unknown command \"$1\". available: update, reset, cd" ;;
|
* ) echo "unknown command \"$1\". available: update, force-update, reset, cd" ;;
|
||||||
esac
|
esac
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -115,6 +115,7 @@ insert_if_not_exist()
|
||||||
filename=$1
|
filename=$1
|
||||||
line=$2
|
line=$2
|
||||||
fmt_note "installing \"$line\" into \"$filename\" ..."
|
fmt_note "installing \"$line\" into \"$filename\" ..."
|
||||||
|
mkdir -p $(dirname "$filename")
|
||||||
if [ ! -f "$filename" ]; then
|
if [ ! -f "$filename" ]; then
|
||||||
touch $filename
|
touch $filename
|
||||||
fi
|
fi
|
||||||
|
@ -140,6 +141,7 @@ create_symlink()
|
||||||
fmt_error "\"$src\" does not exist! aborting this job ..."
|
fmt_error "\"$src\" does not exist! aborting this job ..."
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
|
mkdir -p $(dirname "$dest")
|
||||||
if [ -f "$dest" ]; then
|
if [ -f "$dest" ]; then
|
||||||
if [ "$(readlink $dest)" -ef "$src" ]; then
|
if [ "$(readlink $dest)" -ef "$src" ]; then
|
||||||
return 0
|
return 0
|
||||||
|
@ -188,11 +190,11 @@ install_tmux_tpm(){
|
||||||
if [[ -x $(command -v tmux) && ! -d "$TMUX_TPM" ]]; then
|
if [[ -x $(command -v tmux) && ! -d "$TMUX_TPM" ]]; then
|
||||||
fmt_note "installing tmux tpm ..."
|
fmt_note "installing tmux tpm ..."
|
||||||
git clone https://hub.fastgit.xyz/tmux-plugins/tpm "$TMUX_TPM"
|
git clone https://hub.fastgit.xyz/tmux-plugins/tpm "$TMUX_TPM"
|
||||||
if [[ -x $(command -v g++) && -x $(command -v cmake) ]]; then
|
if [[ -x $(command -v g++) && -x $(command -v cmake) && -x $(command -v make) ]]; then
|
||||||
fmt_note "initializing tmux plugins ..."
|
fmt_note "initializing tmux plugins ..."
|
||||||
~/.tmux/plugins/tpm/bin/install_plugins
|
~/.tmux/plugins/tpm/bin/install_plugins
|
||||||
else
|
else
|
||||||
fmt_warning "pls install g++ and cmake and then init tmux plugins by <prefix + I>"
|
fmt_warning "pls install g++,cmake,make and then init tmux plugins by <prefix + I> or ~/.tmux/plugins/tpm/bin/install_plugins"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
@ -212,6 +214,7 @@ install(){
|
||||||
insert_if_not_exist "${HOME}/.zshrc" "source ${dotfile_home_path}/.zshrc2"
|
insert_if_not_exist "${HOME}/.zshrc" "source ${dotfile_home_path}/.zshrc2"
|
||||||
insert_if_not_exist "${HOME}/.tmux.conf" "source-file ${dotfile_home_path}/.tmux.conf2"
|
insert_if_not_exist "${HOME}/.tmux.conf" "source-file ${dotfile_home_path}/.tmux.conf2"
|
||||||
insert_if_not_exist "${HOME}/.vimrc" "source ${dotfile_home_path}/.vimrc2"
|
insert_if_not_exist "${HOME}/.vimrc" "source ${dotfile_home_path}/.vimrc2"
|
||||||
|
insert_if_not_exist "${HOME}/.gitconfig" "[include] path = \"${dotfile_home_path}/.gitconfig2\""
|
||||||
create_symlink "${dotfile_path}/.ssh/authorized_keys2" "${HOME}/.ssh/authorized_keys2"
|
create_symlink "${dotfile_path}/.ssh/authorized_keys2" "${HOME}/.ssh/authorized_keys2"
|
||||||
# those that won't be uninstalled in the future
|
# those that won't be uninstalled in the future
|
||||||
install_tmux_tpm
|
install_tmux_tpm
|
||||||
|
@ -226,6 +229,7 @@ uninstall(){
|
||||||
delete_if_exist "${HOME}/.zshrc" "source ${dotfile_home_path}/.zshrc2"
|
delete_if_exist "${HOME}/.zshrc" "source ${dotfile_home_path}/.zshrc2"
|
||||||
delete_if_exist "${HOME}/.tmux.conf" "source-file ${dotfile_home_path}/.tmux.conf2"
|
delete_if_exist "${HOME}/.tmux.conf" "source-file ${dotfile_home_path}/.tmux.conf2"
|
||||||
delete_if_exist "${HOME}/.vimrc" "source ${dotfile_home_path}/.vimrc2"
|
delete_if_exist "${HOME}/.vimrc" "source ${dotfile_home_path}/.vimrc2"
|
||||||
|
delete_if_exist "${HOME}/.gitconfig" "[include] path = \"${dotfile_home_path}/.gitconfig2\""
|
||||||
delete_link_if_match "${dotfile_path}/.ssh/authorized_keys2" "${HOME}/.ssh/authorized_keys2"
|
delete_link_if_match "${dotfile_path}/.ssh/authorized_keys2" "${HOME}/.ssh/authorized_keys2"
|
||||||
fmt_note "done uninstalling!"
|
fmt_note "done uninstalling!"
|
||||||
fi
|
fi
|
||||||
|
|
47
tools/alpine.sh
Executable file
47
tools/alpine.sh
Executable file
|
@ -0,0 +1,47 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
if [[ $USER != "root" ]]; then
|
||||||
|
echo "must run as root!"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
set_mirror()
|
||||||
|
{
|
||||||
|
#MIRROR=${1:="mirrors.tuna.tsinghua.edu.cn"}
|
||||||
|
#MIRROR=${MIRROR//\//\\\/}
|
||||||
|
#sed -i 's/(archive|security).ubuntu.com/${MIRROR}/g' /etc/apt/sources.list
|
||||||
|
echo "to-do ..."
|
||||||
|
}
|
||||||
|
|
||||||
|
apk_add()
|
||||||
|
{
|
||||||
|
apk update
|
||||||
|
|
||||||
|
# mass installation
|
||||||
|
apk add zsh git tmux vim curl wget bash python3 htop gcc g++ cmake make fzf perl linux-headers bind-tools iputils man-db
|
||||||
|
#for i in {fzf,ripgrep}; do apk add $i -y; done
|
||||||
|
|
||||||
|
# who am i
|
||||||
|
git config --global user.email "me@beardic.cn"
|
||||||
|
git config --global user.name "Dict Xiong"
|
||||||
|
}
|
||||||
|
|
||||||
|
set_timezone()
|
||||||
|
{
|
||||||
|
apk update
|
||||||
|
apk add tzdata
|
||||||
|
cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
|
||||||
|
echo "Asia/Shanghai" > /etc/timezone
|
||||||
|
}
|
||||||
|
|
||||||
|
router()
|
||||||
|
{
|
||||||
|
case $1 in
|
||||||
|
apk-add ) apk_add ;;
|
||||||
|
set-timezone | set-tz ) set_timezone ;;
|
||||||
|
#set-mirror ) set_mirror $2 ;;
|
||||||
|
* ) echo unknown command "$1". available: apk-add, set-timezone;;
|
||||||
|
esac
|
||||||
|
}
|
||||||
|
|
||||||
|
router $@
|
|
@ -10,6 +10,7 @@ install_commands=(\
|
||||||
[v2ray]="bash <(curl -L https://raw.githubusercontent.com/v2fly/fhs-install-v2ray/master/install-release.sh) #--remove" \
|
[v2ray]="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' \
|
[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' \
|
[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' \
|
||||||
)
|
)
|
||||||
|
|
||||||
install()
|
install()
|
||||||
|
|
|
@ -5,36 +5,43 @@ if [[ $USER != "root" ]]; then
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
init()
|
set_mirror()
|
||||||
|
{
|
||||||
|
MIRROR=${1:-"mirrors.tuna.tsinghua.edu.cn"}
|
||||||
|
MIRROR=${MIRROR//\//\\\/}
|
||||||
|
sed -i 's/(archive|security).ubuntu.com/${MIRROR}/g' /etc/apt/sources.list
|
||||||
|
}
|
||||||
|
|
||||||
|
apt_install()
|
||||||
{
|
{
|
||||||
# basic packages
|
# basic packages
|
||||||
apt update
|
apt update
|
||||||
for i in {man-db,vim,ca-certificates}; do apt install $i -y; done
|
for i in {man-db,vim,ca-certificates}; do apt install $i -y; done
|
||||||
|
|
||||||
# apt source
|
|
||||||
${MIRROR:="mirrors.tuna.tsinghua.edu.cn"}
|
|
||||||
MIRROR=${MIRROR//\//\\\/}
|
|
||||||
sed -i 's/(archive|security).ubuntu.com/${MIRROR}/g' /etc/apt/sources.list
|
|
||||||
|
|
||||||
# mass installation
|
# mass installation
|
||||||
apt update
|
apt update
|
||||||
apt install git tmux zsh curl wget dialog net-tools dnsutils netcat traceroute sudo python3 python3-pip cron inetutils-ping openssh-client openssh-server htop gcc g++ cmake
|
apt install git tmux zsh curl wget dialog net-tools dnsutils netcat traceroute sudo python3 python3-pip cron inetutils-ping openssh-client openssh-server htop gcc g++ cmake make
|
||||||
for i in {fzf,ripgrep}; do apt install $i -y; done
|
for i in {fzf,ripgrep}; do apt install $i -y; done
|
||||||
|
|
||||||
# custom dotfiles (usually not needed)
|
|
||||||
mkdir -p ~/.ssh
|
|
||||||
# cd ~ && git clone https://gitee.com/dictxiong/dotfiles && ./dotfiles/install.sh
|
|
||||||
|
|
||||||
# who am i
|
# who am i
|
||||||
git config --global user.email "me@beardic.cn"
|
git config --global user.email "me@beardic.cn"
|
||||||
git config --global user.name "Dict Xiong"
|
git config --global user.name "Dict Xiong"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
set_timezone()
|
||||||
|
{
|
||||||
|
TIMEZONE=${1:-"Asia/Shanghai"}
|
||||||
|
timedatectl set-timezone "$TIMEZONE"
|
||||||
|
}
|
||||||
|
|
||||||
router()
|
router()
|
||||||
{
|
{
|
||||||
case $1 in
|
case $1 in
|
||||||
init ) init ;;
|
apt-install ) apt_install ;;
|
||||||
* ) echo unknown command "$1". available: init ;;
|
set-mirror ) set_mirror $2 ;;
|
||||||
|
set-timezone\
|
||||||
|
| set-tz ) set_timezone $2 ;;
|
||||||
|
* ) echo unknown command "$1". available: apt-install, set-mirror, set-timezone;;
|
||||||
esac
|
esac
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user