Setting up vim

" You need to import default vim settings first, e.g. syntax highlighting, etc.
source $VIMRUNTIME/defaults.vi

" Set non visual mode when mouse is dragging on vim
set mouse-=a

" set 1 tab == 4 spaces..
filetype plugin indent on
" show existing tab with 4 spaces width
set tabstop=4
" when indenting with '>', use 4 spaces width
set shiftwidth=4
" On pressing tab, insert 4 spaces
set expandtab

run .bashrc at .bash_profile time

if [ -f $HOME/.bashrc ]; then
        source $HOME/.bashrc
fi

Highlight for git branch name

  • Find git-prompt.sh from official git repo
  • Setup code example
source ~/.git-prompt.sh
PS1='[\u@\h \W$(__git_ps1 " \[\033[32m\](%s)\[\033[00m\]")]\$ '

Double Pinyin (双拼)

  1. 使用Ctrl + space来改变输入法。 Use Ctrl + space to change input source..

  2. 使用Karabiner来把Shift键映射为Ctrl + space。Use Karabiner to support using Shift to switch between input sources.

    • 以下为映射代码 (需要放在~/.config/karabiner/karabiner.json,可能需要先做Karabiner UI里面先映射一个simple modification,然后karabiner.json文件才会被创建。)Code to do that (to be put in ~/.config/karabiner/karabiner.json, you may need to set a simple modification first in Karabiner UI, then do this).
    • 更改文件中 complex_modifications => rules 的内容。You need to change the complex_modifications => rules as follows:
                      "rules": [
                       {
                        "manipulators": [
                            {
                                "description": "Change left_shift to control+space when used alone",
                                "from": {
                                    "key_code": "left_shift",
                                    "modifiers": {
                                        "optional": [
                                            "any"
                                        ]
                                    }
                                },
                                "to": [
                                    {
                                        "key_code": "left_shift"
                                    }
                                ],
                                "to_if_alone": [
                                    {
                                        "key_code": "spacebar",
                                        "modifiers": [
                                            "left_control"
                                        ]
                                    }
                                ],
                                "type": "basic"
                            }
                        ]
                    }
                ]