Skip to content

Instantly share code, notes, and snippets.

@dannyh79

dannyh79/.tmux.conf Secret

Last active Nov 26, 2020
Embed
What would you like to do?
20201104
# dannyh79's .tmux.conf (2020-03-29 21:37:09 +0800)
# You can reach me on https://github.com/dannyh79/
# Enjoy :)
# -----------------------------
# Global settings
# -----------------------------
#
# **enable copy-paste in tmux session when using iTerm2**
# Preferences > General > Selection >
# tick "Copy to pasteboard on selection"
# tick "Applications in terminal may access clipboard"
# scrollback buffer n lines
set -g history-limit 5000
# listen for activity on all windows
set -g bell-action any
# start window indexing at 1 window so the <prefix> 1 is easier to reach
set -g base-index 1
# control automatic window renaming
setw -g automatic-rename off
# tell tmux to use 256 colour terminal
set -g default-terminal "xterm-256color"
set-option -ga terminal-overrides ",xterm-256color:Tc"
# remove <esc> key press delay
set -sg escape-time 0
# enable mouse mode for tmux
# in pane-switching (via clicking), and
# copy-mode (hold left button, drag then release)
set -g mouse on
# enable vi key-binding for tmux
# in pane-switching and copy-mode
setw -g mode-keys vi
# -----------------------------
# Key bindings
# -----------------------------
#
# remap prefix from 'C-b' to 'C-a'
unbind C-b
set-option -g prefix C-a
bind-key C-a send-prefix
# <prefix> or Ctrl- or <prefix> Ctrl-
# k --- previous pane
# h l --- previous window / next window
# j --- next pane
# vi keys for switching windows
unbind-key l
bind-key h select-window -t :-
bind-key C-h select-window -t :-
bind-key -n C-h select-window -t :-
bind-key l select-window -t :+
bind-key C-l select-window -t :+
bind-key -n C-l select-window -t :+
# vi keys for switching panes
bind-key j select-pane -t :.-
bind-key C-j select-pane -t :.-
bind-key -n C-j select-pane -t :.-
bind-key k select-pane -t :.+
bind-key C-k select-pane -t :.+
bind-key -n C-k select-pane -t :.+
# vi keys for resizing panes
bind-key < resize-pane -L 5
bind-key > resize-pane -R 5
bind-key - resize-pane -D 5
bind-key + resize-pane -U 5
# vi keys for copy & paste in copy-mode
# https://www.rushiagr.com/blog/2016/06/16/everything-you-need-to-know-about-tmux-copy-pasting/
bind P paste-buffer
bind-key -T copy-mode-vi v send-keys -X begin-selection
bind-key -T copy-mode-vi y send-keys -X copy-selection
bind-key -T copy-mode-vi r send-keys -X rectangle-toggle
# -----------------------------
# Plugin Manager- 'tmux-plugins/tpm'
# -----------------------------
#
# Key bindings
#
# prefix + I
# Installs new plugins from GitHub or any other git repository
# Refreshes TMUX environment
# prefix + U
# updates plugin(s)
# prefix + alt + u (not for MacOS users)
# remove/uninstall plugins not on the plugin list
# Installation with my ~/.tmux.conf
# 1. `$ git clone https://github.com/tmux-plugins/tpm ~/.tmux/plugins/tpm`
# 2. Restart tmux or source .tmux.conf: `$ tmux source ~/.tmux.conf`
# List of plugins
set -g @plugin 'tmux-plugins/tpm'
set -g @plugin 'tmux-plugins/tmux-sensible'
set -g @plugin 'tmux-plugins/tmux-resurrect' # persists Tmux sessions
set -g @plugin 'tmux-plugins/tmux-battery' # show battery life on Tmux
# set -g @plugin 'egel/tmux-gruvbox' # gruvbox them for Tmux
# -----------------------------
# Plugin-related Settings
# -----------------------------
#
# 'tmux-plugins/tmux-battery'
#
set -g status-right 'Batt: #{battery_icon} #{battery_percentage} #{battery_remain} | %a %h-%d %H:%M ' # battery status
set -g status-right-length 200 # to not let status-right get cut out
# 'tmux-plugins/tmux-resurrect'
#
# Key bindings
# prefix + Ctrl-s - save
# prefix + Ctrl-r - restore
# prefix + R - source ~/.tmux.conf
# -----------------------------
# Theming Related
# -----------------------------
#
# Tmux status line with gruvbox dark colors.
# Palette: https://github.com/morhetz/gruvbox#palette
# Status bar colors.
set-option -g status-fg colour223 # fg1
set-option -g status-bg colour235 # bg0
# Window list colors.
set-window-option -g window-status-style fg=colour246,bg=colour239
set-window-option -g window-status-current-style fg=colour235,bg=colour246,bright
set-window-option -g window-status-activity-style fg=colour250,bg=colour241
# Pane divider colors.
set-option -g pane-border-style fg=colour239 # bg2
set-option -g pane-border-style bg=colour235 # bg0
set-option -g pane-active-border-style fg=colour142 # brightgreen
set-option -g pane-active-border-style bg=colour235 # bg0
# Command-line messages colors.
set-option -g message-style fg=colour223 # fg1
set-option -g message-style bg=colour235 # bg0
set-option -g message-style bright
# Set left and right sections.
set-option -g status-left-length 20
set-option -g status-left "#[fg=colour235,bg=colour246] #S "
set-option -g status-right "#[fg=colour235,bg=colour246] Batt: #{battery_icon} #{battery_percentage} #{battery_remain} | %a %h-%d %H:%M "
# Set format of items in window list.
setw -g window-status-format " #I:#W#F "
setw -g window-status-current-format " #I:#W#F "
# Set alignment of windows list.
set-option -g status-justify centre
# Identify activity in non-current windows.
set-window-option -g monitor-activity on
set-option -g visual-activity on
# Initialize Tmux plugin manager (keep this line at the very bottom of tmux.conf)
run -b '~/.tmux/plugins/tpm/tpm'
" dannyh79's .vimrc (2020-11-20 17:11:34 +0800)
" You can reach me on https://github.com/dannyh79/
" Enjoy :)
" -----------------------------
" Plugin Manager - 'junegunn/vim-plug'
" -----------------------------
"
" Some common commands in Vim:
" :PlugInstall - Installs plugins
" :PlugUpdate - Updates plugins
" :PlugClean - Cleans unused plugins
" Automatic installation
" https://github.com/junegunn/vim-plug/wiki/tips#automatic-installation
if empty(glob('~/.vim/autoload/plug.vim'))
silent !curl -fLo ~/.vim/autoload/plug.vim --create-dirs
\ https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
autocmd VimEnter * PlugInstall --sync | source $MYVIMRC
endif
" Plugins will be downloaded under the specified directory
call plug#begin('~/.vim/plugged')
" Declare the list of plugins.
" Themes
Plug 'morhetz/gruvbox'
Plug 'drewtempelmeyer/palenight.vim'
Plug 'artanikin/vim-synthwave84'
Plug 'troyfletcher/vim-colors-synthwave'
Plug 'arcticicestudio/nord-vim'
Plug 'nlknguyen/papercolor-theme'
Plug 'ayu-theme/ayu-vim'
Plug 'ghifarit53/tokyonight-vim'
Plug 'scrooloose/nerdtree' " File explorer
Plug 'jiangmiao/auto-pairs' " Auto-pairing in Vim
Plug 'scrooloose/nerdcommenter' " Commenter
Plug 'tpope/vim-fugitive' " Git version control
Plug 'airblade/vim-gitgutter' " Git status in Vim
Plug 'xuyuanp/nerdtree-git-plugin' " Git status in NERDtree
Plug 'ryanoasis/vim-devicons'
Plug 'junegunn/fzf', { 'do': { -> fzf#install() } }
Plug 'junegunn/fzf.vim'
Plug 'vim-airline/vim-airline'
Plug 'vim-airline/vim-airline-themes'
Plug 'junegunn/goyo.vim' " Writing in Vim
Plug 'junegunn/limelight.vim' " Focus-writing in Vim
" 20191222
Plug 'yggdroot/indentline'
Plug 'tpope/vim-surround'
" 20191227
Plug 'tadaa/vimade' " Dims inactive panes
" 20200124
Plug 'dense-analysis/ale' " Linter - Asynchronous Lint Engine
" 20200229
Plug 'dhruvasagar/vim-marp' " Markdown presenter in Vim
" 20200229
Plug 'tpope/vim-dispatch'
" Languages-specfic Plugins
Plug 'elixir-lang/vim-elixir', {'for': ['ex', 'exs']}
Plug 'pangloss/vim-javascript', {'for': ['js', 'jsx', 'tsx']}
Plug 'maxmellon/vim-jsx-pretty', {'for': ['js', 'jsx', 'tsx']}
Plug 'thoughtbot/vim-rspec'
Plug 'slim-template/vim-slim', {'for': ['slim']}
" List ends here. Plugins become visible to Vim after this call.
call plug#end()
" -----------------------------
" Global Settings - General
" -----------------------------
"
" Line number related
"
" Line number
set nu
" Relative line number
" :set rnu!
" Syntax Highlight
syntax on
" Ruler at bottom-right
set ruler
" Auto-indent with space keys
set autoindent
set tabstop=2
set shiftwidth=2
set expandtab
" Set keycode delay to 5ms
set ttimeoutlen=5
" MacOS clipboard sharing
set clipboard=unnamed
" Auto-read file when changed
set autoread
" Split to the right for vsp
set splitright
" Split to the bottom for sp
set splitbelow
" No colors for line longer than below
" to prevent Vim being slowed down by long lines
set synmaxcol=256
" Start scrolling when n lines away from top/bottom
set scrolloff=5
" Theming related
"
" colorscheme gruvbox
" colorscheme palenight
" colorscheme nord
" colorscheme synthwave
set termguicolors
" set bg=dark
" 20200213 config for ayu (Unset bg=dark required)
"
" let ayucolor="light" " for light version of theme
" let ayucolor="mirage" " for mirage version of theme
" let ayucolor="dark" " for dark version of theme
" colorscheme ayu
let g:tokyonight_style = 'night' " available: night, storm
" let g:tokyonight_enable_italic = 1
colorscheme tokyonight
" Term background related
"
" show background
" hi Normal guibg=NONE ctermbg=NONE
" IMPORTANT - 20191221
" Uncommment the following when enabling background image in terminal
" from https://github.com/morhetz/gruvbox/issues/81
" set t_ut=
" Disable concealing in .json/.md files
let g:vim_json_conceal=0
let g:vim_markdown_conceal=0
" Show nbsp & tab with special chars in file
set listchars=nbsp:☠,tab:▸␣
set list
" 2020-05-30 11:49:38 +0800
" Show match count at bottom right
set shortmess-=S
" -----------------------------
" Key Mappings - General
" -----------------------------
"
" Ignore arrow keys in Vim
noremap <Up> <Nop>
noremap <Down> <Nop>
noremap <Left> <Nop>
noremap <Right> <Nop>
" Break line with capital K
nnoremap K i<CR><Esc>
" Switch among tabs with Ctrl-n / Ctrl-m
nmap <C-n> gT
nmap <C-m> gt
" Removing trailing whitespace with F5
" https://vim.fandom.com/wiki/Remove_unwanted_spaces
nnoremap <silent> <F5> :let _s=@/ <Bar> :%s/\s\+$//e <Bar> :let @/=_s <Bar> :nohl <Bar> :unlet _s <CR>
" Open new file vertically
nnoremap <C-w>N :vnew<CR>
" Tab to indent by 1
nnoremap <TAB> v>
vnoremap <TAB> >gv
" Shift-Tab to remove indent by 1
nnoremap <S-TAB> v<
vnoremap <S-TAB> <gv
" 20200302 Toggle hls (highlight-search) with <leader> + l
nnoremap <silent><expr> <Leader>l (&hls && v:hlsearch ? ':nohls' : ':set hls')."\n"
" 20200321 (Vim 8.1) Open a terminal in a vertical window
" Type "exit" in terminal window to leave & close buffer
nnoremap <silent> <leader>t :vert term<CR>
" 20200425 Copy current filepath
" https://stackoverflow.com/posts/17096082/revisions
" relative path (src/foo.txt)
nnoremap <leader>cfr :let @+=expand("%")<CR>
" absolute path (/something/src/foo.txt)
nnoremap <leader>cfa :let @+=expand("%:p")<CR>
" filename (foo.txt)
nnoremap <leader>cff :let @+=expand("%:t")<CR>
" directory name (/something/src)
nnoremap <leader>cfd :let @+=expand("%:p:h")<CR>
" 2020-06-05 10:16:45 toggle presentation mode
function TogglePresentation()
if g:colors_name == 'tokyonight'
set bg=light
colorscheme PaperColor
else
set bg=dark
colorscheme tokyonight
end
endfunction
nnoremap <leader>pp :call TogglePresentation()<CR>
" -----------------------------
" Key Mappings - Insert Mode
" -----------------------------
"
" :ymd to print out current time
inoremap :ymd <C-R>=strftime('%Y-%m-%d %H:%M:%S %z')<CR>
" 2020-11-04 17:11:34
" <C-e> gives <% %>
:imap <C-e> <lt>% %><Left><Left><Left>
" -----------------------------
" Syntax Highlight by Extension
" -----------------------------
"
" https://vim.fandom.com/wiki/Forcing_Syntax_Coloring_for_files_with_odd_extensions
au BufNewFile,BufRead *.amp.erb set syntax=html.erb
" -----------------------------
" Config by File Extension
" -----------------------------
"
" Python
" https://realpython.com/vim-and-python-a-match-made-in-heaven/#python-indentation
" Check out 'vim-scripts/indentpython.vim' if the below doesn't work
au BufNewFile,BufRead *.py
\ set tabstop=4
\ set softtabstop=4
\ set shiftwidth=4
\ set textwidth=79
\ set fileformat=unix
" -----------------------------
" Settings/Mappings for Plugins
" -----------------------------
"
" 'scrooloose/nerdtree'
"
" toggles NERDTree view with <leader> + f
nmap <silent> <leader>f :NERDTreeToggle<CR>
" finds file in NERDTree with <leader> + \ + f
nmap <silent> <leader>\f :NERDTreeFind<CR>
" 'airblade/vim-gitgutter'
"
" moves to the next hunk and updates the preview window
nnoremap <silent> <leader>]c :GitGutterNextHunk<CR>:GitGutterPreviewHunk<CR>
nnoremap <silent> <leader>[c :GitGutterPrevHunk<CR>:GitGutterPreviewHunk<CR>
" closes preview window
nnoremap <silent> <leader>p :pc<CR>
" 'junegunn/fzf'
"
" Navigating in search window
" use <C-p> and <C-n> (or arrow keys) to navigate up/down
" Opening file in search window
" <CR> - Open in current pane
" <C-t> - Open in new tab
" <C-v> - Open in vertical split
" <C-x> - Open in horizontial split
" toggle FZF to search by file name
" (<C-c> is the default key combo for closing FZF)
nnoremap <silent> <C-c> :FZF<CR>
" Integration with 'ggreer/the_silver_searcher'
" **Install 'ggreer/the_silver_searcher' before using the following**
"
" open Ag in FZF to search word in files
" <leader>gg to open; ESC or <C-c> to close
nnoremap <silent> <leader>gg :Ag<CR>
" nnoremap <silent> <C-g> :Ag<CR>
" open Ag in FZF to search word under cursor in files
" <leader>ag to open; ESC or <C-c> to close
nnoremap <silent> <leader>ag :Ag <C-R><C-W><CR>
" 20200328
" Popup window for FZF search results
" Border style: horizontal/rounded/sharp
" let g:fzf_layout = { 'window': { 'width': 0.9, 'height': 0.6, 'highlight': 'Todo', 'border': 'sharp' } }
" 'scrooloose/nerdcommenter'
"
" Add spaces after comment delimiters by default
let g:NERDSpaceDelims = 1
" Align line-wise comment delimiters flush left instead of following code indentation
let g:NERDDefaultAlign = 'left'
" 'tpope/vim-fugitive'
"
" Make vertical splits for :Gdiffsplit!
set diffopt+=vertical
" 'airblade/vim-gitgutter'
"
" Set Vim's updatetime to 100ms (default: 4000ms)
set updatetime=100
" 'vim-airline/vim-airline'
"
" Get rid of mode (Insert/Visual) display on status
set noshowmode
" Enable smart tabline
let g:airline#extensions#tabline#enabled = 1
" 20191221
" 'yggdroot/indentline'
"
" Change indent line char to the following
let g:indentLine_char = ''
" 20191227
" 'tadaa/vimade'
"
let g:vimade = {}
" Change fade level
let g:vimade.fadelevel = 0.6
" Change fade priority
" Set 0 to make vimade not to dim hlsearch
let g:vimade.fadepriority = 0
" 20200124
" 'dense-analysis/ale'
" ALE only opens the loclist after buffers have been saved
let g:ale_open_list = 'on_save'
let g:ale_list_window_size = 3
" No linting while typing
let g:ale_lint_on_text_changed = 'never'
" 20200206 temp fix for no local config in folders
" FIXME: No linting in editor as consquence
let g:ale_javascript_eslint_suppress_missing_config = 1
" Close the loclist window automatically when the buffer is closed
augroup CloseLoclistWindowGroup
autocmd!
autocmd QuitPre * if empty(&buftype) | lclose | endif
augroup END
" Toggle ALE with <leader>at
map <leader>at :ALEToggle<CR>
" 20200322
" 'tpope/vim-surround' manual
"
" some-text -> <a foo="bar">some-text</a>
" 1. Select "some-text" in visual-block mode
" 2. Hit S then type <a foo="bar">
"
" <a foo="bar">some-text</a> -> <a foo="bar">some-text</a>
" 1. Place cursor anywhere on "some-text" in normal mode
" 2. Hit cst
" 3. Type <div then hit enter
" 20200327
" 'junegunn/goyo.vim'
" Toggle Goyo with <leader> + g + y
nnoremap <silent> <leader>gy :Goyo<CR>
" 'junegunn/limelight.vim'
" Enables/Disables Limelight when entering/leaving Goyo
autocmd! User GoyoEnter Limelight
autocmd! User GoyoLeave Limelight!
" TODO: change to vim-test
" 20200515
" 'thoughtbot/vim-rspec'
" RSpec.vim mappings
" map <Leader>rt :call RunCurrentSpecFile()<CR>
" map <Leader>rs :call RunNearestSpec()<CR>
" map <Leader>rl :call RunLastSpec()<CR>
" map <Leader>ra :call RunAllSpecs()<CR>
" let g:rspec_runner = 'os_x_iterm'
" let g:rspec_command = "Dispatch bundle exec rspec {spec}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment