-
-
Save astocko/c995728fed3cd15091851be2d5f6674c to your computer and use it in GitHub Desktop.
The best tmux and vim configuration in the universe
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Our .tmux.conf file | |
# Setting the prefix from C-b to C-s | |
set -g prefix C-s | |
# Free the original Ctrl-b prefix keybinding | |
unbind C-b | |
#setting the delay between prefix and command | |
set -sg escape-time 1 | |
# Ensure that we can send Ctrl-S to other apps | |
bind C-s send-prefix | |
# Set the base index for windows to 1 instead of 0 | |
set -g base-index 1 | |
# Set the base index for panes to 1 instead of 0 | |
setw -g pane-base-index 1 | |
# Reload the file with Prefix r | |
bind r source-file ~/.tmux.conf \; display "Reloaded!" | |
# splitting panes | |
bind | split-window -h | |
bind - split-window -v | |
# smart pane switching with awareness of vim splits | |
bind -n C-h run "(tmux display-message -p '#{pane_current_command}' | grep -iq vim && tmux send-keys C-h) || tmux select-pane -L" | |
bind -n C-j run "(tmux display-message -p '#{pane_current_command}' | grep -iq vim && tmux send-keys C-j) || tmux select-pane -D" | |
bind -n C-k run "(tmux display-message -p '#{pane_current_command}' | grep -iq vim && tmux send-keys C-k) || tmux select-pane -U" | |
bind -n C-l run "(tmux display-message -p '#{pane_current_command}' | grep -iq vim && tmux send-keys C-l) || tmux select-pane -R" | |
bind -n C-\ run "(tmux display-message -p '#{pane_current_command}' | grep -iq vim && tmux send-keys 'C-\\') || tmux select-pane -l" | |
# Moving between windows, gnome-terminal style | |
bind -n C-PgUp select-window -t :- | |
bind -n C-PgDn select-window -t :+ | |
# open new window gnome-terminal style | |
bind -n C-T new-window | |
set-window-option -g xterm-keys on | |
# move windows forward and backwards, gnome-terminal style | |
bind-key -n C-S-Left swap-window -t -1 | |
bind-key -n C-S-Right swap-window -t +1 | |
# use the mouse | |
set-window-option -g mode-mouse on | |
set -g mouse-select-pane on | |
set -g mouse-resize-pane on | |
set -g mouse-select-window on | |
# use vim-bindings for copying and pasting text | |
unbind [ | |
bind Escape copy-mode | |
# use vim-bindings for copying and pasting text | |
unbind [ | |
bind Escape copy-mode | |
unbind p | |
# move x clipboard into tmux paste buffer | |
bind p run "tmux set-buffer \"$(xclip -o -set clipboard)\"; tmux paste-buffer" | |
bind -t vi-copy 'v' begin-selection | |
# # move tmux copy buffer into x clipboard | |
bind -t vi-copy y copy-pipe 'xclip -in -set clipboard' | |
#unbind p | |
#bind p run "xclip -o | tmux load-buffer - ; tmux paste-buffer" | |
#bind-key -t vi-copy 'v' begin-selection | |
## see http://unix.stackexchange.com/questions/131011/use-system-clipboard-in-vi-copy-mode-in-tmux | |
#bind-key -t vi-copy 'y' save-buffer | |
#bind -t vi-copy y copy-pipe 'xclip -i' | |
#bind -t vi-copy V rectangle-toggle | |
# end corentin | |
# Pane resizing | |
bind -r H resize-pane -L 5 | |
bind -r J resize-pane -D 5 | |
bind -r K resize-pane -U 5 | |
bind -r L resize-pane -R 5 | |
# Set the default terminal mode to 256color mode | |
set -g default-terminal "screen-256color" | |
# enable activity alerts | |
setw -g monitor-activity on | |
set -g visual-activity on | |
# set the status line's colors | |
set -g status-fg white | |
set -g status-bg black | |
# set the color of the window list | |
setw -g window-status-fg cyan | |
setw -g window-status-bg default | |
setw -g window-status-attr dim | |
# set colors for the active window | |
setw -g window-status-current-fg white | |
setw -g window-status-current-bg red | |
setw -g window-status-current-attr bright | |
# pane | |
set -g pane-border-fg green | |
set -g pane-border-bg black | |
set -g pane-active-border-fg white | |
set -g pane-active-border-bg yellow | |
# Command / message line | |
set -g message-fg white | |
set -g message-bg black | |
set -g message-attr bright | |
# Status line left side | |
set -g status-left-length 40 | |
set -g status-left "#[fg=green]Session: #S #[fg=yellow]#I #[fg=cyan]#P" | |
set -g status-utf8 on | |
# Status line right side | |
# 15% | 28 Nov 18:15 | |
#set -g status-right "#(~/battery Discharging) | #[fg=cyan]%d %b %R" | |
# Update the status bar every sixty seconds | |
set -g status-interval 60 | |
# Center the window list | |
set -g status-justify centre | |
# enable vi keys. | |
setw -g mode-keys vi | |
# Open panes in the same directory using the tmux-panes script | |
#unbind v | |
#unbind n | |
#bind v send-keys " ~/tmux-panes -h" C-m | |
#bind n send-keys " ~/tmux-panes -v" C-m | |
# Maximize and restore a pane | |
#unbind Up | |
#bind Up new-window -d -n tmp \; swap-pane -s tmp.1 \; select-window -t tmp | |
#unbind Down | |
#bind Down last-window \; swap-pane -s tmp.1 \; kill-window -t tmp | |
# | |
# Log output to a text file on demand | |
bind P pipe-pane -o "cat >>~/#W.log" \; display "Toggled logging to ~/#W.log" | |
set -g history-limit 10000 | |
set-option -g status-position top | |
#new-window | |
new-session |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"{{{Auto Commands | |
" Automatically cd into the directory that the file is in | |
" nochem not good for diffsplit | |
" autocmd BufEnter * execute "chdir ".escape(expand("%:p:h"), ' ') | |
" Remove any trailing whitespace that is in the file | |
"autocmd BufRead,BufWrite * if ! &bin | silent! %s/\s\+$//ge | endif | |
" Restore cursor position to where it was before | |
augroup JumpCursorOnEdit | |
au! | |
autocmd BufReadPost * | |
\ if expand("<afile>:p:h") !=? $TEMP | | |
\ if line("'\"") > 1 && line("'\"") <= line("$") | | |
\ let JumpCursorOnEdit_foo = line("'\"") | | |
\ let b:doopenfold = 1 | | |
\ if (foldlevel(JumpCursorOnEdit_foo) > foldlevel(JumpCursorOnEdit_foo - 1)) | | |
\ let JumpCursorOnEdit_foo = JumpCursorOnEdit_foo - 1 | | |
\ let b:doopenfold = 2 | | |
\ endif | | |
\ exe JumpCursorOnEdit_foo | | |
\ endif | | |
\ endif | |
" Need to postpone using "zv" until after reading the modelines. | |
autocmd BufWinEnter * | |
\ if exists("b:doopenfold") | | |
\ exe "normal zv" | | |
\ if(b:doopenfold > 1) | | |
\ exe "+".1 | | |
\ endif | | |
\ unlet b:doopenfold | | |
\ endif | |
augroup END | |
"}}} | |
"" status bar that rocks | |
"{{{Misc Settings | |
" Necesary for lots of cool vim things | |
set nocompatible | |
" This shows what you are typing as a command. I love this! | |
set showcmd | |
" Folding Stuffs | |
set foldmethod=marker | |
" Needed for Syntax Highlighting and stuff | |
filetype on | |
filetype plugin on | |
syntax enable | |
set grepprg=grep\ -nH\ $* | |
" Who doesn't like autoindent? | |
set autoindent | |
" Spaces are better than a tab character | |
set expandtab | |
set smarttab | |
" Who wants an 8 character tab? Not me! | |
set shiftwidth=4 | |
set softtabstop=4 | |
" Use english for spellchecking, but don't spellcheck by default | |
if version >= 700 | |
set spl=en spell | |
set nospell | |
endif | |
" Real men use gcc | |
"compiler gcc | |
" Cool tab completion stuff | |
set wildmenu | |
set wildmode=list:longest,full | |
" Enable mouse support in console | |
set mouse+=a | |
" Let me do things with the mouse inside tmux | |
if &term =~ '^screen' | |
" tmux knows the extended mouse mode | |
set ttymouse=xterm2 | |
endif | |
" Got backspace? | |
set backspace=2 | |
" Line Numbers PWN! | |
set number | |
" Ignoring case is a fun trick | |
set ignorecase | |
" And so is Artificial Intellegence! | |
set smartcase | |
" This is totally awesome - remap jj to escape in insert mode. You'll never type jj anyway, so it's great! | |
inoremap jj <Esc> | |
nnoremap JJJJ <Nop> | |
" Incremental searching is sexy | |
set incsearch | |
" Highlight things that we find with the search | |
set hlsearch | |
" Since I use linux, I want this | |
" nochem still not sure what's going on with clipboard | |
"let g:clipbrdDefaultReg = '+' | |
" When I close a tab, remove the buffer | |
set nohidden | |
" Set off the other paren | |
highlight MatchParen ctermbg=4 | |
" }}} | |
"{{{Look and Feel | |
" Favorite Color Scheme | |
" nochem error: color scheme not found | |
" | |
"if has("gui_running") | |
"colorscheme inkpot | |
"" Remove Toolbar | |
"set guioptions-=T | |
""Terminus is AWESOME | |
"set guifont=Terminus\ 9 | |
"else | |
"colorscheme metacosm | |
"endif | |
"Status line gnarliness | |
set laststatus=2 | |
"set statusline=%{fugitive#statusline()}%F%m%r%h%w\ (%{&ff}){%Y}\ [%l,%v][%p%%] | |
" }}} | |
"{{{ Functions | |
"{{{ Open URL in browser | |
function! Browser () | |
let line = getline (".") | |
let line = matchstr (line, "http[^ ]*") | |
exec "!konqueror ".line | |
endfunction | |
"}}} | |
"{{{Theme Rotating | |
let themeindex=0 | |
function! RotateColorTheme() | |
let y = -1 | |
while y == -1 | |
let colorstring = "inkpot#ron#blue#elflord#evening#koehler#murphy#pablo#desert#torte#" | |
let x = match( colorstring, "#", g:themeindex ) | |
let y = match( colorstring, "#", x + 1 ) | |
let g:themeindex = x + 1 | |
if y == -1 | |
let g:themeindex = 0 | |
else | |
let themestring = strpart(colorstring, x + 1, y - x - 1) | |
return ":colorscheme ".themestring | |
endif | |
endwhile | |
endfunction | |
" }}} | |
"{{{ Paste Toggle | |
let paste_mode = 0 " 0 = normal, 1 = paste | |
func! Paste_on_off() | |
if g:paste_mode == 0 | |
set paste | |
let g:paste_mode = 1 | |
else | |
set nopaste | |
let g:paste_mode = 0 | |
endif | |
return | |
endfunc | |
"}}} | |
"{{{ Todo List Mode | |
function! TodoListMode() | |
e ~/.todo.otl | |
Calendar | |
wincmd l | |
set foldlevel=1 | |
tabnew ~/.notes.txt | |
tabfirst | |
" or 'norm! zMzr' | |
endfunction | |
"}}} | |
"}}} | |
"{{{ Mappings | |
" Open Url on this line with the browser \w | |
map <Leader>w :call Browser ()<CR> | |
" Open the Project Plugin <F2> | |
nnoremap <silent> <F2> :Project<CR> | |
" Open the Project Plugin | |
nnoremap <silent> <Leader>pal :Project .vimproject<CR> | |
" TODO Mode | |
nnoremap <silent> <Leader>todo :execute TodoListMode()<CR> | |
" Open the TagList Plugin <F3> | |
nnoremap <silent> <F3> :Tlist<CR> | |
" Next Tab | |
nnoremap <silent> <C-Right> :tabnext<CR> | |
" Previous Tab | |
nnoremap <silent> <C-Left> :tabprevious<CR> | |
" New Tab | |
nnoremap <silent> <C-t> :tabnew<CR> | |
" Rotate Color Scheme <F8> | |
" nnoremap <silent> <F8> :execute RotateColorTheme()<CR> | |
" DOS is for fools. | |
nnoremap <silent> <F9> :%s/$//g<CR>:%s// /g<CR> | |
" Paste Mode! Dang! <F8> | |
nnoremap <silent> <F8> :call Paste_on_off()<CR> | |
set pastetoggle=<F8> | |
" Edit vimrc \ev | |
nnoremap <silent> <Leader>ev :tabnew<CR>:e ~/.vimrc<CR> | |
" Edit gvimrc \gv | |
nnoremap <silent> <Leader>gv :tabnew<CR>:e ~/.gvimrc<CR> | |
" Up and down are more logical with g.. | |
nnoremap <silent> k gk | |
nnoremap <silent> j gj | |
inoremap <silent> <Up> <Esc>gka | |
inoremap <silent> <Down> <Esc>gja | |
" Good call Benjie (r for i) | |
nnoremap <silent> <Home> i <Esc>r | |
nnoremap <silent> <End> a <Esc>r | |
" Create Blank Newlines and stay in Normal mode | |
nnoremap <silent> zj o<Esc> | |
nnoremap <silent> zk O<Esc> | |
" Space will toggle folds! | |
nnoremap <space> za | |
nnoremap <C-h> <C-w>h | |
nnoremap <C-j> <C-w>j | |
nnoremap <C-k> <C-w>k | |
nnoremap <C-l> <C-w>l | |
" Search mappings: These will make it so that going to the next one in a | |
" search will center on the line it's found in. | |
map N Nzz | |
map n nzz | |
" Testing | |
set completeopt=longest,menuone,preview | |
inoremap <expr> <cr> pumvisible() ? "\<c-y>" : "\<c-g>u\<cr>" | |
inoremap <expr> <c-n> pumvisible() ? "\<lt>c-n>" : "\<lt>c-n>\<lt>c-r>=pumvisible() ? \"\\<lt>down>\" : \"\"\<lt>cr>" | |
inoremap <expr> <m-;> pumvisible() ? "\<lt>c-n>" : "\<lt>c-x>\<lt>c-o>\<lt>c-n>\<lt>c-p>\<lt>c-r>=pumvisible() ? \"\\<lt>down>\" : \"\"\<lt>cr>" | |
" Swap ; and : Convenient. | |
" nochem not convenient, because you are going to use 10000 vims with 10000 users | |
"nnoremap ; : | |
"nnoremap : ; | |
" Fix email paragraphs | |
nnoremap <leader>par :%s/^>$//<CR> | |
"ly$O#{{{ "lpjjj_%A#}}}jjzajj | |
"}}} | |
"{{{Taglist configuration | |
let Tlist_Use_Right_Window = 1 | |
let Tlist_Enable_Fold_Column = 0 | |
let Tlist_Exit_OnlyWindow = 1 | |
let Tlist_Use_SingleClick = 1 | |
let Tlist_Inc_Winwidth = 0 | |
"}}} | |
let g:rct_completion_use_fri = 1 | |
"let g:Tex_DefaultTargetFormat = "pdf" | |
let g:Tex_ViewRule_pdf = "kpdf" | |
filetype plugin indent on | |
syntax on | |
"Open new split panes to right and bottom, which feels more natural than Vim’s default: | |
set splitbelow | |
set splitright | |
"set the runtime path to include Vundle and initialize | |
set rtp+=~/.vim/bundle/Vundle.vim | |
call vundle#begin() | |
" let Vundle manage Vundle, required | |
Plugin 'gmarik/Vundle.vim' | |
" | |
" " The following are examples of different formats supported. | |
" " Keep Plugin commands between vundle#begin/end. | |
" " plugin on GitHub repo | |
Plugin 'tpope/vim-fugitive' | |
" Puppet syntax | |
Plugin 'rodjek/vim-puppet' | |
" version control gutter (works with git) | |
Plugin 'airblade/vim-gitgutter' | |
" Seamlessly navigate between tmux and vim panes | |
Plugin 'christoomey/vim-tmux-navigator' | |
" Python Linter | |
Plugin 'nvie/vim-flake8' | |
" status bar that rocks | |
Plugin 'bling/vim-airline' | |
call vundle#end() " required | |
" call flake8 for python files | |
"autocmd BufNewFile,BufRead *.py set ft=python | |
"autocmd BufWritePost *.py call Flake8() | |
" Needed for Syntax Highlighting and stuff | |
filetype on | |
filetype plugin on | |
filetype plugin indent on | |
syntax enable | |
set grepprg=grep\ -nH\ $* |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment