diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..416cfaa --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +*.zwc diff --git a/.tmux.conf2 b/.tmux.conf2 new file mode 100644 index 0000000..d78fc6d --- /dev/null +++ b/.tmux.conf2 @@ -0,0 +1,48 @@ +set -g prefix ^a +set -g default-terminal "xterm-256color" + +# plugins +set -g @plugin 'https://hub.fastgit.xyz/thewtex/tmux-mem-cpu-load' +set -g @plugin 'https://hub.fastgit.xyz/tmux-plugins/tmux-resurrect' +run '~/.tmux/plugins/tpm/tpm' + +# Use Alt-arrow keys to switch panes +bind -n M-Left select-pane -L +bind -n M-Right select-pane -R +bind -n M-Up select-pane -U +bind -n M-Down select-pane -D + +# Shift arrow to switch windows +bind -n S-Left previous-window +bind -n S-Right next-window + +# '-' and '|' to split +bind - split-window -v -c "#{pane_current_path}" +bind | split-window -h -c "#{pane_current_path}" + +# other key bindings +bind r source-file ~/.tmux.conf \; display-message "tmux.conf reloaded" +bind m run 'old=$(tmux show -gv mouse); new="off"; if [ "$old" = "off" ]; then new="on"; fi; tmux set -g mouse $new && tmux display-message toggle\ mouse\ mode\ $new' + +# styles +# status bar +set -g monitor-activity on +set -g bell-action any +set -g status-position top +set -g status-style fg=white,bg=colour241 +set -g status-interval 1 +set -g status-justify centre +set -g status-left-length 23 +set -g status-left "#[fg=#f9f1a5]#(whoami)#[default]@#(hostname | sed 's/-ibd-ink//g')[#S]" +set -g status-right-length 60 +set -g status-right "#[default]#(~/.tmux/plugins/tmux-mem-cpu-load/tmux-mem-cpu-load --averages-count 1 --interval 2)#[default] " +set -ag status-right "#[default]#(uptime | cut -f 4-5 -d ' ' | cut -f 1 -d ',' | sed 's/ //g')" +set -ag status-right " #[fg=white,bg=default]%H:%M:%S" +set -g window-status-style fg=colour248 +set -g window-status-current-style fg=#f9f1a5,bg=colour237 +set -g window-status-activity-style fg=colour237,bg=colour248 +set -g window-status-bell-style fg=colour237,bg=colour214 +# panes and windows +set -g pane-active-border-style fg=brightblue +set -g window-style fg=colour248 +set -g window-active-style fg=white \ No newline at end of file diff --git a/.zshrc2 b/.zshrc2 index 1c60625..cf9da01 100644 --- a/.zshrc2 +++ b/.zshrc2 @@ -61,6 +61,15 @@ antigen theme ${ZSH_THEME:-ys} antigen apply # end of antigen config +# install tmux tpm +TMUX_TPM="$HOME/.tmux/plugins/tpm" +command -v tmux > /dev/null 2>&1 +if [[ $? == 0 && ! -d "$TMUX_TPM" ]]; then + git clone https://hub.fastgit.xyz/tmux-plugins/tpm "$TMUX_TPM" +fi +# end of tpm + + # functions export DOTFILES=$( cd "$( dirname "${BASH_SOURCE[0]:-${(%):-%x}}" )" && pwd ) dfs() @@ -82,4 +91,17 @@ dfs() # alias alias "pls"='sudo $(fc -ln -1)' -alias "se"='sudo -sE' \ No newline at end of file +alias "se"='sudo -sE' +alias "pbd"='ping baidu.com' +alias "p114"='ping 114.114.114.114' +alias "p666"='ping6 2001:da8::666' + +# 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 diff --git a/install.sh b/install.sh index 2b3ec43..c64457d 100755 --- a/install.sh +++ b/install.sh @@ -187,6 +187,7 @@ uninstall_crontab(){ install(){ install_crontab 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" create_symlink "${dotfile_path}/.ssh/authorized_keys2" "${HOME}/.ssh/authorized_keys2" fmt_note "done installing!" } @@ -196,6 +197,7 @@ uninstall(){ if [[ $? == 1 ]]; then uninstall_crontab delete_if_exist "${HOME}/.zshrc" "source ${dotfile_home_path}/.zshrc2" + delete_if_exist "${HOME}/.tmux.conf" "source-file ${dotfile_home_path}/.tmux.conf2" delete_link_if_match "${dotfile_path}/.ssh/authorized_keys2" "${HOME}/.ssh/authorized_keys2" fmt_note "done uninstalling!" fi diff --git a/tools/install.sh b/tools/install.sh new file mode 100755 index 0000000..8e43bb0 --- /dev/null +++ b/tools/install.sh @@ -0,0 +1,20 @@ +#!/bin/bash + +declare -A install_commands +install_commands=(\ + [git]="apt update && apt install git" \ + [fzf]="git clone --depth 1 https://github.com/junegunn/fzf.git ~/.fzf && ~/.fzf/install" \ + [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" \ + [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' \ +) + +install() +{ + echo -e ${install_commands[$1]} +} + +install $1 diff --git a/tools/ubuntu.sh b/tools/ubuntu.sh new file mode 100755 index 0000000..0f8e0f6 --- /dev/null +++ b/tools/ubuntu.sh @@ -0,0 +1,41 @@ +#!/bin/bash + +if [[ $USER != "root" ]]; then + echo "must run as root!" + exit 1 +fi + +init() +{ + # basic packages + apt update + 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 + 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 + 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 + git config --global user.email "me@beardic.cn" + git config --global user.name "Dict Xiong" +} + +router() +{ + case $1 in + init ) init ;; + * ) echo unknown command "$1". available: init ;; + esac +} + +router $@