* init tools tools/ubuntu.sh

* init tools/install.sh and adding ssh to tools/ubuntu.sh

* more in tools/install.sh; .tmux.conf

* ping alias

* tmux customization; tpm auto install; zsh key binding for HOME and END; .gitignore .zwc

* ubuntu.sh: gcc g++ cmake
This commit is contained in:
Dict Xiong 2022-05-20 17:34:21 +08:00 committed by GitHub
parent 80057e06e9
commit ada575bb9b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 135 additions and 1 deletions

1
.gitignore vendored Normal file
View File

@ -0,0 +1 @@
*.zwc

48
.tmux.conf2 Normal file
View File

@ -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

24
.zshrc2
View File

@ -61,6 +61,15 @@ antigen theme ${ZSH_THEME:-ys}
antigen apply antigen apply
# end of antigen config # 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 # functions
export DOTFILES=$( cd "$( dirname "${BASH_SOURCE[0]:-${(%):-%x}}" )" && pwd ) export DOTFILES=$( cd "$( dirname "${BASH_SOURCE[0]:-${(%):-%x}}" )" && pwd )
dfs() dfs()
@ -82,4 +91,17 @@ dfs()
# alias # alias
alias "pls"='sudo $(fc -ln -1)' alias "pls"='sudo $(fc -ln -1)'
alias "se"='sudo -sE' 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

View File

@ -187,6 +187,7 @@ uninstall_crontab(){
install(){ install(){
install_crontab install_crontab
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"
create_symlink "${dotfile_path}/.ssh/authorized_keys2" "${HOME}/.ssh/authorized_keys2" create_symlink "${dotfile_path}/.ssh/authorized_keys2" "${HOME}/.ssh/authorized_keys2"
fmt_note "done installing!" fmt_note "done installing!"
} }
@ -196,6 +197,7 @@ uninstall(){
if [[ $? == 1 ]]; then if [[ $? == 1 ]]; then
uninstall_crontab uninstall_crontab
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_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

20
tools/install.sh Executable file
View File

@ -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

41
tools/ubuntu.sh Executable file
View File

@ -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 $@