├── gitconfig ├── tools ├── install_zsh_no_sudo.sh ├── update_config.sh └── install.sh ├── README.md ├── .gitmodules ├── zshrc └── tmux.conf /gitconfig: -------------------------------------------------------------------------------- 1 | [user] 2 | email = zjli1997@163.com 3 | name = serend1p1ty 4 | [core] 5 | editor = vim 6 | [diff] 7 | tool = vimdiff 8 | [difftool] 9 | prompt = false 10 | [alias] 11 | d = difftool 12 | [credential] 13 | helper = cache --timeout=86400 -------------------------------------------------------------------------------- /tools/install_zsh_no_sudo.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -e 4 | 5 | mkdir ~/tmp && cd ~/tmp 6 | wget https://sourceforge.net/projects/zsh/files/zsh/5.8/zsh-5.8.tar.xz 7 | tar xvf zsh-5.8.tar.xz && cd zsh-5.8 8 | ./configure --prefix=$HOME 9 | make && make install 10 | 11 | rm ~/tmp -rf 12 | 13 | echo "exec ~/bin/zsh -l" >> ~/.bashrc 14 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # dotfiles 2 | 3 | ## 1. Introduction 4 | 5 | Build development environment (`zsh`, `vim`, `tmux`) for Linux. 6 | 7 | ## 2. Installation 8 | 9 | **Requirements**: `zsh`, `vim`, `tmux`, `fd (optional)`, `ag (optional)`, `exuberant ctags (optional)` 10 | 11 | ``` 12 | git clone https://github.com/serend1p1ty/dotfiles.git ~/dotfiles 13 | sh ~/dotfiles/tools/install.sh 14 | ``` 15 | -------------------------------------------------------------------------------- /tools/update_config.sh: -------------------------------------------------------------------------------- 1 | this_file_dir=$(cd "$(dirname "$0")";pwd) 2 | root=$this_file_dir/.. 3 | cd $root 4 | 5 | if [ $1 == "up" ]; then 6 | echo "Upload configuration." 7 | cp ~/.tmux.conf tmux.conf 8 | cp ~/.zshrc zshrc 9 | cp ~/.gitconfig gitconfig 10 | fi 11 | 12 | if [ $1 == "down" ]; then 13 | echo "Download configuration." 14 | cp tmux.conf ~/.tmux.conf 15 | cp zshrc ~/.zshrc 16 | cp gitconfig ~/.gitconfig 17 | fi 18 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "third_party/zsh-autosuggestions"] 2 | path = third_party/zsh-autosuggestions 3 | url = https://github.com/zsh-users/zsh-autosuggestions 4 | [submodule "third_party/zsh-syntax-highlighting"] 5 | path = third_party/zsh-syntax-highlighting 6 | url = https://github.com/zsh-users/zsh-syntax-highlighting.git 7 | [submodule "third_party/oh-my-zsh"] 8 | path = third_party/oh-my-zsh 9 | url = https://github.com/ohmyzsh/ohmyzsh.git 10 | [submodule "third_party/fzf"] 11 | path = third_party/fzf 12 | url = https://github.com/junegunn/fzf.git 13 | -------------------------------------------------------------------------------- /zshrc: -------------------------------------------------------------------------------- 1 | ZSH_THEME="robbyrussell" 2 | # export PS1="[%c]$ " 3 | 4 | # https://github.com/ohmyzsh/ohmyzsh/wiki/FAQ#i-see-duplicate-typed-characters-after-i-complete-a-command 5 | export LC_ALL=C.UTF-8 6 | 7 | plugins=(git z zsh-autosuggestions zsh-syntax-highlighting) 8 | 9 | source $HOME/.oh-my-zsh/oh-my-zsh.sh 10 | 11 | #################### 12 | # autosuggestion # 13 | #################### 14 | # set suggestion color 15 | # ZSH_AUTOSUGGEST_HIGHLIGHT_STYLE="fg=24" 16 | 17 | ################## 18 | # fuzzy finder # 19 | ################## 20 | # make alt-c work in macos 21 | bindkey "ç" fzf-cd-widget 22 | export FZF_DEFAULT_OPTS="--height 40% --layout=reverse --border" 23 | export FZF_DEFAULT_COMMAND="fd --type f" 24 | export FZF_CTRL_T_COMMAND="$FZF_DEFAULT_COMMAND" 25 | export FZF_ALT_C_COMMAND="fd -t d . " 26 | [ -f ~/.fzf.zsh ] && source ~/.fzf.zsh 27 | 28 | alias cl="clear" 29 | 30 | build_ctags () { 31 | if (($+1)) { 32 | fd --type f | ctags --python-kinds=-i -f $1 -L- 33 | } else { 34 | fd --type f | ctags --python-kinds=-i -L- 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /tmux.conf: -------------------------------------------------------------------------------- 1 | # set prefix to 2 | # -g means global, i.e., apply the setting to all sessions 3 | set -g prefix C-a 4 | unbind C-b 5 | 6 | set -g history-limit 500000 7 | 8 | set -g allow-rename off 9 | 10 | set -g default-terminal "screen-256color" 11 | 12 | # prefix r 13 | # reload configuration 14 | bind r source-file ~/.tmux.conf \; display "Reloaded ~/.tmux.conf" 15 | 16 | # make work immediately 17 | set -s escape-time 0 18 | 19 | # enable vi in copy mode 20 | setw -g mode-keys vi 21 | # -b means run in background 22 | run-shell -b "tmux bind -t vi-copy v begin-selection 2> /dev/null || true" 23 | run-shell -b "tmux bind -T copy-mode-vi v send -X begin-selection 2> /dev/null || true" 24 | run-shell -b "tmux bind -t vi-copy y copy-selection 2> /dev/null || true" 25 | run-shell -b "tmux bind -T copy-mode-vi y send -X copy-selection-and-cancel 2> /dev/null || true" 26 | 27 | # prefix | 28 | # split the window horizontally 29 | unbind % 30 | bind | split-window -h 31 | 32 | # prefix - 33 | # split the window vertically 34 | unbind '"' 35 | bind - split-window -v 36 | 37 | # prefix arrow 38 | # resize the panel, -r means this key may repeat 39 | bind -r up resizep -U 2 40 | bind -r down resizep -D 2 41 | bind -r left resizep -L 2 42 | bind -r right resizep -R 2 43 | 44 | # 45 | # smart pane switching with awareness of vim splits and fzf 46 | # -n means that no prefix key is required 47 | is_vim="ps -o state= -o comm= -t '#{pane_tty}' | grep -iqE '^[^TXZ ]+ +(\\S+\\/)?g?(view|n?vim?x?)(diff)?$'" 48 | is_fzf="ps -o state= -o comm= -t '#{pane_tty}' | grep -iqE '^[^TXZ ]+ +(\\S+\\/)?fzf$'" 49 | bind -n C-h run-shell "($is_vim && tmux send-keys C-h) || tmux select-pane -L" 50 | bind -n C-j run-shell "($is_vim && tmux send-keys C-j) || ($is_fzf && tmux send-keys C-j) || tmux select-pane -D" 51 | bind -n C-k run-shell "($is_vim && tmux send-keys C-k) || ($is_fzf && tmux send-keys C-k) || tmux select-pane -U" 52 | bind -n C-l run-shell "($is_vim && tmux send-keys C-l) || tmux select-pane -R" 53 | -------------------------------------------------------------------------------- /tools/install.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -e 4 | 5 | for opt in "$@"; do 6 | case $opt in 7 | --vim) 8 | install_vim="1" 9 | ;; 10 | --zsh) 11 | install_zsh="1" 12 | ;; 13 | --zsh-offline) 14 | arch=$(uname -sm) 15 | install_zsh="2" 16 | ;; 17 | --zsh-download=*) 18 | arch="${opt#*=}" 19 | install_zsh="3" 20 | ;; 21 | --tmux) 22 | install_tmux="1" 23 | ;; 24 | --gitconfig) 25 | install_gitconfig="1" 26 | ;; 27 | *) 28 | # unknown option 29 | ;; 30 | esac 31 | done 32 | 33 | command_exists () { 34 | command -v "$1" >/dev/null 2>&1 || { echo ">>> $1 is not installed" >&2; exit 1; } 35 | } 36 | 37 | command_exists git 38 | command_exists wget 39 | 40 | this_file_dir=$(cd "$(dirname "$0")";pwd) 41 | root=$this_file_dir/.. 42 | cd $root 43 | 44 | if [ "$install_vim" = "1" ] || [ "$install_vim" = "2" ] || [ "$install_vim" = "3" ]; then 45 | command_exists vim 46 | git clone --depth=1 https://github.com/serend1p1ty/vim.git ~/.vim_runtime 47 | sh ~/.vim_runtime/install.sh 48 | fi 49 | 50 | if [ "$install_zsh" != "0" ]; then 51 | command_exists zsh 52 | if [ "$install_zsh" = "1" ]; then 53 | # online installation 54 | # oh-my-zsh 55 | wget https://github.com/robbyrussell/oh-my-zsh/raw/master/tools/install.sh -O - | sh 56 | 57 | # useful zsh plugins 58 | git clone https://github.com/zsh-users/zsh-autosuggestions ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions 59 | git clone https://github.com/zsh-users/zsh-syntax-highlighting.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting 60 | 61 | # fuzzy-finder, you want it! 62 | git clone --depth 1 https://github.com/junegunn/fzf.git ~/.fzf 63 | ~/.fzf/install 64 | 65 | # copy configuration file 66 | cp zshrc ~/.zshrc 67 | else 68 | version=0.33.0 69 | case "$arch" in 70 | Darwin\ arm64) exec_file=fzf-$version-darwin_arm64.zip ;; 71 | Darwin\ x86_64) exec_file=fzf-$version-darwin_amd64.zip ;; 72 | Linux\ armv5*) exec_file=fzf-$version-linux_armv5.tar.gz ;; 73 | Linux\ armv6*) exec_file=fzf-$version-linux_armv6.tar.gz ;; 74 | Linux\ armv7*) exec_file=fzf-$version-linux_armv7.tar.gz ;; 75 | Linux\ armv8*) exec_file=fzf-$version-linux_arm64.tar.gz ;; 76 | Linux\ aarch64*) exec_file=fzf-$version-linux_arm64.tar.gz ;; 77 | Linux\ *64) exec_file=fzf-$version-linux_amd64.tar.gz ;; 78 | FreeBSD\ *64) exec_file=fzf-$version-freebsd_amd64.tar.gz ;; 79 | OpenBSD\ *64) exec_file=fzf-$version-openbsd_amd64.tar.gz ;; 80 | CYGWIN*\ *64) exec_file=fzf-$version-windows_amd64.zip ;; 81 | MINGW*\ *64) exec_file=fzf-$version-windows_amd64.zip ;; 82 | MSYS*\ *64) exec_file=fzf-$version-windows_amd64.zip ;; 83 | Windows*\ *64) exec_file=fzf-$version-windows_amd64.zip ;; 84 | *) echo "unsupported architecture $arch"; exit 1 ;; 85 | esac 86 | 87 | if [ "$install_zsh" = "2" ]; then 88 | # offline installation 89 | cp -r third_party/oh-my-zsh ~/.oh-my-zsh 90 | cp -r third_party/zsh-autosuggestions ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/ 91 | cp -r third_party/zsh-syntax-highlighting ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/ 92 | 93 | cp -r third_party/fzf ~/.fzf 94 | exec_file_path=third_party/fzf/$exec_file 95 | if [ ! -f $exec_file_path ]; then 96 | echo ">>> $exec_file_path not found! Run './install.sh --zsh-download=your_arch' to download it." 97 | fi 98 | tar xvzf third_party/fzf/$exec_file -C ~/.fzf/bin/ 99 | ~/.fzf/install 100 | 101 | # copy configuration file 102 | cp zshrc ~/.zshrc 103 | else 104 | echo ">>> Downloading third_party source code" 105 | git submodule update --init --recursive 106 | echo ">>> Downloading fzf binary to third_party/fzf/$exec_file" 107 | wget -O third_party/fzf/$exec_file https://github.com/junegunn/fzf/releases/download/$version/$exec_file 108 | fi 109 | fi 110 | fi 111 | 112 | if [ "$install_tmux" = "1" ]; then 113 | command_exists tmux 114 | cp tmux.conf ~/.tmux.conf 115 | fi 116 | 117 | if [ "$install_gitconfig" = "1" ]; then 118 | cp gitconfig ~/.gitconfig 119 | fi 120 | 121 | echo ">>> Installed the configuration successfully, enjoy it!" 122 | --------------------------------------------------------------------------------