├── .gitignore ├── LICENSE ├── README.md ├── bash └── bashrc ├── common ├── aliases.sh ├── exports.sh ├── functions.sh ├── golang.sh ├── other.sh ├── python.sh ├── quickjump.sh ├── ssh-agent-wrapper.sh └── virtualenvwrapper.sh ├── custom └── .gitkeep ├── git ├── gitconfig └── tigrc ├── macos └── brew.sh ├── mutt └── muttrc ├── pip └── pip.conf ├── screen └── screenrc ├── setup.sh ├── tmux ├── tanky ├── tmux.conf └── tmux.sh ├── tools ├── 256-color.sh ├── http-proxy │ ├── polipo.conf │ └── run ├── ss-proxy │ ├── .gitignore │ └── run ├── syntax.sh └── tmux-multi.sh ├── uninstall.sh ├── vim ├── colors │ └── apprentice_mod.vim └── vimrc └── zsh ├── tanky.zsh-theme └── zshrc /.gitignore: -------------------------------------------------------------------------------- 1 | custom/* 2 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2013 Tanky Woo 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy of 6 | this software and associated documentation files (the "Software"), to deal in 7 | the Software without restriction, including without limitation the rights to 8 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 9 | the Software, and to permit persons to whom the Software is furnished to do so, 10 | subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 17 | FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 18 | COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 19 | IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 20 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Dotfiles # 2 | 3 | > **WARNING: 2018-04-29, THE STRUCTURE OF REPOSITORY HAS BEEN CHANGED, IF YOU PULLED, YOU SHOULD RE-SYMLINK THE DOTFILES** 4 | 5 | My dotfiles for: `bash`, `zsh`, `vim`, `neovim`, `git`, `tmux`, `screen` and useful tools, etc. 6 | 7 | 8 | ## Install & Uninstall ## 9 | 10 | > **READ BEFORE YOU RUN THESE SCRIPTS** 11 | 12 | Install: 13 | 14 | ./setup.sh 15 | 16 | Uninstall: 17 | 18 | ./uninstall.sh # by default in dry-run mode, it's not going to actually execute 19 | ./uninstall.sh -f # actually execute rm symlink, and keep if it's not symlink 20 | 21 | 22 | ## Usage ## 23 | 24 | `common/aliases.sh`: 25 | - `treepy`: `tree` exclude `.pyc` 26 | - `json`: pretty print json file 27 | - `ccat`: cat code with color 28 | - `mux`: alias [tmuxinator](https://github.com/tmuxinator/tmuxinator) 29 | - `mac-listen`: `netstat -tlnp` under macOS 30 | 31 | `common/functions.sh`: 32 | - `pycd`: quick cd to python source package directory 33 | - `set-tab`: change terminal tab's title 34 | - `mdv`: markdown preview in terminal, [mdv](https://github.com/axiros/terminal_markdown_viewer) 35 | - `wanip`: get outer ip in private network 36 | - `getip`: get geo ip 37 | - `man`: man with color 38 | 39 | `common/virtualenvwrapper.sh`: source virtualenvwrapper script 40 | 41 | `common/ssh-agent-wrapper.sh`: auto start ssh agent to load private key 42 | 43 | `git/gitconfig`: user global configuration. `git diff` with `diff-highlight` tool, set some alias shortkey, and colors for status 44 | 45 | `pip/pip.conf`: set pypi mirror for [ustc.edu.cn](https://mirrors.ustc.edu.cn/pypi/web/) or [douban](http://pypi.doubanio.com/) 46 | 47 | `tmux/tmux.conf`: set prefix key with `control + a` instead default `control + b`, for compatible with `screen` 48 | 49 | `tools/tmux-multi.sh`: get hosts list file as arg, auto quick start tmux window with multiple panes, each pane with one host login by ssh, and operate these hosts synchronized. 50 | 51 | `tools/256-color.sh`: display 256 colors in terminal 52 | 53 | 54 | ## State ## 55 | 56 | Current the configurations and install script have been tested to work on: 57 | 58 | * Gentoo 59 | * Mac OS >= 10.9 60 | * Ubuntu >= 12.04 61 | 62 | If there are problems on other platforms, please contact me, thanks. 63 | 64 | 65 | ## Contact ## 66 | 67 | - HOMEPAGE: [Tanky Woo](http://tankywoo.com/) 68 | - EMAIL: 69 | -------------------------------------------------------------------------------- /bash/bashrc: -------------------------------------------------------------------------------- 1 | # /etc/bash/bashrc 2 | # 3 | # This file is sourced by all *interactive* bash shells on startup, 4 | # including some apparently interactive shells such as scp and rcp 5 | # that can't tolerate any output. So make sure this doesn't display 6 | # anything or bad things will happen ! 7 | 8 | 9 | # Test for an interactive shell. There is no need to set anything 10 | # past this point for scp and rcp, and it's important to refrain from 11 | # outputting anything in those cases. 12 | if [[ $- != *i* ]] ; then 13 | # Shell is non-interactive. Be done now! 14 | return 15 | fi 16 | 17 | # Bash won't get SIGWINCH if another process is in the foreground. 18 | # Enable checkwinsize so that bash will check the terminal size when 19 | # it regains control. #65623 20 | # http://cnswww.cns.cwru.edu/~chet/bash/FAQ (E11) 21 | shopt -s checkwinsize 22 | 23 | # Disable completion when the input buffer is empty. i.e. Hitting tab 24 | # and waiting a long time for bash to expand all of $PATH. 25 | shopt -s no_empty_cmd_completion 26 | 27 | # Enable history appending instead of overwriting when exiting. #139609 28 | shopt -s histappend 29 | 30 | # Save each command to the history file as it's executed. #517342 31 | # This does mean sessions get interleaved when reading later on, but this 32 | # way the history is always up to date. History is not synced across live 33 | # sessions though; that is what `history -n` does. 34 | # Disabled by default due to concerns related to system recovery when $HOME 35 | # is under duress, or lives somewhere flaky (like NFS). Constantly syncing 36 | # the history will halt the shell prompt until it's finished. 37 | #PROMPT_COMMAND='history -a' 38 | 39 | # Change the window title of X terminals 40 | case ${TERM} in 41 | [aEkx]term*|rxvt*|gnome*|konsole*|interix) 42 | PS1='\[\033]0;\u@\h:\w\007\]' 43 | ;; 44 | screen*) 45 | PS1='\[\033k\u@\h:\w\033\\\]' 46 | ;; 47 | *) 48 | unset PS1 49 | ;; 50 | esac 51 | 52 | # Set colorful PS1 only on colorful terminals. 53 | # dircolors --print-database uses its own built-in database 54 | # instead of using /etc/DIR_COLORS. Try to use the external file 55 | # first to take advantage of user additions. 56 | use_color=false 57 | if type -P dircolors >/dev/null ; then 58 | # Enable colors for ls, etc. Prefer ~/.dir_colors #64489 59 | LS_COLORS= 60 | if [[ -f ~/.dir_colors ]] ; then 61 | # If you have a custom file, chances are high that it's not the default. 62 | used_default_dircolors="no" 63 | eval "$(dircolors -b ~/.dir_colors)" 64 | elif [[ -f /etc/DIR_COLORS ]] ; then 65 | # People might have customized the system database. 66 | used_default_dircolors="maybe" 67 | eval "$(dircolors -b /etc/DIR_COLORS)" 68 | else 69 | used_default_dircolors="yes" 70 | eval "$(dircolors -b)" 71 | fi 72 | if [[ -n ${LS_COLORS:+set} ]] ; then 73 | use_color=true 74 | 75 | # The majority of systems out there do not customize these files, so we 76 | # want to avoid always exporting the large $LS_COLORS variable. This 77 | # keeps the active env smaller, and it means we don't have to deal with 78 | # running new/old (incompatible) versions of `ls` compared to when we 79 | # last sourced this file. 80 | case ${used_default_dircolors} in 81 | no) ;; 82 | yes) unset LS_COLORS ;; 83 | *) 84 | ls_colors=$(eval "$(dircolors -b)"; echo "${LS_COLORS}") 85 | if [[ ${ls_colors} == "${LS_COLORS}" ]] ; then 86 | unset LS_COLORS 87 | fi 88 | ;; 89 | esac 90 | fi 91 | unset used_default_dircolors 92 | else 93 | # Some systems (e.g. BSD & embedded) don't typically come with 94 | # dircolors so we need to hardcode some terminals in here. 95 | case ${TERM} in 96 | [aEkx]term*|rxvt*|gnome*|konsole*|screen|cons25|*color) use_color=true;; 97 | esac 98 | fi 99 | 100 | if ${use_color} ; then 101 | if [[ ${EUID} == 0 ]] ; then 102 | PS1+='\[\033[01;31m\]\h\[\033[01;34m\] \W \$\[\033[00m\] ' 103 | else 104 | PS1+='\[\033[01;32m\]\u@\h\[\033[01;34m\] \w \$\[\033[00m\] ' 105 | fi 106 | 107 | alias ls='ls --color=auto' 108 | alias grep='grep --colour=auto' 109 | alias egrep='egrep --colour=auto' 110 | alias fgrep='fgrep --colour=auto' 111 | else 112 | if [[ ${EUID} == 0 ]] ; then 113 | # show root@ when we don't have colors 114 | PS1+='\u@\h \W \$ ' 115 | else 116 | PS1+='\u@\h \w \$ ' 117 | fi 118 | fi 119 | 120 | for sh in /etc/bash/bashrc.d/* ; do 121 | [[ -r ${sh} ]] && source "${sh}" 122 | done 123 | 124 | # custom 125 | for sh in ~/bashrc.d/* ; do 126 | [[ -r ${sh} ]] && source "${sh}" 127 | done 128 | 129 | source ~/.common/exports.sh 130 | source ~/.common/aliases.sh 131 | source ~/.common/functions.sh 132 | 133 | source ~/.common/python.sh 134 | source ~/.common/golang.sh 135 | 136 | source ~/.common/quickjump.sh 137 | source ~/.common/virtualenvwrapper.sh 138 | source ~/.common/ssh-agent-wrapper.sh 139 | 140 | source ~/.common/other.sh 141 | 142 | # compat with bash/zsh 143 | if [ -d ${HOME}/.custom ]; then 144 | custom_sh=( $( find ${HOME}/.custom -name '*.sh' ) ) 145 | if [ ${#custom_sh[@]} -gt 0 ]; then 146 | for sf in "${custom_sh[@]}"; do 147 | source $sf 148 | done 149 | fi 150 | fi 151 | 152 | # Try to keep environment pollution down, EPA loves us. 153 | unset use_color sh 154 | -------------------------------------------------------------------------------- /common/aliases.sh: -------------------------------------------------------------------------------- 1 | alias tmux="tmux -2" 2 | 3 | if [[ "$(uname)" == "Darwin" ]]; then 4 | # For Mac OS 5 | alias ls='ls -hG' 6 | elif [[ "$(uname)" == "Linux" ]];then 7 | # For Linux 8 | alias ls='ls --color=auto' 9 | fi 10 | alias ll='ls -al' 11 | alias lls='ls -alSh' 12 | alias rm='rm -i' 13 | alias cp='cp -i' 14 | alias mv='mv -i' 15 | alias grep='grep --color' 16 | 17 | alias vix='vim --cmd "set expandtab"' 18 | 19 | alias treepy='tree -I "*.pyc"' 20 | alias json="python -mjson.tool" 21 | alias ccat="pygmentize -f terminal256 -O style=monokai -g" 22 | alias mux="tmuxinator" 23 | 24 | #@bug: fc -l cause fzf works wrong 25 | #alias history='fc -l' # defult: aliased to fc -l 1 26 | #export HISTTIMEFORMAT='%F %T' # for Bash only 27 | if [[ "$SHELL" == `which zsh 2>/dev/null` ]]; then 28 | HISTFILE=~/.zsh_history 29 | elif [[ "$SHELL" == `which bash 2>/dev/null` ]]; then 30 | HISTFILE=~/.bash_history 31 | fi 32 | HISTSIZE=9999 33 | SAVEHIST=9999 34 | if [[ "$SHELL" == `which zsh 2>/dev/null` ]]; then 35 | setopt extendedhistory 36 | fi 37 | 38 | if [[ "$(uname)" == "Darwin" ]]; then 39 | alias mac-listen='sudo lsof -i -n -P | grep TCP' 40 | fi 41 | -------------------------------------------------------------------------------- /common/exports.sh: -------------------------------------------------------------------------------- 1 | # shellcheck shell=bash 2 | # ------------------------------------------------------------------------------- 3 | # xterm settings 4 | # ------------------------------------------------------------------------------- 5 | # xterm hack for some terminals to support 256 colors 6 | 7 | if [ -z "$TMUX" ] && [[ "$TERM" =~ "xterm" ]]; then 8 | if ls /usr/share/terminfo/*/xterm-256color >/dev/null 2>&1; then 9 | export TERM='xterm-256color' 10 | else 11 | export TERM='xterm-color' 12 | fi 13 | elif [ -n "$TMUX" ]; then 14 | if ls /usr/share/terminfo/*/screen-256color >/dev/null 2>&1; then 15 | export TERM='screen-256color' 16 | else 17 | export TERM='screen' 18 | fi 19 | fi 20 | 21 | # ------------------------------------------------------------------------------- 22 | # $PATH settings 23 | # ------------------------------------------------------------------------------- 24 | # refer to: http://superuser.com/questions/39751/add-directory-to-path-if-its-not-already-there 25 | pathappend() { 26 | for _path in "$@" 27 | do 28 | if [ -d "$_path" ] && [[ ":$PATH:" != *":$_path:"* ]]; then 29 | PATH="${PATH:+"$PATH:"}$_path" 30 | fi 31 | done 32 | } 33 | 34 | pathprepend() { 35 | _paths=("$@") 36 | for ((i=$(($# - 1)); i>=0; i--)); 37 | do 38 | _path=${_paths[*]:$i:1} # for bash & zsh, https://stackoverflow.com/a/56311706/1276501 39 | if [ -d "$_path" ] && [[ ":$PATH:" != *":$_path:"* ]]; then 40 | PATH="$_path${PATH:+":$PATH"}" 41 | fi 42 | export PATH 43 | done 44 | } 45 | 46 | pathprepend_f() { 47 | # force prepend path no matter if it already exists in $PATH 48 | _paths=("$@") 49 | for ((i=$(($# - 1)); i>=0; i--)); 50 | do 51 | _path=${_paths[*]:$i:1} # for bash & zsh, https://stackoverflow.com/a/56311706/1276501 52 | if [ -d "$_path" ]; then 53 | PATH="$_path${PATH:+":$PATH"}" 54 | fi 55 | export PATH 56 | done 57 | } 58 | 59 | normalize_path() { 60 | # remove duplicate items in $PATH 61 | # shell will auto add some path to $PATH, which cause duplicate paths 62 | paths="" 63 | declare -a _paths=( $(echo $PATH | tr ':' ' ') ) 64 | for _path in "${_paths[@]}"; do 65 | if [[ ":$paths:" != *":$_path:"* ]]; then 66 | paths="${paths:+"$paths:"}$_path" 67 | fi 68 | done 69 | unset PATH 70 | # should export, or behave strangely under darwin bash, like which command 71 | export PATH=$paths 72 | } 73 | 74 | pathprepend_f /usr/local/bin /usr/local/sbin 75 | pathprepend /bin /usr/bin /sbin /usr/sbin 76 | 77 | if command -v pyenv >/dev/null 2>&1; then 78 | pathprepend_f "$(pyenv root)/shims" 79 | fi 80 | normalize_path 81 | 82 | 83 | # ------------------------------------------------------------------------------- 84 | # other environment variables 85 | # ------------------------------------------------------------------------------- 86 | export TZ='Asia/Shanghai' 87 | export EDITOR='vim' 88 | export LANG='en_US.UTF-8' 89 | export LESS='-RS' 90 | -------------------------------------------------------------------------------- /common/functions.sh: -------------------------------------------------------------------------------- 1 | if [[ $EUID -ne 0 ]]; then 2 | SUDO=sudo 3 | fi 4 | 5 | # ------------------------------------------------------------------------------- 6 | # Quick jump to Python package directory 7 | # ------------------------------------------------------------------------------- 8 | pycd(){ cd $(dirname $(python -c "print __import__('$1').__file__")); } 9 | 10 | # ------------------------------------------------------------------------------- 11 | # Simplify ntpdate command 12 | # ------------------------------------------------------------------------------- 13 | ntpupdate(){ $SUDO ntpdate cn.pool.ntp.org; } 14 | #ntpupdate(){ $SUDO ntpdate jp.pool.ntp.org; } 15 | 16 | # ------------------------------------------------------------------------------- 17 | # set window/tab title 18 | # $1 = type; 0 - both, 1 - tab, 2 - title 19 | # ref: 20 | # - Change iTerm2 window and tab titles in zsh 21 | # - http://superuser.com/questions/419775/with-bash-iterm2-how-to-name-tabs 22 | # `echo -ne "\e]1;your title\a"` for simple 23 | # TODO not work under tmux 24 | # ------------------------------------------------------------------------------- 25 | setTerminalText() { 26 | local mode=$1 ; shift 27 | echo -ne "\033]$mode;$@\007" 28 | } 29 | set-both() { setTerminalText 0 $@; } 30 | set-tab() { setTerminalText 1 $@; } 31 | set-window() { setTerminalText 2 $@; } 32 | 33 | # ------------------------------------------------------------------------------- 34 | # mdv is a python tool, markdown preview under terminal 35 | # ------------------------------------------------------------------------------- 36 | mdv_path=`command -v mdv` 37 | if [ $? -eq 0 ]; then 38 | mdv() { $mdv_path $@ | less; } 39 | fi 40 | 41 | # ------------------------------------------------------------------------------- 42 | # wanip get the external ip 43 | # ref: http://unix.stackexchange.com/questions/22615/how-can-i-get-my-external-ip-address-in-a-shell-script 44 | # ------------------------------------------------------------------------------- 45 | wanip() { dig +short myip.opendns.com @resolver1.opendns.com; } 46 | 47 | # ------------------------------------------------------------------------------- 48 | # Geo lookup 49 | # ------------------------------------------------------------------------------- 50 | geoip(){ curl ip.cn/$1; } 51 | 52 | # ------------------------------------------------------------------------------- 53 | # colored man 54 | # ------------------------------------------------------------------------------- 55 | # Fix colored man pages not work 56 | # * http://unix.stackexchange.com/questions/6010/colored-man-pages-not-working-on-gentoo 57 | # * https://forums.gentoo.org/viewtopic-t-819833-start-0.html 58 | export GROFF_NO_SGR=1 59 | # Overwrite man with different color 60 | man() { 61 | env \ 62 | LESS_TERMCAP_mb=$(printf "\e[1;34m") \ 63 | LESS_TERMCAP_md=$(printf "\e[1;34m") \ 64 | LESS_TERMCAP_me=$(printf "\e[0m") \ 65 | LESS_TERMCAP_se=$(printf "\e[0m") \ 66 | LESS_TERMCAP_so=$(printf "\e[1;44;33m") \ 67 | LESS_TERMCAP_ue=$(printf "\e[0m") \ 68 | LESS_TERMCAP_us=$(printf "\e[1;32m") \ 69 | PAGER="${commands[less]:-$PAGER}" \ 70 | _NROFF_U=1 \ 71 | PATH="$HOME/bin:$PATH" \ 72 | man "$@" 73 | } 74 | -------------------------------------------------------------------------------- /common/golang.sh: -------------------------------------------------------------------------------- 1 | export GOPATH=${HOME}/.go 2 | pathprepend $GOPATH/bin 3 | -------------------------------------------------------------------------------- /common/other.sh: -------------------------------------------------------------------------------- 1 | # rbenv; Octopress 2 | if command -v rbenv 2>/dev/null; then 3 | export PATH="$HOME/.rbenv/bin:$PATH" 4 | eval "$(rbenv init -)" 5 | fi 6 | 7 | # rvm 8 | pathappend $HOME/.rvm/bin # Add RVM to PATH for scripting 9 | 10 | # for Mac new Python 11 | if [[ "$(uname)" == "Darwin" ]]; then 12 | pathappend $HOME/Library/Python/2.7/bin 13 | fi 14 | 15 | # disable CTRL+S from sending XOFF 16 | stty ixany 17 | stty ixoff -ixon 18 | -------------------------------------------------------------------------------- /common/python.sh: -------------------------------------------------------------------------------- 1 | pathprepend ${HOME}/.local/bin 2 | -------------------------------------------------------------------------------- /common/quickjump.sh: -------------------------------------------------------------------------------- 1 | # http://jeroenjanssens.com/2013/08/16/quickly-navigate-your-filesystem-from-the-command-line.html 2 | # This tool is used to quick jump 3 | export MARKPATH=$HOME/.marks 4 | function cda { 5 | cd -P "$MARKPATH/$1" 2>/dev/null || echo "No such mark: $1" 6 | } 7 | function mark { 8 | mkdir -p "$MARKPATH"; ln -s "$(pwd)" "$MARKPATH/$1" 9 | } 10 | function unmark { 11 | rm -i "$MARKPATH/$1" 12 | } 13 | function marks { 14 | ls -l "$MARKPATH" | sed 's/ / /g' | cut -d' ' -f9- | sed 's/ -/\t-/g' && echo 15 | } 16 | function _completemarks { 17 | reply=($(ls $MARKPATH)) 18 | } 19 | 20 | if [[ "$SHELL" == */"bash" ]]; then 21 | _completemarks() { 22 | local curw=${COMP_WORDS[COMP_CWORD]} 23 | local wordlist=$(find $MARKPATH -type l -printf "%f\n") 24 | COMPREPLY=($(compgen -W '${wordlist[@]}' -- "$curw")) 25 | return 0 26 | } 27 | 28 | complete -F _completemarks jump unmark 29 | elif [[ "$SHELL" == */"zsh" ]]; then 30 | compctl -K _completemarks cda 31 | compctl -K _completemarks unmark 32 | fi 33 | -------------------------------------------------------------------------------- /common/ssh-agent-wrapper.sh: -------------------------------------------------------------------------------- 1 | # ------------------------------------------------------------------------------- 2 | # Auto start ssh agent to load private key 3 | # ------------------------------------------------------------------------------- 4 | 5 | # Set up ssh-agent 6 | SSH_ENV="$HOME/.ssh/environment" 7 | 8 | function start_agent { 9 | echo "Initializing new SSH agent..." 10 | /usr/bin/ssh-agent | sed 's/^echo/#echo/' > "${SSH_ENV}" 11 | echo succeeded 12 | chmod 600 "${SSH_ENV}" 13 | . "${SSH_ENV}" > /dev/null 14 | /usr/bin/ssh-add; 15 | } 16 | 17 | # Source SSH settings, if applicable 18 | if [ -f "${SSH_ENV}" ]; then 19 | . "${SSH_ENV}" > /dev/null 20 | #ps ${SSH_AGENT_PID} doesn't work under cywgin 21 | ps -ef | grep ${SSH_AGENT_PID} | grep ssh-agent$ > /dev/null || { 22 | start_agent; 23 | } 24 | else 25 | start_agent; 26 | fi 27 | 28 | -------------------------------------------------------------------------------- /common/virtualenvwrapper.sh: -------------------------------------------------------------------------------- 1 | # ------------------------------------------------------------------------------- 2 | # An virtualenv enhanced tool 3 | # ref: 4 | # - 5 | # - 6 | # ------------------------------------------------------------------------------- 7 | 8 | # default $WORKON_HOME is ~/.virtualenvs after source virtualenvwrapper.sh 9 | #export WORKON_HOME=~/Envs 10 | VIRTUALENVWRAPPER_UBUNTU="/usr/local/bin/virtualenvwrapper.sh" 11 | VIRTUALENVWRAPPER_GENTOO="/usr/bin/virtualenvwrapper.sh" 12 | VIRTUALENVWRAPPER_PIP_USER="~/.local/bin/virtualenvwrapper.sh" 13 | if [ -e "${VIRTUALENVWRAPPER_UBUNTU}" ]; then 14 | source ${VIRTUALENVWRAPPER_UBUNTU} 15 | elif [ -e "${VIRTUALENVWRAPPER_GENTOO}" ]; then 16 | source ${VIRTUALENVWRAPPER_GENTOO} 17 | elif [ -e "${VIRTUALENVWRAPPER_PIP_USER}" ]; then 18 | source ${VIRTUALENVWRAPPER_PIP_USER} 19 | fi 20 | 21 | -------------------------------------------------------------------------------- /custom/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tankywoo/dotfiles/37270ad547c259746059fa437bed90ec630be64c/custom/.gitkeep -------------------------------------------------------------------------------- /git/gitconfig: -------------------------------------------------------------------------------- 1 | [user] 2 | name = Tanky Woo 3 | email = wtq1990@gmail.com 4 | [push] 5 | ; for git 1.8 6 | default = simple 7 | [core] 8 | editor = vim 9 | excludesfile = /home/tankywoo/.gitignore 10 | quotepath = false 11 | pager = less -RS 12 | [diff] 13 | tool = vimdiff 14 | [merge] 15 | tool = vimdiff 16 | [difftool] 17 | prompt = false 18 | 19 | [alias] 20 | st = status 21 | l = log --pretty=oneline -n 20 --graph --abbrev-commit 22 | ll = log --color --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit -- 23 | la = log --color --graph --oneline --decorate --all -- 24 | b = branch 25 | ci = commit -v 26 | ca = commit -a -v 27 | pl = pull 28 | ps = push 29 | co = checkout 30 | df = diff 31 | lg = log --color --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit -- 32 | 33 | ; https://github.com/git/git/tree/master/contrib/diff-highlight 34 | [pager] 35 | log = diff-highlight | less 36 | show = diff-highlight | less 37 | diff = diff-highlight | less 38 | 39 | [interactive] 40 | diffFilter = diff-highlight | less 41 | 42 | [color] 43 | ui = auto 44 | [color "branch"] 45 | current = yellow reverse 46 | local = yellow 47 | remote = green 48 | [color "diff"] 49 | meta = yellow bold 50 | frag = magenta bold 51 | old = red bold 52 | new = green bold 53 | [color "diff-highlight"] 54 | oldNormal = red bold 55 | oldHighlight = red bold 52 56 | newNormal = green bold 57 | newHighlight = green bold 22 58 | [color "status"] 59 | added = yellow 60 | changed = green 61 | untracked = cyan 62 | -------------------------------------------------------------------------------- /git/tigrc: -------------------------------------------------------------------------------- 1 | # Tig 2 | # Project Page: https://github.com/jonas/tig 3 | # Default RC: https://github.com/jonas/tig/blob/master/tigrc 4 | # Man: http://jonas.nitro.dk/tig/tigrc.5.html 5 | 6 | # View settings 7 | set main-view = \ 8 | line-number:yes,interval=5 \ 9 | id:yes \ 10 | date:default \ 11 | author:full \ 12 | commit-title:yes,graph,refs,overflow=no 13 | 14 | # UI display settings 15 | set line-graphics = utf-8 # Enum: ascii, default, utf-8 16 | 17 | set reference-format = (branch) 18 | 19 | set split-view-width = 60% 20 | -------------------------------------------------------------------------------- /macos/brew.sh: -------------------------------------------------------------------------------- 1 | # Brew 2 | brew install ack 3 | brew install aria2 4 | brew install arping 5 | brew install autojump 6 | brew install axel 7 | brew install bash-completion 8 | brew install bower 9 | brew install coreutils 10 | brew install curl 11 | brew install dos2unix 12 | brew install findutils 13 | brew install flake8 14 | brew install fping 15 | brew install fzf 16 | brew install gawk 17 | brew install geoip 18 | brew install gist 19 | brew install git 20 | brew install git-cal 21 | brew install gnu-getopt 22 | brew install gnu-sed 23 | brew install go 24 | brew install gotags 25 | brew install govendor 26 | brew install highlight 27 | brew install htop 28 | brew install httpie 29 | brew install ipcalc 30 | brew install iproute2mac 31 | brew install jq 32 | brew install macvim 33 | brew install mercurial 34 | brew install mitmproxy 35 | brew install mongodb 36 | brew install mosh 37 | brew install mtr 38 | brew install mutt 39 | brew install mycli 40 | brew install mysql 41 | brew install nginx 42 | brew install ngrep 43 | brew install nmap 44 | brew install node 45 | brew install openssh 46 | brew install openssl 47 | brew install openssl@1.1 48 | brew install openvpn 49 | brew install pandoc 50 | brew install pdsh 51 | brew install polipo 52 | brew install pssh 53 | brew install pstree 54 | brew install python 55 | brew install python3 56 | brew install python@2 57 | brew install ranger 58 | brew install redis 59 | brew install shadowsocks-libev 60 | brew install shellcheck 61 | brew install simple-obfs 62 | brew install sqlite 63 | brew install the_silver_searcher 64 | brew install tig 65 | brew install tmux 66 | brew install tree 67 | brew install unrar 68 | brew install vim 69 | brew install watch 70 | brew install wget 71 | brew install zsh-completions 72 | 73 | 74 | # Brew Cask 75 | brew cask install firefox 76 | brew cask install google-chrome 77 | brew cask install macdown 78 | brew cask install osxfuse 79 | brew cask install vagrant 80 | brew cask install veracrypt 81 | brew cask install virtualbox 82 | -------------------------------------------------------------------------------- /mutt/muttrc: -------------------------------------------------------------------------------- 1 | # 设置发信地址和用户名 2 | set from = "" 3 | set realname = "" 4 | set use_from = yes 5 | 6 | # 设置邮箱帐户和密码 7 | set imap_user = "" 8 | set imap_pass = "" 9 | 10 | # 设置远程服务器文件夹 11 | set folder = "imaps://:" 12 | set spoolfile = "+INBOX" 13 | 14 | # 允许mutt自动创建一个新的imap连接 15 | unset imap_passive 16 | 17 | # imap连接保持时间 18 | set imap_keepalive = 300 19 | 20 | # 检查新邮件间隔时间 21 | set mail_check = 120 22 | 23 | # 本地缓存目录 24 | set header_cache = ~/.mutt/cache/headers 25 | set message_cachedir = ~/.mutt/cache/bodies 26 | 27 | # 设置内建smtp, 这里我们不使用 28 | #set smtp_url = "smtps://username@gmail.com@smtp.gmail.com:465/" 29 | #set smtp_pass = "your password" 30 | #set ssl_starttls = yes 31 | 32 | # 使用msmtp 33 | #set sendmail = "/usr/bin/msmtp" 34 | 35 | # 退出提醒 36 | set quit = ask-yes 37 | 38 | # 回信包含原文 39 | set include 40 | 41 | # 设置回信引文之前的插入符号 42 | set indent_str = "> " 43 | 44 | # 设置邮件头 45 | my_hdr From: xxx@xxx.com 46 | 47 | # 邮件打分 48 | # score "~N" +4 49 | # score "~s 通知" +2 50 | # score "~D" -5 51 | # score "~O" +1 52 | # score "~s believe" -10 53 | 54 | # 排序方式 55 | set sort = date 56 | 57 | # 二级排序 58 | #set sort_aux = score 59 | 60 | # 翻到最后一页不回到第一页 61 | set pager_stop 62 | 63 | # 删除邮件自动移动光标 64 | set resolve = yes 65 | 66 | # 设置编码,保持和终端一致 67 | set charset = "utf-8" 68 | 69 | # 是否编辑邮件头 70 | set edit_headers = no 71 | 72 | # pager显示行数 73 | set pager_index_lines = 4 74 | 75 | set pager_index_lines=15 76 | set sort=threads 77 | 78 | ignore * 79 | unignore from date subject to cc 80 | unignore organization organisation x-mailer: x-newsreader: x-mailing-list: 81 | unignore posted-to: 82 | 83 | # 颜色配置 84 | # http://www.mutt.org/doc/manual/manual-3.html 85 | color header cyan black . 86 | color header yellow black ^From 87 | color header yellow black ^Subject 88 | 89 | color hdrdefault green black 90 | color quoted green black 91 | color signature cyan black 92 | color attachment yellow black 93 | color tree white black 94 | color indicator brightyellow red 95 | color status yellow blue 96 | color tilde blue black 97 | color normal white black 98 | 99 | color message brightred black 100 | color error brightred black 101 | color markers red black 102 | color search white red 103 | color index blue black ~F 104 | color index red black "~N|~O" 105 | -------------------------------------------------------------------------------- /pip/pip.conf: -------------------------------------------------------------------------------- 1 | [global] 2 | timeout = 3000 3 | download_cache = ~/.pip/downloads/ 4 | index-url = https://pypi.mirrors.ustc.edu.cn/simple 5 | #index-url = http://pypi.doubanio.com/simple/ 6 | 7 | [install] 8 | trusted-host = pypi.doubanio.com 9 | -------------------------------------------------------------------------------- /screen/screenrc: -------------------------------------------------------------------------------- 1 | chdir # the default dir is home directory 2 | startup_message off # do not display the startup message 3 | term xterm 4 | altscreen on 5 | vbell off # disable the bell 6 | defscrollback 1000 7 | 8 | # ways to get the bindkey code: 9 | # * cat > /dev/null 10 | # * read 11 | # * ctrl+v 12 | # then press key and display code 13 | bindkey "^[[D" prev 14 | bindkey "^[[C" next 15 | 16 | # status line 17 | hardstatus on 18 | hardstatus alwayslastline 19 | hardstatus string "%{= br}%{g}[%{G}$USER@%H%{g}]%{w}%1`%{g}[%=%{=kw}%{w}%-w%{Y}[%{W}%n-%t%{Y}]%{w}%+w%=%{g}][%l][%{w}%Y-%m-%d %{Y}%c%{g}]" 20 | 21 | # screen windows 22 | screen -t tankykwoo 0 23 | screen -t ops-dev 1 24 | select 0 25 | -------------------------------------------------------------------------------- /setup.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # TODO: 4 | # - nvim support 5 | # 6 | 7 | OH_MY_ZSH=$HOME"/.oh-my-zsh" 8 | VIM_PLUG=$HOME"/.vim/autoload/plug.vim" 9 | #VUNDLE=$HOME"/.vim/bundle/Vundle.vim" 10 | #NEO_VUNDLE=$HOME"/.config/nvim/bundle/Vundle.vim" 11 | 12 | IS_VIM=0 13 | IS_NVIM=0 # neovim 14 | IS_GIT=0 15 | IS_BASH=0 16 | IS_ZSH=0 17 | IS_TMUX=0 18 | IS_PIP=0 19 | IS_SCREEN=0 20 | 21 | read -p "CHOOSE SHELL (bash or zsh)? " _shell 22 | # echo $choose_shell 23 | 24 | if [ "$_shell" = "bash" ]; then 25 | unset IS_ZSH 26 | elif [ "$_shell" = "zsh" ]; then 27 | unset IS_BASH 28 | else 29 | echo "Invalid shell type, exit." 30 | exit 1 31 | fi 32 | 33 | # Pre check 34 | check_installed() { 35 | softwares=("vim" "nvim" "git" "tmux" "pip" "screen") 36 | # bash >= 4.2 37 | if [ -v IS_BASH ]; then 38 | softwares+=( "bash" ) 39 | else 40 | softwares+=( "zsh" ) 41 | fi 42 | for sw in "${softwares[@]}" 43 | do 44 | flag="IS_${sw^^}" # bash >= 4.0 45 | # Notice the semicolon 46 | # Dynamic naming: 47 | # - https://stackoverflow.com/a/13717788/1276501 48 | # - https://stackoverflow.com/a/18124325/1276501 49 | type ${sw} > /dev/null 2>&1 && 50 | { printf -v "${flag}" 1; } || 51 | { echo >&2 "[WARN] \`${sw}' is not installed, ignore it."; } 52 | done 53 | } 54 | 55 | create_symlinks() { 56 | # dotfile_src format such as zsh/zshrc or vim/vimrc 57 | dotfile_src=$1 58 | dotfile_dst=$2 59 | if [[ "$dotfile_dst" != /* ]]; then 60 | # relative path 61 | dotfile_dst=$HOME/$dotfile_dst 62 | fi 63 | if [ -e $dotfile_dst ]; then 64 | if [ -h $dotfile_dst ]; then 65 | ln -sf $PWD/$dotfile_src $dotfile_dst 66 | echo "Update existed symlink $dotfile_dst" 67 | else 68 | echo "[WARN] Ignore due to $dotfile_dst exists and is not a symlink" 69 | fi 70 | else 71 | ln -sf $PWD/$dotfile_src $dotfile_dst 72 | echo "Create symlink $dotfile_dst" 73 | fi 74 | } 75 | 76 | # 77 | # VIM 78 | # 79 | _install_vundle(){ 80 | # deprecated 81 | VUNDLE_DIR=$1 82 | if [ -d "${VUNDLE_DIR}" ]; then 83 | cd "${VUNDLE_DIR}" 84 | echo "Change directory to `pwd`" 85 | echo "${VUNDLE_DIR} exists. Git pull to update..." 86 | git pull 87 | cd - > /dev/null 2>&1 88 | echo "Change directory back to `pwd`" 89 | else 90 | echo "${VUNDLE_DIR} not exists. Git clone to create..." 91 | git clone https://github.com/gmarik/Vundle.vim.git ${VUNDLE_DIR} 92 | vim +PluginInstall +qall 93 | fi 94 | } 95 | 96 | _install_vim_plug() { 97 | if ! [ -e $VIM_PLUG ]; then 98 | curl -fLo $VIM_PLUG --create-dirs \ 99 | https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim 100 | fi 101 | } 102 | 103 | config_vim() { 104 | # _install_vundle $VUNDLE 105 | _install_vim_plug 106 | create_symlinks "vim/vimrc" ".vimrc" 107 | } 108 | 109 | # 110 | # NEOVIM 111 | # 112 | config_nvim() { 113 | if [ -e $HOME/.vim ]; then 114 | create_symlinks "$HOME/.vim" "$HOME/.config/nvim" 115 | # else 116 | # _install_vundle $NEO_VUNDLE 117 | fi 118 | create_symlinks "vim/vimrc" "$HOME/.config/nvim/init.vim" 119 | } 120 | 121 | 122 | # 123 | # GIT 124 | # 125 | config_git() { 126 | create_symlinks "git/gitconfig" ".gitconfig" 127 | create_symlinks "git/tigrc" ".tigrc" 128 | } 129 | 130 | 131 | # 132 | # BASH 133 | # 134 | _config_shell() { 135 | create_symlinks "common" ".common" 136 | create_symlinks "tools" "tools" 137 | } 138 | 139 | config_bash() { 140 | create_symlinks "bash/bashrc" ".bashrc" 141 | _config_shell 142 | } 143 | 144 | 145 | # 146 | # ZSH 147 | # 148 | _install_oh_my_zsh() { 149 | if [ -d "${OH_MY_ZSH}" ]; then 150 | cd "${OH_MY_ZSH}" 151 | echo "Change directory to `pwd`" 152 | echo "${OH_MY_ZSH} exists. Git pull to update..." 153 | git pull 154 | cd - > /dev/null 2>&1 155 | echo "Change directory back to `pwd`" 156 | else 157 | echo "${OH_MY_ZSH} not exists. Install..." 158 | #git clone git@github.com:robbyrussell/oh-my-zsh.git ${HOME}/.oh-my-zsh 159 | #wget --no-check-certificate http://install.ohmyz.sh -O - | sh 160 | git clone https://github.com/robbyrussell/oh-my-zsh.git ${HOME}/.oh-my-zsh 161 | fi 162 | 163 | # install plugins 164 | zsh_autosuggestions="${HOME}/.oh-my-zsh/custom/plugins/zsh-autosuggestions" 165 | if ! [ -d "$zsh_autosuggestions" ]; then 166 | git clone https://github.com/zsh-users/zsh-autosuggestions.git $zsh_autosuggestions 167 | fi 168 | zsh_completions="${HOME}/.oh-my-zsh/custom/plugins/zsh-completions" 169 | if ! [ -d "$zsh_completions" ]; then 170 | git clone https://github.com/zsh-users/zsh-completions.git $zsh_completions 171 | fi 172 | } 173 | 174 | config_zsh() { 175 | _install_oh_my_zsh 176 | create_symlinks "zsh/zshrc" ".zshrc" 177 | _config_shell 178 | # TODO: See ~/.oh-my-zsh/custom/ 179 | create_symlinks "zsh/tanky.zsh-theme" "${OH_MY_ZSH}/themes/tanky.zsh-theme" 180 | # chsh -s `which zsh` # TODO: If zsh is an alias? 181 | echo "[INFO] Change your shell manually" 182 | } 183 | 184 | 185 | # 186 | # TMUX 187 | # 188 | config_tmux(){ 189 | create_symlinks "tmux/tmux.conf" ".tmux.conf" 190 | create_symlinks "tmux/tmux.sh" ".tmux.sh" 191 | } 192 | 193 | 194 | # 195 | # PIP 196 | # 197 | config_pip(){ 198 | [ -d ${HOME}/.pip ] || { mkdir $HOME/.pip; echo "mkdir $HOME/.pip"; } 199 | create_symlinks "pip/pip.conf" ".pip/pip.conf" 200 | } 201 | 202 | 203 | # 204 | # SCREEN 205 | # 206 | config_screen() { 207 | create_symlinks "screen/screenrc" ".screenrc" 208 | } 209 | 210 | # 211 | # CUSTOM 212 | # 213 | mkdir_custom() { 214 | [ -e ${HOME}/.custom ] || { mkdir $HOME/.custom; echo "mkdir $HOME/.custom"; } 215 | } 216 | 217 | 218 | check_installed 219 | [ $IS_VIM -eq 1 ] && config_vim 220 | [ $IS_NVIM -eq 1 ] && config_nvim 221 | [ $IS_GIT -eq 1 ] && config_git 222 | [ -v IS_BASH ] && [ "$IS_BASH" -eq 1 ] && config_bash 223 | [ -v IS_ZSH ] && [ "$IS_ZSH" -eq 1 ] && config_zsh 224 | [ $IS_TMUX -eq 1 ] && config_tmux 225 | [ $IS_PIP -eq 1 ] && config_pip 226 | [ $IS_SCREEN -eq 1 ] && config_screen 227 | mkdir_custom 228 | 229 | echo "[SETUP OK]" 230 | -------------------------------------------------------------------------------- /tmux/tanky: -------------------------------------------------------------------------------- 1 | select-pane -t 0 2 | split-window -h -p 60 3 | select-pane -t 1 4 | split-window -v -p 25 5 | select-pane -t 1 6 | -------------------------------------------------------------------------------- /tmux/tmux.conf: -------------------------------------------------------------------------------- 1 | #set -g default-terminal "xterm-256color" # Use 256 colors 2 | set -g default-terminal "screen-256color" # Use 256 colors 3 | # fix utf character confused with mosh + tmux 4 | # see issue: https://github.com/tmux/tmux/issues/1310 5 | set -as terminal-overrides ',*:indn@' 6 | set -g display-time 5000 7 | # tmux 2.2 has remove below option 8 | # set -g status-utf8 on # Enable utf-8 9 | set -g history-limit 100000 # Scrollback buffer n lines 10 | # set -g mouse on # Enable mouse (>=2.1) 11 | setw -g mode-keys vi 12 | # esc in delay under neovim with tmux 13 | # ref: https://github.com/neovim/neovim/wiki/FAQ#esc-in-tmux-or-gnu-screen-is-delayed 14 | set -g escape-time 0 15 | set-option -g status-position top # Status bar, default bottom 16 | 17 | set-option -g allow-rename off 18 | 19 | # Start window indexing at one instead of zero 20 | set -g base-index 1 21 | 22 | # Start pane indexing at one instead of zero 23 | setw -g pane-base-index 1 24 | 25 | # Disable default 500ms repeat time 26 | set-option -g repeat-time 0 27 | 28 | # Set the prefix key and some key bindings to match GNU Screen 29 | set -g prefix C-a 30 | unbind-key C-b 31 | bind-key C-a send-prefix 32 | 33 | # Key bindings for horizontal and vertical panes 34 | unbind % 35 | bind | split-window -h 36 | unbind '"' 37 | bind - split-window -v 38 | 39 | # Key bindings for join/split panes 40 | # via: http://unix.stackexchange.com/questions/14300/moving-tmux-window-to-pane 41 | bind-key j command-prompt -p "join pane from:" "join-pane -s '%%'" 42 | bind-key s command-prompt -p "send pane to:" "join-pane -t '%%'" 43 | 44 | # Shift-movement keys will resize panes 45 | bind -r H resize-pane -L 5 46 | bind -r J resize-pane -D 5 47 | bind -r K resize-pane -U 5 48 | bind -r L resize-pane -R 5 49 | 50 | # Window title string (uses statusbar variables) 51 | set -g set-titles-string '#T' 52 | # Disable auto rename window title 53 | set -g allow-rename off 54 | setw -g automatic-rename off 55 | 56 | # Bind to reload config 57 | bind r source-file ~/.tmux.conf 58 | 59 | # Bind to create a specify layout in current window 60 | bind T source-file ~/.dotfiles/tanky 61 | 62 | # # Pane settings 63 | # set -g status-left-length 90 64 | # set -g status-right-length 90 65 | # set -g status-left '[#(whoami)]' 66 | # set -g status-right '#[fg=white][#(date +" %m-%d %H:%M ")]' 67 | # set -g status-justify "centre" 68 | # set -g window-status-format '#I #W' 69 | # set -g window-status-current-format ' #I #W ' 70 | # 71 | # # https://github.com/seebi/tmux-colors-solarized 72 | # #### COLOUR (Solarized 256) 73 | # 74 | # # default statusbar colors 75 | # set-option -g status-bg blue 76 | # set-option -g status-fg white 77 | # set-option -g status-attr default 78 | # 79 | # # default window title colors 80 | # set-window-option -g window-status-fg colour253 81 | # set-window-option -g window-status-bg default 82 | # set-window-option -g window-status-attr dim 83 | # 84 | # # active window title colors 85 | # set-window-option -g window-status-current-fg white 86 | # set-window-option -g window-status-current-bg cyan 87 | # set-window-option -g window-status-current-attr bright 88 | # 89 | # # pane border 90 | # set-option -g pane-border-fg green 91 | # set-option -g pane-border-bg black 92 | # set-option -g pane-active-border-fg red 93 | # set-option -g pane-active-border-bg black 94 | # 95 | # # message text 96 | # set-option -g message-bg white 97 | # set-option -g message-fg black 98 | # set-option -g message-attr bright 99 | # 100 | # # pane number display 101 | # set-option -g display-panes-active-colour colour33 #blue 102 | # set-option -g display-panes-colour colour166 #orange 103 | 104 | 105 | ## Status bar design 106 | ## from: http://www.hamvocke.com/blog/a-guide-to-customizing-your-tmux-conf/ 107 | # status line 108 | set -g status-justify centre 109 | set -g status-bg default 110 | set -g status-fg colour12 111 | set -g status-interval 2 112 | 113 | # messaging 114 | set -g message-style fg=black,bg=yellow 115 | set -g message-command-style fg=blue,bg=black 116 | 117 | #window mode 118 | setw -g mode-style fg=colour0,bg=colour6 119 | 120 | # window status 121 | setw -g window-status-format " #F#I:#W#F " 122 | setw -g window-status-current-format " #F#I:#W#F " 123 | setw -g window-status-format "#[fg=magenta]#[bg=black] #I #[bg=cyan]#[fg=colour8] #W " 124 | setw -g window-status-current-format "#[bg=brightmagenta]#[fg=colour8] #I #[fg=colour8]#[bg=colour14] #W " 125 | setw -g window-status-current-style fg=colour11,bg=colour0,dim 126 | setw -g window-status-style fg=black,bg=green,reverse 127 | 128 | # loud or quiet? 129 | set-option -g visual-activity off 130 | set-option -g visual-bell off 131 | set-option -g visual-silence off 132 | set-window-option -g monitor-activity off 133 | set-option -g bell-action none 134 | 135 | set -g default-terminal "screen-256color" 136 | 137 | # The modes 138 | setw -g clock-mode-colour colour135 139 | setw -g mode-style fg=colour196,bg=colour238,bold 140 | 141 | # The panes 142 | set -g pane-border-style fg=colour238,bg=colour235 143 | set -g pane-active-border-style fg=red,bg=colour236 144 | 145 | # The statusbar 146 | set -g status-position bottom 147 | set -g status-style fg=colour137,bg=colour234,dim 148 | set -g status-left '#[fg=colour233,bg=colour241,bold] @#(whoami) #[fg=colour233,bg=colour245,bold] [#h] ' 149 | set -g status-right '#{?pane_synchronized, #[fg=white]#[bg=blue] sync ,}#[fg=colour233,bg=colour241,bold] %Y-%m-%d #[fg=colour233,bg=colour245,bold] %H:%M ' 150 | set -g status-right-length 50 151 | set -g status-left-length 50 152 | 153 | setw -g window-status-current-style fg=blue,bg=colour238,bold 154 | setw -g window-status-current-format ' #I#[fg=colour250]:#[fg=colour255]#W#[fg=red]#F ' 155 | 156 | setw -g window-status-style fg=colour138,bg=colour235,none 157 | setw -g window-status-format ' #I#[fg=colour237]:#[fg=colour250]#W#[fg=colour244]#F ' 158 | 159 | setw -g window-status-bell-style fg=colour255,bg=colour1,bold 160 | -------------------------------------------------------------------------------- /tmux/tmux.sh: -------------------------------------------------------------------------------- 1 | #!/bin/zsh 2 | # Tanky Woo 3 | 4 | # 5 | SESSION_NAME='dev' 6 | WINDOWS_NAME1='tankywoo' 7 | WINDOWS_NAME2='ops-dev' 8 | 9 | source ~/.zshrc 10 | tmux='tmux -2' 11 | 12 | tmux start-server 13 | 14 | if ! $(tmux has-session -t ${SESSION_NAME}); then 15 | tmux new-session -d -s ${SESSION_NAME} -n ${WINDOWS_NAME1} # -d is important 16 | 17 | tmux select-window -t ${WINDOWS_NAME1} 18 | tmux split-window -h -p 60 19 | tmux select-pane -t 0 20 | tmux split-window -v -p 25 21 | tmux send-keys -t 0 'ipython' C-m 22 | # The C-m at the end is interpreted by Tmux as the enter key. 23 | 24 | tmux new-window -n ${WINDOWS_NAME2} 25 | 26 | tmux select-window -t ${WINDOWS_NAME1} 27 | tmux select-pane -t 2 28 | fi 29 | 30 | tmux attach-session -d -t ${SESSION_NAME} 31 | -------------------------------------------------------------------------------- /tools/256-color.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # ------------------------------------------------------------------ 3 | # Tanky Woo (2016-07-27) 4 | # Show 256 colors under terminal 5 | # Ref: http://misc.flogisoft.com/bash/tip_colors_and_formatting 6 | # ------------------------------------------------------------------ 7 | 8 | for fb in 38 48; do # fg with 38 or bg with 48 9 | for code in {0..255}; do # 256-colors 10 | printf "\e[%s;05;%sm%-4s\e[0m " "${fb}" "${code}" "${code}" 11 | if ! (( ( $code + 1 ) % 16 )); then 12 | echo # or `echo -n -e '\n'` 13 | fi 14 | done 15 | echo -n -e "\n\n" 16 | done 17 | -------------------------------------------------------------------------------- /tools/http-proxy/polipo.conf: -------------------------------------------------------------------------------- 1 | socksParentProxy = "localhost:1080" 2 | socksProxyType = socks5 3 | logLevel=4 4 | -------------------------------------------------------------------------------- /tools/http-proxy/run: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # ------------------------------------------------------------------ 3 | # Tanky Woo (2016-07-28) 4 | # HTTP Wrapper (with polipo) 5 | # Usage: 6 | # ./run [start|stop] 7 | # ------------------------------------------------------------------ 8 | 9 | realpath() { 10 | [[ $1 = /* ]] && echo "$1" || echo "$PWD/${1#./}" 11 | } 12 | 13 | PROGPATH=$(realpath ${BASH_SOURCE}) 14 | DWORK=$(dirname ${PROGPATH}) 15 | 16 | CONF=${DWORK}/polipo.conf 17 | PIDFILE=/var/run/polipo.pid 18 | 19 | if [ ! -f ${CONF} ]; then 20 | echo ">> ${CONF} not exists!" 21 | exit 1 22 | fi 23 | 24 | if [[ $1 == "stop" ]]; then 25 | kill -TERM $(cat ${PIDFILE}) 26 | echo ">> stop polipo ok" 27 | else 28 | polipo -c ${CONF} -- daemonise=True logFile=/tmp/polipo.log pidFile=${PIDFILE} 29 | echo ">> start polipo ok" 30 | fi 31 | -------------------------------------------------------------------------------- /tools/ss-proxy/.gitignore: -------------------------------------------------------------------------------- 1 | *.json 2 | -------------------------------------------------------------------------------- /tools/ss-proxy/run: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # ------------------------------------------------------------------ 3 | # Tanky Woo (2016-07-28) 4 | # Shadowsocks Wrapper (Python version, not libev) 5 | # Usage: 6 | # ./run [start|stop] 7 | # ------------------------------------------------------------------ 8 | 9 | realpath() { 10 | [[ $1 = /* ]] && echo "$1" || echo "$PWD/${1#./}" 11 | } 12 | 13 | PROGPATH=$(realpath ${BASH_SOURCE}) 14 | DWORK=$(dirname ${PROGPATH}) 15 | 16 | CONF_NAME=$1 17 | CONF=${DWORK}/${CONF_NAME}.json 18 | 19 | if [ ! -f ${CONF} ]; then 20 | echo ">> ${CONF} not exists!" 21 | exit 1 22 | fi 23 | 24 | if [[ $2 == "stop" ]]; then 25 | sslocal -c ${CONF} --log-file /tmp/ss.log -d stop 26 | echo ">> stop shadowsocks [$CONF_NAME] ok" # TODO stop failed also return 0 27 | else 28 | sslocal -c ${CONF} --log-file /tmp/ss.log -d start 29 | (( ! $? )) && echo ">> start shadowsocks [$CONF_NAME] ok" || echo ">> start shadowsocks [$CONF_NAME] failed" 30 | fi 31 | -------------------------------------------------------------------------------- /tools/syntax.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # ------------------------------------------------------------------ 3 | # Tanky Woo (2016-07-30) 4 | # Show code syntax theme with Pygments 5 | # Ref: 6 | # - http://stackoverflow.com/questions/7314044/use-bash-to-read-line-by-line-and-keep-space 7 | # - http://stackoverflow.com/questions/5349718/how-can-i-repeat-a-character-in-bash 8 | # ------------------------------------------------------------------ 9 | 10 | #IFS='' 11 | 12 | # pygmentize -L styles | grep '* ' | cut -d ' ' -f2 | cut -d ':' -f1 # get style list 13 | THEMES=("manni" "igor" "lovelace" "xcode" "vim" "autumn" "vs" "rrt" 14 | "native" "perldoc" "borland" "tango" "emacs" "friendly" "monokai" "paraiso-dark" 15 | "colorful" "murphy" "bw" "pastie" "algol_nu" "paraiso-light" "trac" 16 | "default" "algol" "fruity") 17 | 18 | CODE=$(cat <" 19 | exit 1 20 | fi 21 | 22 | # remove empty lines and comment lines 23 | HOSTS=$(sed -e 's/#.*$//' -e '/^$/d' $HOSTS_FILE) 24 | 25 | WINDOW_NAME=tmux-multi 26 | MAX_PANES=16 # max panes per window 27 | HOSTS_COUNT=$(echo "$HOSTS" | wc -l) 28 | PANE_BASE_INDEX=$(tmux showw -gv pane-base-index) 29 | 30 | widx=0 # window index 31 | hidx=0 # host index 32 | declare -i selected_pane 33 | 34 | pane_offset=$(( 1 - ${PANE_BASE_INDEX:-0} )) 35 | 36 | while read host; do 37 | 38 | # every MAX_PANES number of hosts put in one window 39 | if [ $(( hidx % MAX_PANES )) -eq 0 ]; then 40 | (( widx++ )) 41 | selected_pane=${PANE_BASE_INDEX:-0} 42 | tmux new-window -n "$WINDOW_NAME-$widx" 43 | tmux select-window -t "$WINDOW_NAME-$widx" 44 | fi 45 | 46 | (( hidx++ )) 47 | 48 | # The C-m at the end is interpreted by Tmux as the enter key. 49 | tmux send-keys -t $selected_pane "ssh root@$host" C-m 50 | 51 | if [ $(( $selected_pane + $pane_offset )) -lt $MAX_PANES \ 52 | -a $hidx -lt $HOSTS_COUNT ]; then 53 | tmux split-window -h 54 | else 55 | # last pane of a window, enable sync 56 | tmux set-window-option synchronize-panes on 57 | fi 58 | 59 | (( selected_pane++ )) 60 | 61 | tmux select-layout tiled 62 | 63 | done < <(echo "$HOSTS") 64 | -------------------------------------------------------------------------------- /uninstall.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # Tanky Woo @ 2013-10-18 00:19:56 3 | 4 | dry_run=1 5 | if [ "$1" == "-f" ]; then 6 | dry_run=0 7 | fi 8 | 9 | if [ "$dry_run" -eq 1 ]; then 10 | echo "=== DRY RUN MODE ===" 11 | fi 12 | 13 | remove_symlink() { 14 | dotfile=$1 15 | if ! [ -e $dotfile ]; then 16 | # echo "Ignore as symlink $dotfile not exists" 17 | return 18 | fi 19 | 20 | if [ -h $dotfile ]; then 21 | echo "Delete symlink $dotfile" 22 | if [ "$dry_run" -eq 0 ]; then 23 | rm -f $dotfile 24 | fi 25 | else 26 | echo "Keep $dotfile as it's not a symlink" 27 | fi 28 | } 29 | 30 | dotfiles=( 31 | ".zshrc" 32 | ".tmux.conf" 33 | ".vimrc" 34 | ".gitconfig" 35 | ".screenrc" 36 | "tools" 37 | ".common" 38 | "tmux.sh" 39 | ".zsh" 40 | ".pip/pip.conf" 41 | ) 42 | for dotfile in "${dotfiles[@]}" 43 | do 44 | remove_symlink $HOME/$dotfile 45 | done 46 | 47 | echo "Delete ${HOME}/.custom manually" 48 | -------------------------------------------------------------------------------- /vim/colors/apprentice_mod.vim: -------------------------------------------------------------------------------- 1 | " 'apprentice_mod.vim' -- Vim color scheme. 2 | " Author: Romain Lafourcade (romainlafourcade@gmail.com) 3 | " Description: Essentially a streamlining and conversion to xterm colors of 4 | " 'sorcerer' by Jeet Sukumaran (jeetsukumaran@gmailcom) 5 | " Last Change: 2017 Oct 07 6 | " Fork and Modified: 2019-03-26, Tanky Woo (me@tankywoo.com) 7 | 8 | " MADE-UP NAME HEX RGB XTERM ANSI 9 | " ======================================================================== 10 | " almost black #1c1c1c rgb(28, 28, 28) 234 0 11 | " darker grey #262626 rgb(38, 38, 38) 235 background color 12 | " dark grey #303030 rgb(48, 48, 48) 236 8 13 | " grey #444444 rgb(68, 68, 68) 238 8 14 | " medium grey #585858 rgb(88, 88, 88) 240 8 15 | " light grey #6c6c6c rgb(108, 108, 108) 242 7 16 | " lighter grey #bcbcbc rgb(188, 188, 188) 250 foreground color 17 | " white #ffffff rgb(255, 255, 255) 231 15 18 | " purple #5f5f87 rgb(95, 95, 135) 60 5 19 | " light purple #8787af rgb(135, 135, 175) 103 13 20 | " green #5f875f rgb(95, 135, 95) 65 2 21 | " light green #87af87 rgb(135, 175, 135) 108 10 22 | " aqua #5f8787 rgb(95, 135, 135) 66 6 23 | " light aqua #5fafaf rgb(95, 175, 175) 73 14 24 | " blue #5f87af rgb(95, 135, 175) 67 4 25 | " light blue #8fafd7 rgb(143, 175, 215) 110 12 26 | " red #af5f5f rgb(175, 95, 95) 131 1 27 | " orange #ff8700 rgb(255, 135, 0) 208 9 28 | " ocre #87875f rgb(135, 135, 95) 101 3 29 | " yellow #ffffaf rgb(255, 255, 175) 229 11 30 | 31 | hi clear 32 | 33 | if exists("syntax_on") 34 | syntax reset 35 | endif 36 | 37 | let colors_name = "apprentice_mod" 38 | 39 | if ($TERM =~ '256' || &t_Co >= 256) || has("gui_running") 40 | hi Normal ctermbg=235 ctermfg=250 guibg=#262626 guifg=#bcbcbc cterm=NONE gui=NONE 41 | hi Terminal ctermbg=235 ctermfg=250 guibg=#262626 guifg=#bcbcbc cterm=NONE gui=NONE 42 | hi LineNr ctermbg=234 ctermfg=242 guibg=#1c1c1c guifg=#6c6c6c cterm=NONE gui=NONE 43 | hi FoldColumn ctermbg=234 ctermfg=242 guibg=#1c1c1c guifg=#6c6c6c cterm=NONE gui=NONE 44 | hi Folded ctermbg=234 ctermfg=242 guibg=#1c1c1c guifg=#6c6c6c cterm=NONE gui=NONE 45 | hi MatchParen ctermbg=234 ctermfg=229 guibg=#1c1c1c guifg=#ffffaf cterm=NONE gui=NONE 46 | hi signColumn ctermbg=234 ctermfg=242 guibg=#1c1c1c guifg=#6c6c6c cterm=NONE gui=NONE 47 | 48 | set background=dark 49 | 50 | hi Comment ctermbg=NONE ctermfg=240 guibg=NONE guifg=#585858 cterm=NONE gui=NONE 51 | hi Conceal ctermbg=NONE ctermfg=250 guibg=NONE guifg=#bcbcbc cterm=NONE gui=NONE 52 | hi Constant ctermbg=NONE ctermfg=208 guibg=NONE guifg=#ff8700 cterm=NONE gui=NONE 53 | hi Error ctermbg=NONE ctermfg=131 guibg=NONE guifg=#af5f5f cterm=reverse gui=reverse 54 | hi Identifier ctermbg=NONE ctermfg=67 guibg=NONE guifg=#5f87af cterm=NONE gui=NONE 55 | hi Ignore ctermbg=NONE ctermfg=NONE guibg=NONE guifg=NONE cterm=NONE gui=NONE 56 | hi PreProc ctermbg=NONE ctermfg=66 guibg=NONE guifg=#5f8787 cterm=NONE gui=NONE 57 | hi Special ctermbg=NONE ctermfg=65 guibg=NONE guifg=#5f875f cterm=NONE gui=NONE 58 | hi Statement ctermbg=NONE ctermfg=110 guibg=NONE guifg=#8fafd7 cterm=NONE gui=NONE 59 | hi String ctermbg=NONE ctermfg=108 guibg=NONE guifg=#87af87 cterm=NONE gui=NONE 60 | hi Todo ctermbg=NONE ctermfg=NONE guibg=NONE guifg=NONE cterm=reverse gui=reverse 61 | hi Type ctermbg=NONE ctermfg=103 guibg=NONE guifg=#8787af cterm=NONE gui=NONE 62 | hi Underlined ctermbg=NONE ctermfg=66 guibg=NONE guifg=#5f8787 cterm=underline gui=underline 63 | 64 | hi NonText ctermbg=NONE ctermfg=240 guibg=NONE guifg=#585858 cterm=NONE gui=NONE 65 | 66 | hi Pmenu ctermbg=238 ctermfg=250 guibg=#444444 guifg=#bcbcbc cterm=NONE gui=NONE 67 | hi PmenuSbar ctermbg=240 ctermfg=NONE guibg=#585858 guifg=NONE cterm=NONE gui=NONE 68 | hi PmenuSel ctermbg=66 ctermfg=235 guibg=#5f8787 guifg=#262626 cterm=NONE gui=NONE 69 | hi PmenuThumb ctermbg=66 ctermfg=66 guibg=#5f8787 guifg=#5f8787 cterm=NONE gui=NONE 70 | 71 | hi ErrorMsg ctermbg=131 ctermfg=235 guibg=#af5f5f guifg=#262626 cterm=NONE gui=NONE 72 | hi ModeMsg ctermbg=108 ctermfg=235 guibg=#87af87 guifg=#262626 cterm=NONE gui=NONE 73 | hi MoreMsg ctermbg=NONE ctermfg=66 guibg=NONE guifg=#5f8787 cterm=NONE gui=NONE 74 | hi Question ctermbg=NONE ctermfg=108 guibg=NONE guifg=#87af87 cterm=NONE gui=NONE 75 | hi WarningMsg ctermbg=NONE ctermfg=131 guibg=NONE guifg=#af5f5f cterm=NONE gui=NONE 76 | 77 | hi TabLine ctermbg=238 ctermfg=101 guibg=#444444 guifg=#87875f cterm=NONE gui=NONE 78 | hi TabLineFill ctermbg=238 ctermfg=238 guibg=#444444 guifg=#444444 cterm=NONE gui=NONE 79 | hi TabLineSel ctermbg=101 ctermfg=235 guibg=#87875f guifg=#262626 cterm=NONE gui=NONE 80 | 81 | hi Cursor ctermbg=242 ctermfg=NONE guibg=#6c6c6c guifg=NONE cterm=NONE gui=NONE 82 | hi CursorColumn ctermbg=236 ctermfg=NONE guibg=#303030 guifg=NONE cterm=NONE gui=NONE 83 | hi CursorLineNr ctermbg=236 ctermfg=73 guibg=#303030 guifg=#5fafaf cterm=NONE gui=NONE 84 | hi CursorLine ctermbg=236 ctermfg=NONE guibg=#303030 guifg=NONE cterm=NONE gui=NONE 85 | 86 | hi helpLeadBlank ctermbg=NONE ctermfg=NONE guibg=NONE guifg=NONE cterm=NONE gui=NONE 87 | hi helpNormal ctermbg=NONE ctermfg=NONE guibg=NONE guifg=NONE cterm=NONE gui=NONE 88 | 89 | hi StatusLine ctermbg=101 ctermfg=235 guibg=#87875f guifg=#262626 cterm=NONE gui=NONE 90 | hi StatusLineNC ctermbg=238 ctermfg=101 guibg=#444444 guifg=#87875f cterm=NONE gui=NONE 91 | 92 | hi StatusLineTerm ctermbg=101 ctermfg=235 guibg=#87875f guifg=#262626 cterm=NONE gui=NONE 93 | hi StatusLineTermNC ctermbg=238 ctermfg=101 guibg=#444444 guifg=#87875f cterm=NONE gui=NONE 94 | 95 | hi Visual ctermbg=235 ctermfg=110 guibg=#262626 guifg=#8fafd7 cterm=reverse gui=reverse 96 | hi VisualNOS ctermbg=NONE ctermfg=NONE guibg=NONE guifg=NONE cterm=underline gui=underline 97 | 98 | hi VertSplit ctermbg=238 ctermfg=238 guibg=#444444 guifg=#444444 cterm=NONE gui=NONE 99 | hi WildMenu ctermbg=110 ctermfg=235 guibg=#8fafd7 guifg=#262626 cterm=NONE gui=NONE 100 | 101 | hi Function ctermbg=NONE ctermfg=229 guibg=NONE guifg=#ffffaf cterm=NONE gui=NONE 102 | hi SpecialKey ctermbg=NONE ctermfg=240 guibg=NONE guifg=#585858 cterm=NONE gui=NONE 103 | hi Title ctermbg=NONE ctermfg=231 guibg=NONE guifg=#ffffff cterm=NONE gui=NONE 104 | 105 | hi DiffAdd ctermbg=235 ctermfg=108 guibg=#262626 guifg=#87af87 cterm=reverse gui=reverse 106 | hi DiffChange ctermbg=235 ctermfg=103 guibg=#262626 guifg=#8787af cterm=reverse gui=reverse 107 | hi DiffDelete ctermbg=235 ctermfg=131 guibg=#262626 guifg=#af5f5f cterm=reverse gui=reverse 108 | hi DiffText ctermbg=235 ctermfg=208 guibg=#262626 guifg=#ff8700 cterm=reverse gui=reverse 109 | 110 | hi IncSearch ctermbg=131 ctermfg=235 guibg=#af5f5f guifg=#262626 cterm=NONE gui=NONE 111 | hi Search ctermbg=108 ctermfg=235 guibg=#ffffaf guifg=#262626 cterm=NONE gui=NONE 112 | 113 | hi Directory ctermbg=NONE ctermfg=73 guibg=NONE guifg=#5fafaf cterm=NONE gui=NONE 114 | 115 | hi debugPC ctermbg=67 guibg=#5f87af 116 | hi debugBreakpoint ctermbg=131 guibg=#af5f5f 117 | 118 | if has("gui_running") 119 | hi SpellBad ctermbg=NONE ctermfg=131 guibg=NONE guifg=NONE cterm=undercurl gui=undercurl guisp=#af5f5f 120 | hi SpellCap ctermbg=NONE ctermfg=73 guibg=NONE guifg=NONE cterm=undercurl gui=undercurl guisp=#5fafaf 121 | hi SpellLocal ctermbg=NONE ctermfg=65 guibg=NONE guifg=NONE cterm=undercurl gui=undercurl guisp=#5f875f 122 | hi SpellRare ctermbg=NONE ctermfg=208 guibg=NONE guifg=NONE cterm=undercurl gui=undercurl guisp=#ff8700 123 | else 124 | hi SpellBad ctermbg=NONE ctermfg=131 guibg=NONE guifg=#af5f5f cterm=undercurl gui=undercurl guisp=NONE 125 | hi SpellCap ctermbg=NONE ctermfg=73 guibg=NONE guifg=#5fafaf cterm=undercurl gui=undercurl guisp=NONE 126 | hi SpellLocal ctermbg=NONE ctermfg=65 guibg=NONE guifg=#5f875f cterm=undercurl gui=undercurl guisp=NONE 127 | hi SpellRare ctermbg=NONE ctermfg=208 guibg=NONE guifg=#ff8700 cterm=undercurl gui=undercurl guisp=NONE 128 | endif 129 | 130 | hi ColorColumn ctermbg=234 ctermfg=NONE guibg=#1c1c1c guifg=NONE cterm=NONE gui=NONE 131 | elseif &t_Co == 8 || $TERM !~# '^linux' || &t_Co == 16 132 | set t_Co=16 133 | 134 | hi Normal ctermbg=NONE ctermfg=white cterm=NONE 135 | hi Terminal ctermbg=NONE ctermfg=white cterm=NONE 136 | 137 | set background=dark 138 | 139 | hi Comment ctermbg=NONE ctermfg=gray cterm=NONE 140 | hi Conceal ctermbg=NONE ctermfg=white cterm=NONE 141 | hi Constant ctermbg=NONE ctermfg=red cterm=NONE 142 | hi Function ctermbg=NONE ctermfg=yellow cterm=NONE 143 | hi Identifier ctermbg=NONE ctermfg=darkblue cterm=NONE 144 | hi PreProc ctermbg=NONE ctermfg=darkcyan cterm=NONE 145 | hi Special ctermbg=NONE ctermfg=darkgreen cterm=NONE 146 | hi Statement ctermbg=NONE ctermfg=blue cterm=NONE 147 | hi String ctermbg=NONE ctermfg=green cterm=NONE 148 | hi Todo ctermbg=NONE ctermfg=NONE cterm=reverse 149 | hi Type ctermbg=NONE ctermfg=magenta cterm=NONE 150 | 151 | hi Error ctermbg=NONE ctermfg=darkred cterm=reverse 152 | hi Ignore ctermbg=NONE ctermfg=NONE cterm=NONE 153 | hi Underlined ctermbg=NONE ctermfg=NONE cterm=reverse 154 | 155 | hi LineNr ctermbg=black ctermfg=gray cterm=NONE 156 | hi NonText ctermbg=NONE ctermfg=darkgray cterm=NONE 157 | 158 | hi Pmenu ctermbg=darkgray ctermfg=white cterm=NONE 159 | hi PmenuSbar ctermbg=gray ctermfg=NONE cterm=NONE 160 | hi PmenuSel ctermbg=darkcyan ctermfg=black cterm=NONE 161 | hi PmenuThumb ctermbg=darkcyan ctermfg=NONE cterm=NONE 162 | 163 | hi ErrorMsg ctermbg=darkred ctermfg=black cterm=NONE 164 | hi ModeMsg ctermbg=darkgreen ctermfg=black cterm=NONE 165 | hi MoreMsg ctermbg=NONE ctermfg=darkcyan cterm=NONE 166 | hi Question ctermbg=NONE ctermfg=green cterm=NONE 167 | hi WarningMsg ctermbg=NONE ctermfg=darkred cterm=NONE 168 | 169 | hi TabLine ctermbg=darkgray ctermfg=darkyellow cterm=NONE 170 | hi TabLineFill ctermbg=darkgray ctermfg=black cterm=NONE 171 | hi TabLineSel ctermbg=darkyellow ctermfg=black cterm=NONE 172 | 173 | hi Cursor ctermbg=NONE ctermfg=NONE cterm=NONE 174 | hi CursorColumn ctermbg=darkgray ctermfg=NONE cterm=NONE 175 | hi CursorLineNr ctermbg=black ctermfg=cyan cterm=NONE 176 | hi CursorLine ctermbg=darkgray ctermfg=NONE cterm=NONE 177 | 178 | hi helpLeadBlank ctermbg=NONE ctermfg=NONE cterm=NONE 179 | hi helpNormal ctermbg=NONE ctermfg=NONE cterm=NONE 180 | 181 | hi StatusLine ctermbg=darkyellow ctermfg=black cterm=NONE 182 | hi StatusLineNC ctermbg=darkgray ctermfg=darkyellow cterm=NONE 183 | 184 | hi StatusLineterm ctermbg=darkyellow ctermfg=black cterm=NONE 185 | hi StatusLinetermNC ctermbg=darkgray ctermfg=darkyellow cterm=NONE 186 | 187 | hi Visual ctermbg=black ctermfg=blue cterm=reverse 188 | hi VisualNOS ctermbg=black ctermfg=white cterm=reverse 189 | 190 | hi FoldColumn ctermbg=black ctermfg=darkgray cterm=NONE 191 | hi Folded ctermbg=black ctermfg=darkgray cterm=NONE 192 | 193 | hi VertSplit ctermbg=darkgray ctermfg=darkgray cterm=NONE 194 | hi WildMenu ctermbg=blue ctermfg=black cterm=NONE 195 | 196 | hi SpecialKey ctermbg=NONE ctermfg=darkgray cterm=NONE 197 | hi Title ctermbg=NONE ctermfg=white cterm=NONE 198 | 199 | hi DiffAdd ctermbg=black ctermfg=green cterm=reverse 200 | hi DiffChange ctermbg=black ctermfg=magenta cterm=reverse 201 | hi DiffDelete ctermbg=black ctermfg=darkred cterm=reverse 202 | hi DiffText ctermbg=black ctermfg=red cterm=reverse 203 | 204 | hi IncSearch ctermbg=darkred ctermfg=black cterm=NONE 205 | hi Search ctermbg=yellow ctermfg=black cterm=NONE 206 | 207 | hi Directory ctermbg=NONE ctermfg=cyan cterm=NONE 208 | hi MatchParen ctermbg=black ctermfg=yellow cterm=NONE 209 | 210 | hi SpellBad ctermbg=NONE ctermfg=darkred cterm=undercurl 211 | hi SpellCap ctermbg=NONE ctermfg=darkyellow cterm=undercurl 212 | hi SpellLocal ctermbg=NONE ctermfg=darkgreen cterm=undercurl 213 | hi SpellRare ctermbg=NONE ctermfg=darkmagenta cterm=undercurl 214 | 215 | hi ColorColumn ctermbg=black ctermfg=NONE cterm=NONE 216 | hi SignColumn ctermbg=black ctermfg=darkgray cterm=NONE 217 | 218 | hi debugPC ctermbg=blue 219 | hi debugBreakpoint ctermbg=red 220 | endif 221 | 222 | let g:terminal_ansi_colors = [ 223 | \ '#1c1c1c', 224 | \ '#af5f5f', 225 | \ '#5f875f', 226 | \ '#87875f', 227 | \ '#5f87af', 228 | \ '#5f5f87', 229 | \ '#5f8787', 230 | \ '#6c6c6c', 231 | \ '#444444', 232 | \ '#ff8700', 233 | \ '#87af87', 234 | \ '#ffffaf', 235 | \ '#8fafd7', 236 | \ '#8787af', 237 | \ '#5fafaf', 238 | \ '#ffffff' 239 | \ ] 240 | 241 | let links = [ 242 | \ ['Boolean', 'Constant'], 243 | \ ['Character', 'Constant'], 244 | \ ['Conditional', 'Statement'], 245 | \ ['Debug', 'Special'], 246 | \ ['Define', 'PreProc'], 247 | \ ['Delimiter', 'Special'], 248 | \ ['Exception', 'Statement'], 249 | \ ['Float', 'Number'], 250 | \ ['HelpCommand', 'Statement'], 251 | \ ['HelpExample', 'Statement'], 252 | \ ['Include', 'PreProc'], 253 | \ ['Keyword', 'Statement'], 254 | \ ['Label', 'Statement'], 255 | \ ['Macro', 'PreProc'], 256 | \ ['Number', 'Constant'], 257 | \ ['Operator', 'Statement'], 258 | \ ['PreCondit', 'PreProc'], 259 | \ ['Repeat', 'Statement'], 260 | \ ['SpecialChar', 'Special'], 261 | \ ['SpecialComment', 'Special'], 262 | \ ['StorageClass', 'Type'], 263 | \ ['Structure', 'Type'], 264 | \ ['Tag', 'Special'], 265 | \ ['Terminal', 'Normal'], 266 | \ ['Typedef', 'Type'], 267 | \ ['htmlEndTag', 'htmlTagName'], 268 | \ ['htmlLink', 'Function'], 269 | \ ['htmlSpecialTagName', 'htmlTagName'], 270 | \ ['htmlTag', 'htmlTagName'], 271 | \ ['htmlBold', 'Normal'], 272 | \ ['htmlItalic', 'Normal'], 273 | \ ['xmlTag', 'Statement'], 274 | \ ['xmlTagName', 'Statement'], 275 | \ ['xmlEndTag', 'Statement'], 276 | \ ['markdownItalic', 'Preproc'], 277 | \ ['asciidocQuotedEmphasized', 'Preproc'], 278 | \ ['diffBDiffer', 'WarningMsg'], 279 | \ ['diffCommon', 'WarningMsg'], 280 | \ ['diffDiffer', 'WarningMsg'], 281 | \ ['diffIdentical', 'WarningMsg'], 282 | \ ['diffIsA', 'WarningMsg'], 283 | \ ['diffNoEOL', 'WarningMsg'], 284 | \ ['diffOnly', 'WarningMsg'], 285 | \ ['diffRemoved', 'WarningMsg'], 286 | \ ['diffAdded', 'String'], 287 | \ ] 288 | augroup Apprentice_mod 289 | autocmd! 290 | autocmd ColorScheme * if expand("") == "apprentice_mod" | for link in links | execute 'hi link' link[0] link[1] | endfor | else | for link in links | execute 'hi link' link[0] 'NONE' | endfor | endif 291 | augroup END 292 | -------------------------------------------------------------------------------- /vim/vimrc: -------------------------------------------------------------------------------- 1 | " Tanky Woo 2 | " https://tankywoo.com 3 | 4 | " =============================================================================== 5 | " Info 6 | " leader: default is `\`, detailed with `:help `` 7 | " =============================================================================== 8 | 9 | 10 | " =============================================================================== 11 | " General Configuration 12 | " =============================================================================== 13 | 14 | set nocompatible " Use the vim's keyboard setting, not vi 15 | 16 | if filereadable(expand("~/.vim/vimrc.vundle")) 17 | source ~/.vim/vimrc.vundle 18 | endif 19 | 20 | set nu " Set the line number 21 | syntax on " Syntax highlighting 22 | "set autochdir " Set the current dir as thr work dir 23 | filetype on " File type detection 24 | filetype plugin on " Loading the plugin files for specific file types 25 | filetype indent on " Loading the indent file for specific file types with 26 | 27 | " Tab and Indent 28 | set tabstop=4 29 | set softtabstop=4 30 | set shiftwidth=4 31 | set smarttab 32 | "set expandtab " Use the space to instead of tab 33 | set autoindent " Copy indent from current line when starting a new line 34 | set smartindent 35 | set cindent 36 | 37 | " Seach and Match 38 | set hlsearch " Highlight the search result 39 | set incsearch " Real-time search 40 | set ignorecase 41 | set smartcase 42 | set showmatch " When a bracket is inserted, briefly jump to the matching one 43 | 44 | " Display 45 | set showmode " Show the current mode 46 | set t_Co=256 " If under tty, use 256 47 | 48 | " Display tab and trail space 49 | set list 50 | set listchars=tab:>-,trail:. 51 | " Not display above list 52 | nmap l :set list! 53 | 54 | " Other 55 | set nobackup 56 | set fileencodings=utf-8,gb18030,cp936,big5 " Set the encode 57 | " set pastetoggle= " Bind `F10` to `:set paste` 58 | set pastetoggle=p 59 | set backspace=2 " same as ":set backspace=indent,eol,start" in vim7.4 60 | 61 | " Press `shift` while selecting with the mouse can disable into visual mode 62 | " In mac os, hold `alt/option` is easier 63 | " ref: http://stackoverflow.com/questions/4608161/copy-text-out-of-vim-with-set-mouse-a-enabled 64 | "set mouse=a " Enable mouse 65 | 66 | set foldmethod=indent " The kind of folding used for the current window 67 | set foldlevel=99 68 | 69 | " ------------------------------------------------------------------------------- 70 | " Enhanced 71 | " ------------------------------------------------------------------------------- 72 | 73 | au BufRead,BufNewFile *.md set filetype=markdown " .md default is modula2 74 | 75 | " Execute python file being edited with + e: 76 | map :w:!/usr/bin/env python % 77 | 78 | " Auto add head info 79 | " .py file auto add header 80 | function HeaderPython() 81 | call setline(1, "#!/usr/bin/env python") 82 | call append(1, "# -*- coding: utf-8 -*-") 83 | call append(2, "# Tanky Woo @ " . strftime('%Y-%m-%d', localtime())) 84 | normal G 85 | normal o 86 | endf 87 | autocmd bufnewfile *.py call HeaderPython() 88 | 89 | " .sh file auto add header 90 | function HeaderBash() 91 | call setline(1, "#!/bin/bash") 92 | call append(1, "# Tanky Woo @ " . strftime('%Y-%m-%d', localtime())) 93 | normal G 94 | normal o 95 | endf 96 | autocmd bufnewfile *.sh call HeaderBash() 97 | 98 | " ref: http://stackoverflow.com/questions/158968/changing-vim-indentation-behavior-by-file-type 99 | autocmd FileType html set shiftwidth=2|set expandtab 100 | autocmd FileType htmljinja setlocal shiftwidth=2 tabstop=2 softtabstop=2 expandtab 101 | autocmd FileType htmldjango setlocal shiftwidth=2 tabstop=2 softtabstop=2 expandtab 102 | autocmd FileType css setlocal shiftwidth=2 tabstop=2 softtabstop=2 expandtab 103 | autocmd Filetype javascript setlocal ts=2 sts=2 sw=2 expandtab 104 | autocmd FileType sh setlocal shiftwidth=4 tabstop=4 softtabstop=4 expandtab 105 | autocmd FileType python setlocal shiftwidth=4 tabstop=4 softtabstop=4 expandtab 106 | autocmd FileType vim setlocal shiftwidth=2 tabstop=2 softtabstop=2 expandtab 107 | 108 | " enable quick jump between keyword, such as if/endif 109 | runtime macros/matchit.vim 110 | 111 | " quick expand current active file's directory (not work directory) 112 | " use `%%' to auto expand instead of `%:h' 113 | cnoremap %% getcmdtype() == ':' ? expand('%:h').'/' : '%%' 114 | 115 | " ------------------------------------------------------------------------------- 116 | " Bind Keys 117 | " ------------------------------------------------------------------------------- 118 | 119 | " : quick temp disable hlsearch 120 | nnoremap :nohlsearch 121 | 122 | 123 | " ------------------------------------------------------------------------------- 124 | " Platform 125 | " ------------------------------------------------------------------------------- 126 | " ref: https://unix.stackexchange.com/a/253202/45725 127 | let g:platform = 0 128 | let g:distro = 0 129 | if filereadable("/etc/gentoo-release") 130 | let g:platform="Linux" 131 | let g:distro="Gentoo" 132 | elseif filereadable("/etc/debian_version") 133 | let g:platform="Linux" 134 | let g:distro="Debian" 135 | elseif has('mac') 136 | let g:platform="Darwin" 137 | let g:distro="OS X" 138 | else 139 | let g:platform="Unknown" 140 | endif 141 | 142 | 143 | " =============================================================================== 144 | " Vundle Configuration 145 | " =============================================================================== 146 | 147 | call plug#begin('~/.vim/bundle') 148 | 149 | " Display 150 | "Plug 'Lokaltog/vim-powerline' " newer powerline is https://github.com/powerline/powerline 151 | Plug 'vim-airline/vim-airline' 152 | Plug 'vim-airline/vim-airline-themes' 153 | Plug 'chriskempson/tomorrow-theme' 154 | " Plug 'kien/rainbow_parentheses.vim' 155 | "Plug 'Yggdroot/indentLine' 156 | " Note vim-colorschemes will cause vim-powerline not work if :tabnew 157 | " Plug 'flazz/vim-colorschemes' " themes collection 158 | Plug 'vim-scripts/Color-Scheme-Explorer' 159 | 160 | " Linter 161 | Plug 'w0rp/ale' 162 | 163 | " Python 164 | Plug 'davidhalter/jedi-vim' 165 | Plug 'nvie/vim-flake8' 166 | 167 | if g:distro != 'Gentoo' 168 | " under gentoo, conflict with dev-python/jinja builtin vim-jinja extension 169 | Plug 'mitsuhiko/vim-jinja' 170 | endif 171 | "Plug 'kevinw/pyflakes-vim' 172 | "Plug 'fs111/pydoc.vim' 173 | "Plug 'Pydiction' 174 | "Plug 'pep8' 175 | 176 | " HTML & CSS 177 | Plug 'mattn/emmet-vim' 178 | Plug 'hail2u/vim-css3-syntax' 179 | 180 | " JavaScript 181 | Plug 'pangloss/vim-javascript' " improved indentation 182 | Plug 'ternjs/tern_for_vim' " js autocompletion 183 | Plug 'Shutnik/jshint2.vim' 184 | 185 | " Go 186 | Plug 'fatih/vim-go' 187 | 188 | " Markdown 189 | Plug 'sjl/badwolf' 190 | Plug 'plasticboy/vim-markdown' 191 | 192 | " Enhanced 193 | Plug 'scrooloose/nerdtree' 194 | Plug 'jistr/vim-nerdtree-tabs' 195 | Plug 'tiagofumo/vim-nerdtree-syntax-highlight' 196 | Plug 'ryanoasis/vim-devicons' " need patch nerd fonts first 197 | Plug 'airblade/vim-gitgutter' 198 | Plug 'ervandew/supertab' 199 | "if has('nvim') 200 | " Plug 'Shougo/deoplete.nvim' 201 | "else 202 | " Plug 'Shougo/neocomplete.vim' " neocomplete need vim --with-lua 203 | "endif 204 | Plug 'Valloric/YouCompleteMe' 205 | Plug 'SirVer/ultisnips' 206 | Plug 'honza/vim-snippets' " needed with SirVer/ultisnips 207 | Plug 'AndrewRadev/splitjoin.vim' " transition between multiline and single-line code 208 | Plug 'vim-scripts/Tagbar' " Tagbar is more powerful than 'taglist.vim' 209 | Plug 'vim-scripts/Auto-Pairs' " Auto-Pairs is more useful than AutoClose 210 | Plug 'godlygeek/tabular' " need by plasticboy/vim-markdown 211 | Plug 'hotoo/pangu.vim' 212 | Plug 'easymotion/vim-easymotion' 213 | " https://github.com/dyng/ctrlsf.vim 214 | Plug 'dyng/ctrlsf.vim' 215 | Plug 'terryma/vim-smooth-scroll' " make scrolling in Vim more pleasant 216 | Plug 'tpope/vim-commentary' " quick add comment for code 217 | Plug 'rhysd/clever-f.vim' " Extended f, F, t and T key mappings for Vim 218 | 219 | 220 | if has('mac') || has('macunix') 221 | Plug 'rizzatti/dash.vim' 222 | endif 223 | 224 | call plug#end() " required! 225 | 226 | 227 | " ------------------------------------------------------------------------------- 228 | " Lokaltog/vim-powerline 229 | " ------------------------------------------------------------------------------- 230 | let g:Powerline_symbols = 'unicode' " compatible/unicode/fancy 231 | set laststatus=2 " Always show the statusline 232 | set encoding=utf-8 " Necessary to show Unicode glyphs 233 | set t_Co=256 " Explicitly tell Vim that the terminal supports 256 colors 234 | 235 | 236 | " ------------------------------------------------------------------------------- 237 | " vim-airline/vim-airline 238 | " ------------------------------------------------------------------------------- 239 | " Keep vim-powerline configuration opened 240 | " In Mac with iTerm2, need to select patched font for non-ascii font, in 241 | " Profiles -> Text 242 | let g:airline_powerline_fonts = 1 243 | let g:airline_theme='tomorrow' 244 | 245 | 246 | " ------------------------------------------------------------------------------- 247 | " kien/rainbow_parentheses.vim 248 | " ------------------------------------------------------------------------------- 249 | " always on 250 | if exists(':RainbowParenthesesToggle') 251 | au VimEnter *.py,*.js,*.html,*.css,*.sls RainbowParenthesesToggle 252 | au Syntax *.py,*.js,*.html,*.css,*.sls RainbowParenthesesLoadRound 253 | au Syntax *.py,*.js,*.html,*.css,*.sls RainbowParenthesesLoadSquare 254 | au Syntax *.py,*.js,*.html,*.css,*.sls RainbowParenthesesLoadBraces 255 | endif 256 | 257 | " the outer layer is the last pair 258 | " remove black for dark terminal 259 | let g:rbpt_colorpairs = [ 260 | \ ['brown', 'RoyalBlue3'], 261 | \ ['darkblue', 'SeaGreen3'], 262 | \ ['darkgray', 'DarkOrchid3'], 263 | \ ['darkgreen', 'firebrick3'], 264 | \ ['darkcyan', 'RoyalBlue3'], 265 | \ ['darkred', 'SeaGreen3'], 266 | \ ['darkmagenta', 'DarkOrchid3'], 267 | \ ['brown', 'firebrick3'], 268 | \ ['gray', 'RoyalBlue3'], 269 | \ ['darkred', 'DarkOrchid3'], 270 | \ ['darkmagenta', 'DarkOrchid3'], 271 | \ ['darkblue', 'firebrick3'], 272 | \ ['darkgreen', 'RoyalBlue3'], 273 | \ ['darkcyan', 'SeaGreen3'], 274 | \ ['red', 'firebrick3'], 275 | \ ] 276 | let g:rbpt_max = 15 277 | 278 | " ------------------------------------------------------------------------------- 279 | " Yggdroot/indentLine 280 | " ------------------------------------------------------------------------------- 281 | " https://github.com/Yggdroot/indentLine 282 | " let g:indentLine_char='┆' 283 | " let g:indentLine_enabled = 1 284 | 285 | " ------------------------------------------------------------------------------- 286 | " w0rp/ale 287 | " ------------------------------------------------------------------------------- 288 | let b:ale_linters = ['flake8', 'shellcheck'] 289 | let g:ale_lint_on_text_changed = 'never' 290 | let g:airline#extensions#ale#enabled = 1 291 | let g:ale_echo_msg_error_str = 'E' 292 | let g:ale_echo_msg_warning_str = 'W' 293 | let g:ale_echo_msg_format = '[%linter%] %s [%code%]' 294 | nmap (ale_previous_wrap) 295 | nmap (ale_next_wrap) 296 | 297 | " ------------------------------------------------------------------------------- 298 | " davidhalter/jedi-vim 299 | " ------------------------------------------------------------------------------- 300 | " Goto assignments g (typical goto function) 301 | " Goto definitions d (follow identifier as far as possible, includes 302 | " imports and statements) 303 | " Show Documentation/Pydoc K (shows a popup with assignments) 304 | " Renaming r 305 | " Usages n (shows all the usages of a name) 306 | " Open module, e.g. :Pyimport os (opens the os module) 307 | autocmd FileType python setlocal completeopt-=preview " disable docstring 308 | let g:jedi#completions_command = "" 309 | 310 | " ------------------------------------------------------------------------------- 311 | " nvie/vim-flake8 312 | " ------------------------------------------------------------------------------- 313 | autocmd FileType python map :call Flake8() 314 | let g:flake8_quickfix_height=5 315 | let g:flake8_show_in_gutter=1 316 | highlight link Flake8_Error Error 317 | highlight link Flake8_Warning WarningMsg 318 | highlight link Flake8_Complexity WarningMsg 319 | highlight link Flake8_Naming WarningMsg 320 | highlight link Flake8_PyFlake WarningMsg 321 | "autocmd BufWritePost *.py call Flake8() 322 | 323 | " ---------------------------------------------------------------------------- 324 | " mattn/emmet-vim 325 | " ---------------------------------------------------------------------------- 326 | " trigger key: , " note with comma 327 | " html:5 328 | " n: next edit point 329 | " N: previous edit point 330 | " d: select whole label 331 | " D: select whole label content 332 | " k: delete current label 333 | 334 | 335 | " ---------------------------------------------------------------------------- 336 | " hail2u/vim-css3-syntax 337 | " ---------------------------------------------------------------------------- 338 | augroup VimCSS3Syntax 339 | autocmd! 340 | 341 | autocmd FileType css setlocal iskeyword+=- 342 | augroup END 343 | 344 | " ---------------------------------------------------------------------------- 345 | " ternjs/tern_for_vim 346 | " ---------------------------------------------------------------------------- 347 | let tern_show_signature_in_pum = 1 348 | let tern_show_argument_hints = 'on_hold' 349 | autocmd FileType javascript nnoremap d :TernDef 350 | autocmd FileType javascript setlocal omnifunc=tern#Complete 351 | " 352 | " ---------------------------------------------------------------------------- 353 | " Shutnik/jshint2.vim 354 | " ---------------------------------------------------------------------------- 355 | let jshint2_save = 1 356 | " jshint validation 357 | nnoremap j :JSHint 358 | 359 | " ---------------------------------------------------------------------------- 360 | " plasticboy/vim-markdown 361 | " https://github.com/plasticboy/vim-markdown 362 | " ---------------------------------------------------------------------------- 363 | let g:vim_markdown_folding_style_pythonic = 1 364 | let g:vim_markdown_folding_level = 3 365 | let g:vim_markdown_frontmatter = 1 366 | let g:vim_markdown_toc_autofit = 1 367 | let g:vim_markdown_conceal = 0 " do not conceal fenced code tag 368 | 369 | " ---------------------------------------------------------------------------- 370 | " scrooloose/nerdtree and jistr/vim-nerdtree-tabs 371 | " ---------------------------------------------------------------------------- 372 | "nmap ne :NERDTreeToggle 373 | nmap ne :NERDTreeTabsToggle 374 | " open golang file with nerdtree, and auto switch panel to main panel 375 | " https://vi.stackexchange.com/a/16000 376 | autocmd vimEnter *.go NERDTree | wincmd w 377 | let g:NERDTreeDirArrowExpandable='▷' 378 | let g:NERDTreeDirArrowCollapsible='▼' 379 | 380 | " ---------------------------------------------------------------------------- 381 | " ervandew/supertab 382 | " ---------------------------------------------------------------------------- 383 | set completeopt=longest,menu,preview 384 | let g:SuperTabDefaultCompletionType = "" " use omni completion instead of default 385 | let g:SuperTabCrMapping = 1 " disable with newline, https://github.com/ervandew/supertab/issues/142 386 | 387 | " ---------------------------------------------------------------------------- 388 | " Shougo/neocomplete.vim 389 | " ---------------------------------------------------------------------------- 390 | " Disable AutoComplPop. 391 | let g:acp_enableAtStartup = 0 392 | " Use neocomplete. 393 | let g:neocomplete#enable_at_startup = 1 394 | " Use smartcase. 395 | let g:neocomplete#enable_smart_case = 1 396 | " Set minimum syntax keyword length. 397 | let g:neocomplete#sources#syntax#min_keyword_length = 3 398 | let g:neocomplete#lock_buffer_name_pattern = '\*ku\*' 399 | 400 | " Define dictionary. 401 | let g:neocomplete#sources#dictionary#dictionaries = { 402 | \ 'default' : '', 403 | \ 'vimshell' : $HOME.'/.vimshell_hist', 404 | \ 'scheme' : $HOME.'/.gosh_completions' 405 | \ } 406 | 407 | " Define keyword. 408 | if !exists('g:neocomplete#keyword_patterns') 409 | let g:neocomplete#keyword_patterns = {} 410 | endif 411 | let g:neocomplete#keyword_patterns['default'] = '\h\w*' 412 | 413 | " Plugin key-mappings. 414 | inoremap neocomplete#undo_completion() 415 | inoremap neocomplete#complete_common_string() 416 | 417 | " Recommended key-mappings. 418 | " : completion. 419 | inoremap pumvisible() ? "\" : "\" 420 | " , : close popup and delete backword char. 421 | inoremap neocomplete#smart_close_popup()."\" 422 | inoremap neocomplete#smart_close_popup()."\" 423 | " Close popup by . 424 | "inoremap pumvisible() ? "\" : "\" 425 | 426 | " AutoComplPop like behavior. 427 | let g:neocomplete#enable_auto_select = 1 428 | 429 | " Enable omni completion. 430 | autocmd FileType css setlocal omnifunc=csscomplete#CompleteCSS 431 | autocmd FileType html,markdown setlocal omnifunc=htmlcomplete#CompleteTags 432 | autocmd FileType javascript setlocal omnifunc=tern#Complete " for ternjs 433 | autocmd FileType python setlocal omnifunc=jedi#completions " for jedi 434 | autocmd FileType xml setlocal omnifunc=xmlcomplete#CompleteTags 435 | 436 | " Enable heavy omni completion. 437 | if !exists('g:neocomplete#sources#omni#input_patterns') 438 | let g:neocomplete#sources#omni#input_patterns = {} 439 | endif 440 | 441 | " ---------------------------------------------------------------------------- 442 | " Valloric/YouCompleteMe 443 | " ---------------------------------------------------------------------------- 444 | let g:ycm_seed_identifiers_with_syntax = 1 445 | let g:ycm_complete_in_comments = 0 446 | let g:ycm_complete_in_strings = 0 447 | let g:ycm_key_list_select_completion = ['', ''] 448 | let g:ycm_key_list_previous_completion = ['', ''] 449 | nnoremap :YcmCompleter GoToDefinitionElseDeclaration| 450 | let g:ycm_min_num_of_chars_for_completion=2 451 | 452 | " ---------------------------------------------------------------------------- 453 | " SirVer/ultisnips 454 | " ---------------------------------------------------------------------------- 455 | " Trigger configuration. Do not use if you use https://github.com/Valloric/YouCompleteMe. 456 | let g:UltiSnipsExpandTrigger="" 457 | let g:UltiSnipsJumpForwardTrigger="" 458 | let g:UltiSnipsJumpBackwardTrigger="" 459 | 460 | " If you want :UltiSnipsEdit to split your window. 461 | let g:UltiSnipsEditSplit="vertical" 462 | 463 | " ---------------------------------------------------------------------------- 464 | " Tagbar 465 | " ---------------------------------------------------------------------------- 466 | nmap :TagbarToggle 467 | map tb :TagbarToggle 468 | let g:tagbar_sort = 0 469 | 470 | "let g:tagbar_type_markdown = { 471 | " \ 'ctagstype': 'markdown', 472 | " \ 'ctagsbin' : '/Users/TankyWoo/.dotfiles/markdown2ctags.py', 473 | " \ 'ctagsargs' : '-f - --sort=yes', 474 | " \ 'kinds' : [ 475 | " \ 's:sections', 476 | " \ 'i:images' 477 | " \ ], 478 | " \ 'sro' : '|', 479 | " \ 'kind2scope' : { 480 | " \ 's' : 'section', 481 | " \ }, 482 | " \ 'sort': 0, 483 | "\ } 484 | 485 | " ---------------------------------------------------------------------------- 486 | " airblade/vim-gitgutter 487 | " ---------------------------------------------------------------------------- 488 | let g:gitgutter_max_signs = 500 489 | "let g:gitgutter_highlight_lines = 1 490 | highlight clear SignColumn 491 | 492 | " ---------------------------------------------------------------------------- 493 | " SirVer/ultisnips 494 | " ---------------------------------------------------------------------------- 495 | " Trigger configuration. Do not use if you use https://github.com/Valloric/YouCompleteMe. 496 | "let g:UltiSnipsExpandTrigger="" 497 | "let g:UltiSnipsJumpForwardTrigger="" 498 | "let g:UltiSnipsJumpBackwardTrigger="" 499 | 500 | " ---------------------------------------------------------------------------- 501 | " rizzatti/dash.vim 502 | " ---------------------------------------------------------------------------- 503 | " https://raw.githubusercontent.com/rizzatti/dash.vim/master/doc/dash.txt 504 | let g:dash_map = { 505 | \ 'python' : ['py', 'python2', 'py3', 'python3'] 506 | \ } 507 | nmap da DashSearch 508 | 509 | " ---------------------------------------------------------------------------- 510 | " godlygeek/tabular 511 | " ---------------------------------------------------------------------------- 512 | " use `Tab /|` to auto align '|' 513 | 514 | " ---------------------------------------------------------------------------- 515 | " hotoo/pangu.vim 516 | " https://github.com/hotoo/pangu.vim 517 | " ---------------------------------------------------------------------------- 518 | "autocmd BufWritePre *.markdown,*.md call PanGuSpacing() 519 | 520 | " ---------------------------------------------------------------------------- 521 | " easymotion/vim-easymotion 522 | " https://github.com/easymotion/vim-easymotion 523 | " ---------------------------------------------------------------------------- 524 | " f{char} to move to {char} 525 | map f (easymotion-bd-f) 526 | nmap f (easymotion-overwin-f) 527 | 528 | " s{char}{char} to move to {char}{char} 529 | nmap s (easymotion-overwin-f2) 530 | 531 | " Move to line 532 | map L (easymotion-bd-jk) 533 | nmap L (easymotion-overwin-line) 534 | 535 | " Move to word 536 | map w (easymotion-bd-w) 537 | nmap w (easymotion-overwin-w) 538 | 539 | " ---------------------------------------------------------------------------- 540 | " dyng/ctrlsf.vim 541 | " https://github.com/dyng/ctrlsf.vim 542 | " ---------------------------------------------------------------------------- 543 | nmap f CtrlSFPrompt 544 | "vmap f CtrlSFVwordPath 545 | vmap f CtrlSFVwordExec 546 | nmap n CtrlSFCwordPath 547 | "nmap p CtrlSFPwordPath 548 | nnoremap o :CtrlSFOpen 549 | nnoremap t :CtrlSFToggle 550 | inoremap t :CtrlSFToggle 551 | let g:ctrlsf_search_mode = 'async' " vim >= 8.0 552 | " let g:ctrlsf_winsize = '40%' 553 | 554 | " ---------------------------------------------------------------------------- 555 | " terryma/vim-smooth-scroll 556 | " https://github.com/terryma/vim-smooth-scroll 557 | " ---------------------------------------------------------------------------- 558 | noremap :call smooth_scroll#up(&scroll, 0, 2) 559 | noremap :call smooth_scroll#down(&scroll, 0, 2) 560 | 561 | " ---------------------------------------------------------------------------- 562 | " tpope/vim-commentary 563 | " https://github.com/tpope/vim-commentary 564 | " usage: 565 | " - gcc: comment current line 566 | " - gc: in visual mode, comment selection 567 | " - gcap: auto comment paragraph 568 | " ---------------------------------------------------------------------------- 569 | 570 | " ---------------------------------------------------------------------------- 571 | " rhysd/clever-f.vim 572 | " https://github.com/rhysd/clever-f.vim 573 | " ---------------------------------------------------------------------------- 574 | " enable thus plugin cause `;' and `,' disabled by defaults, so reopen it. 575 | map ; (clever-f-repeat-forward) 576 | map , (clever-f-repeat-back) 577 | 578 | 579 | " =============================================================================== 580 | " Color Settings 581 | " =============================================================================== 582 | " test color with run `:runtime syntax/colortest.vim` 583 | 584 | set t_Co=256 585 | 586 | if exists('+colorcolumn') 587 | " cc is only exist >= `Vim7.3` 588 | set cc=81 " Short for colorcolumn 589 | else 590 | au BufWinEnter * let w:m2=matchadd('ErrorMsg', '\%>80v.\+', -1) 591 | endif 592 | hi ColorColumn ctermbg=lightgrey guibg=lightgrey " Highlighter cc 593 | 594 | try 595 | set background=dark 596 | colorscheme Tomorrow-Night-Bright 597 | hi LineNr ctermfg=darkgreen 598 | hi CursorLineNr cterm=bold ctermfg=yellow 599 | " Below syntax will affect vim-airline statusbar; write colorscheme 600 | " directly is ok 601 | " autocmd BufEnter * colorscheme Tomorrow-Night-Bright 602 | autocmd BufEnter *.md,*.mkd,*.markdown colorscheme badwolf 603 | catch /^Vim\%((\a\+)\)\=:E185/ 604 | colorscheme desert 605 | endtry 606 | 607 | " for gui, such as macvim 608 | if has("gui_running") 609 | "set guifont=Monaco:h12 610 | set guifont=Source\ Code\ Pro\ for\ Powerline:h12 " for vim-airline 611 | set gcr=a:blinkon0 "Disable cursor blink 612 | set lines=60 613 | set columns=150 614 | endif 615 | 616 | " Highlight TODO/FIXME/XXX 617 | highlight myTODO cterm=bold term=bold ctermbg=yellow ctermfg=black 618 | match myTODO /\(TODO\|XXX\|FIXME\)/ 619 | 620 | " this options can be setted with colors, and must be put after colorscheme 621 | set cursorline " Highlighter the current line 622 | set cursorcolumn " Highlighter the vertical line" 623 | hi search cterm=underline ctermfg=white 624 | 625 | highlight PmenuSel cterm=underline,bold ctermfg=blue 626 | -------------------------------------------------------------------------------- /zsh/tanky.zsh-theme: -------------------------------------------------------------------------------- 1 | # changed from philips.zsh-theme 2 | 3 | if [ $UID -eq 0 ]; then NCOLOR="red"; else NCOLOR="blue"; fi 4 | 5 | PS1_PRE='' 6 | PS1_BOLD_PRE="false" 7 | if [ -n "${PS1_ENABLE_USERNAME}" ] && [ "${PS1_ENABLE_USERNAME}" = true ]; then 8 | PS1_PRE=${PS1_PRE}'%n' 9 | fi 10 | if [ -n "${PS1_ENABLE_HOSTNAME}" ] && [ "${PS1_ENABLE_HOSTNAME}" = true ]; then 11 | PS1_PRE=${PS1_PRE}'@%m' 12 | fi 13 | if [ -n "${PS1_BOLD_PRE}" ] && [ "${PS1_BOLD_PRE}" = true ]; then 14 | PS1_PRE='%B'${PS1_PRE}'%b' 15 | fi 16 | if [ -n "${PS1_PRE}" ]; then 17 | PS1_PRE=${PS1_PRE}' ' # add a space between username and path 18 | fi 19 | 20 | # use $FG, not $fg, for 256 color 21 | #PROMPT='%{$fg[$NCOLOR]%}'${PS1_PRE}'%{$reset_color%}%{$fg[green]%}%~%{$reset_color%} $(git_prompt_info)%{$fg[blue]%}%%%{$reset_color%} ' 22 | PROMPT='%{$fg[$NCOLOR]%}'${PS1_PRE}'%{$reset_color%}%{$FG[077]%}%~%{$reset_color%} $(git_prompt_info)%{$fg[blue]%}%%%{$reset_color%} ' 23 | 24 | 25 | # git theming 26 | ZSH_THEME_GIT_PROMPT_PREFIX="%{$fg_bold[blue]%}(%{$fg_no_bold[yellow]%}%B" 27 | ZSH_THEME_GIT_PROMPT_SUFFIX="%b%{$fg_bold[blue]%})%{$reset_color%} " 28 | ZSH_THEME_GIT_PROMPT_CLEAN="" 29 | ZSH_THEME_GIT_PROMPT_DIRTY="%{$fg_bold[red]%}*" 30 | 31 | # LS colors, made with http://geoff.greer.fm/lscolors/ 32 | export LSCOLORS="Gxfxcxdxbxegedabagacad" 33 | export LS_COLORS='no=00:fi=00:di=01;34:ln=00;36:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=41;33;01:ex=00;32:*.dll=01;32:*.tar=00;31:*.tbz=00;31:*.tgz=00;31:*.rpm=00;31:*.deb=00;31:*.zip=00;31:*.z=00;31:*.Z=00;31:*.gz=00;31:*.bz2=00;31:*.bmp=01;35:*.gif=01;35:*.jpg=01;35:*.jpeg=01;35:*.png=01;35:' 34 | 35 | # custom 36 | export LS_COLORS="${LS_COLORS}*.md=00;33:*.py=00;35:*.pyc=00;37:*.rb=00;36:" 37 | -------------------------------------------------------------------------------- /zsh/zshrc: -------------------------------------------------------------------------------- 1 | # Use the default config, them overwrite it. 2 | . ~/.oh-my-zsh/templates/zshrc.zsh-template 3 | 4 | ZSH_THEME="tanky" 5 | DISABLE_CORRECTION="true" 6 | DISABLE_AUTO_TITLE="true" 7 | DISABLE_AUTO_UPDATE="true" 8 | 9 | PS1_ENABLE_USERNAME="true" 10 | PS1_ENABLE_HOSTNAME="false" 11 | PS1_BOLD_PRE="false" 12 | 13 | # tmuxinator is completion script almost like offical 14 | plugins=(git svn python colored-man-pages tmux git-flow autojump tmuxinator web-search golang zsh-autosuggestions zsh-completions) 15 | 16 | ZSH_AUTOSUGGEST_HIGHLIGHT_STYLE="fg=66,underline" 17 | 18 | # TODO, get path by command 19 | WORK_DIR="$HOME/.dotfiles/" 20 | PRE_CUSTOM="${WORK_DIR}/custom/pre_custom.zsh" 21 | if [ -e "${PRE_CUSTOM}" ]; then 22 | source ${PRE_CUSTOM} 23 | fi 24 | 25 | ZSH=$HOME/.oh-my-zsh 26 | source $ZSH/oh-my-zsh.sh 27 | 28 | if [[ "$SHELL" == `which zsh 2>/dev/null` ]]; then 29 | # disable zsh default glob. 30 | # such cause all glob and expansion controlled by zsh 31 | unsetopt nomatch 32 | unsetopt nullglob # default is not set 33 | setopt glob # default is set 34 | fi 35 | 36 | source ~/.common/exports.sh 37 | source ~/.common/aliases.sh 38 | source ~/.common/functions.sh 39 | 40 | source ~/.common/python.sh 41 | source ~/.common/golang.sh 42 | 43 | source ~/.common/quickjump.sh 44 | source ~/.common/virtualenvwrapper.sh 45 | source ~/.common/ssh-agent-wrapper.sh 46 | 47 | source ~/.common/other.sh 48 | 49 | POST_CUSTOM="${WORK_DIR}/custom/post_custom.zsh" 50 | if [ -e "${POST_CUSTOM}" ]; then 51 | source ${POST_CUSTOM} 52 | fi 53 | 54 | # compat with bash/zsh 55 | if [ -d ${HOME}/.custom ]; then 56 | custom_sh=( $( find ${HOME}/.custom -name '*.sh' ) ) 57 | if [ ${#custom_sh[@]} -gt 0 ]; then 58 | for sf in "${custom_sh[@]}"; do 59 | source $sf 60 | done 61 | fi 62 | fi 63 | 64 | # 65 | # find key code: 66 | # - `showkey -a` 67 | # - `cat`, ref 68 | # 69 | # bind keys: 70 | # - ctrl + n : accept current suggestion 71 | # - ctrl + alt + t : toggle zsh-autosuggestions plugin 72 | # 73 | # 74 | 75 | # enable vi mode 76 | #bindkey -v 77 | 78 | # ctrl + n : accept current suggestion 79 | bindkey '^N' autosuggest-accept 80 | 81 | # ctrl + alt + t : toggle zsh-autosuggestions plugin 82 | bindkey '^[^T' autosuggest-toggle 83 | --------------------------------------------------------------------------------