Mac OS 開發環境 Terminal 配置
來源:互聯網
上載者:User
這是一個建立於 的文章,其中的資訊可能已經有所發展或是發生改變。Mac OS 開發環境 Terminal 配置---[TOC]### Terminal 主題選擇Mac OS 內建主題已經很不錯很好看,如果不滿意系統內建主題,可以自訂配置。這裡推薦下面的設定檔,下載下來,直接匯入就好。[https://github.com/chriskempson/tomorrow-theme](https://github.com/chriskempson/tomorrow-theme)### Vim 配置.vimrc```$ touch ~/.vimrc```配置內容如下:```syntax on " 自動文法高亮"colorscheme molokai " 設定色彩配置"set nocompatible " 關閉 vi 相容模式set number " 顯示行號"set cursorline " 反白當前行set ruler " 開啟狀態列尺規set shiftwidth=4 " 設定 << 和 >> 命令移動時的寬度為 4set softtabstop=4 " 使得按退格鍵時可以一次刪掉 4 個空格set tabstop=4 " 設定 tab 長度為 4set nobackup " 覆蓋檔案時不備份set autochdir " 自動切換目前的目錄為當前檔案所在的目錄set nocompatible " be iMproved, requiredfiletype off " required" 以下內容配置 vim 中粘帖代碼重複縮排問題if &term =~ "xterm.*" let &t_ti = &t_ti . "\e[?2004h" let &t_te = "\e[?2004l" . &t_te function XTermPasteBegin(ret) set pastetoggle=<Esc>[201~ set paste return a:ret endfunction map <expr> <Esc>[200~ XTermPasteBegin("i") imap <expr> <Esc>[200~ XTermPasteBegin("") cmap <Esc>[200~ <nop> cmap <Esc>[201~ <nop>endif```### Tmux 神器Tmux 安裝```brew install tmux```Tmux 配置```$ vim ~/.tmux.conf# Sets prefix globally# Reload tmux.confbind-key r source-file ~/.tmux.conf \; display-message "~/.tmux.conf reloaded"# improve colorsset-option -g default-terminal "screen-256color"# Set prompt behavior like emacsset-option -g status-keys "emacs"# window statussetw -g window-status-format " #F#I:#W#F "setw -g window-status-current-format " #F#I:#W#F "setw -g window-status-format "#[fg=magenta]#[bg=black] #I #[bg=cyan]#[fg=colour8] #W "setw -g window-status-current-format "#[bg=brightmagenta]#[fg=colour8] #I #[fg=colour8]#[bg=colour14] #W "setw -g window-status-current-bg colour0setw -g window-status-current-fg colour11setw -g window-status-current-attr dimsetw -g window-status-bg greensetw -g window-status-fg blacksetw -g window-status-attr reverse# panal themeset -g pane-border-bg colour0set -g pane-border-fg colour236set -g pane-active-border-bg colour0set -g pane-active-border-fg colour55# Show session name in the status left, empty status rightset -g status-position bottomset -g status-bg colour0set -g status-fg colour137set -g status-attr dimset -g status-left-length 50set -g status-left '#[fg=magenta]#[fg=colour233,bg=colour245,bold] %H:%M:%S #[default]'set -g status-right-length 50set -g status-right '#[fg=colour233,bg=colour241,bold] %d/%m/%Y'setw -g window-status-current-fg colour81setw -g window-status-current-bg colour56setw -g window-status-current-attr boldsetw -g window-status-current-format ' #I#[fg=colour250]:#[fg=colour255]#W#[fg=colour50]#F 'setw -g window-status-fg colour138setw -g window-status-bg colour235setw -g window-status-attr nonesetw -g window-status-format ' #I#[fg=colour237]:#[fg=colour250]#W#[fg=colour244]#F 'setw -g window-status-bell-attr boldsetw -g window-status-bell-fg colour255setw -g window-status-bell-bg colour1# More intuitive panes split and remember current pathbind-key - split-window -v -c '#{pane_current_path}'bind-key \ split-window -h -c '#{pane_current_path}'# Smart pane switching with awareness of vim splits# See: https://github.com/christoomey/vim-tmux-navigatoris_vim='echo "#{pane_current_command}" | grep -iqE "(^|\/)g?(view|n?vim?x?)(diff)?$"'bind -n C-h if-shell "$is_vim" "send-keys C-h" "select-pane -L"bind -n C-j if-shell "$is_vim" "send-keys C-j" "select-pane -D"bind -n C-k if-shell "$is_vim" "send-keys C-k" "select-pane -U"bind -n C-l if-shell "$is_vim" "send-keys C-l" "select-pane -R"bind -n C-\ if-shell "$is_vim" "send-keys C-\\" "select-pane -l"# Resize panes using shift keybind -n S-Left resize-pane -L 2bind -n S-Right resize-pane -R 2bind -n S-Down resize-pane -D 1bind -n S-Up resize-pane -U 1# Remember current patch when creating new windowbind c new-window -c '#{pane_current_path}'# Set base-index to 1 (useful for switching between windows)set-option -g base-index 1set-option -g renumber-windows on# Set break-pane and detach (-d) while keeping focus on current windowbind-key b break-pane -d# Easily go to tmux choose-tree to navigate between sessionsbind-key C-j choose-tree# enable mouse optionset-option -g mouse on# open copy with vi modesetw -g mode-keys vi# buffer緩衝複製到Mac系統粘貼板bind C-c run "tmux save-buffer - | reattach-to-user-namespace pbcopy"# Mac系統粘貼板內容複寫到會話bind C-v run "reattach-to-user-namespace pbpaste | tmux load-buffer - \; paste-buffer -d"# 綁定y鍵為複製選中文本到Mac系統粘貼板bind-key -T copy-mode-vi 'y' send-keys -X copy-pipe-and-cancel 'reattach-to-user-namespace pbcopy'# 滑鼠拖動選中文本,並複製到Mac系統粘貼板bind-key -T copy-mode-vi MouseDragEnd1Pane send -X copy-pipe-and-cancel "pbcopy"```### Tmux 操作下面所有的prefix均代表CTRL+bSession相關操作| 操作 | 快速鍵 || ----------------- | -------- || 查看/切換session | prefix s || 離開Session | prefix d || 重新命名當前Session | prefix $ |Window相關操作| 操作 | 快速鍵 || ------------------ | ------------- || 建立視窗 | prefix c || 切換到上一個活動的視窗 | prefix space || 關閉一個視窗 | prefix & || 使用視窗號切 | prefix 視窗號 |Pane相關操作| 操作 | 快速鍵 || ------------------ | --------- || 切換到下一個窗格 | prefix o || 查看所有窗格的編號 | prefix q || 垂直分割出一個新窗格 | prefix “ || 水平分割出一個新窗格 | prefix % || 暫時把一個表單放到最大 | prefix z |284 次點擊