Skip to content

ctjoy/dotfiles

Repository files navigation

My Dotfiles

Just keep my dotfiles and notes in one place. I use master branch for generic setting. For machine-specific configuration, is located in different branch. This dotfile is powered by Dotbot.

A fresh macOS setup

Before you re-install

First, go through the checklist below to make sure you didn't forget anything before you wipe your hard drive.

  • Did you commit and push any changes/branches to your git repositories?
  • Did you remember to save all important documents from non-iCloud directories?
  • Did you save all of your work from apps which aren't synced through iCloud?
  • Did you remember to export important data from your local database?

Setting up your Mac

If you did all of the above you may now follow these install instructions to setup a new Mac.

  • Update macOS to the latest version with the App Store
  • Install macOS Command Line Tools by running xcode-select --install
  • Generate a new public and private SSH key and add them to Github
  • Clone this repo to ~/.dotfiles
  • Run install to start the installation
  • Restart your computer to finalize the process

Your Mac is now ready to use!

For daily update

  • Check out to the machine-specific branch
  • Comment out the command you don't want in install.conf.yaml
  • Run install

Branch Hierarchy

```
master
|
+- mac
```

Shell

.bashrc vs .bash_profile

這兩者的差別在於系統上認定有無登入會選擇其中一種來初始化 bash,不同系統會有不同作法,我的設定是如果系統要 load bash_profile 就把它轉到 bashrc,這樣只要設定好 bashrc 就好,bashrc 和 bash_profile 差別可參考別人的回覆

aliases

  • extract: 解壓縮後面接的檔案
  • mkd: 創建資料夾且進入

tmux

  • ltm: 如果有 tmux session 就 attach,如果沒有就新開一個 (lazy tmux)
  • tml: tmux ls
  • tma: tmux attach-session
  • tmk: tmux kill-session
  • tmc: clear tmux stuff
  • tmna: rename session

color

Tmux

指令

  • <C-a>: prefix

需要加 prefix

  • d: detach 目前的 session
  • ,: rename 目前的 window
  • number: 跳到那個 number 的 window
  • c: 開啟新的 window (create)
  • n: 跳到下一個 window (next)
  • p: 跳到上一個 window (previous)
  • r: 重新 load tmux.conf (reload)
  • |: split window h
  • _: split window v
  • H: resize left
  • K: resize down
  • J: resize up
  • L: resize right
  • <hjkl>: pane 上下左右跳

用 ssh 時會有 nested tmux 的狀況

  • <S-Up>: 轉到 ssh 的 tmux
  • <S-Down>: 轉回 local 的 tmux

Vim

好東西

外掛列表

Appearance

Easy editing

Syntax color and indent

指令

以下只記錄自訂指令與外掛指令。

自訂指令

可搭配 vimrc 一起看會比較清楚

<Leader> = ,

  • <Leader>w = :w!
  • jk = <Esc> (跳回 normal mode)
  • 9 = $ (跳到此行的最後一個字)
  • 0 = ^ (跳到此行的第一個字)
  • <Leader>dw: 把白色空白刪掉 (delete whitespace)
windows and buffers

我目前把 buffer 當 tab 在用

  • <C-hjkl> window 上下左右跳
  • <Tab> 跳下一個 buffer
  • <Shift-Tab> 跳上一個 buffer
  • <Leader>t 開一個新的 buffer
  • <Leader>q 關掉目前所在 buffer

外掛指令

t comment

  • <Leader>c 註解選擇的範圍

NerdTree

  • <Leader>n 開關 NerdTree
  • o 在 NerdTree 底下開啟檔案或開關目錄
  • I 顯示隱藏被隱藏的檔案與目錄
  • u 跳到上一個目錄

EasyMotion

  • <Space>f『目標』 用 EasyMotion 找『目標』
  • <Space>w 用 EasyMotion 找字
  • <Space>j 用 EasyMotion 往下面行跳
  • <Space>k 用 EasyMotion 往上面行跳

vim surround

  • ysiw) 在所在字上加 () 號,例如;hello -> (hello) ( yield surround inside word )
  • yss) 在所在行加 () 號
  • S) 在 visual mode 下輸入,可在選取的字旁加 ()

CtrlP

  • ; 開啟 ctrlp 模糊查詢
Once CtrlP is open:
  • Press <Ctrl-f> and <Ctrl-b> to cycle between modes.
  • Use <Ctrl-j>, <Ctrl-k> or the arrow keys to navigate the result list.
  • Use <Ctrl-t> or <Ctrl-v>, <Ctrl-x> to open the selected entry in a new tab or in a new split.

vim gitgutter

  • [c 跳到上一個 hunk
  • ]c 跳到下一個 hunk
  • <Leader>hp preview a hunk's changes
  • <Leader>hs stage a hunk
  • <Leader>hu undo a hunk

gundo

  • <Leader>u 開啟 gundo

Pangu

  • :Pangu 中文排版

vim prettier

  • <Leader>p format file

vim vista

  • <Leader>v show functions and tags

vim signature

  • mx Toggle mark 'x' and display it in the leftmost column
  • dmx Remove mark 'x' where x is a-zA-Z
  • m, Place the next available mark
  • m<Space> Delete all marks from the current buffer
  • m<BS> Remove all markers
  • ]' Jump to start of next line containing a mark
  • [' Jump to start of prev line containing a mark
  • m/ Open location list and display marks from current buffer

Special thanks to

Releases

No releases published

Packages

No packages published