# HG changeset patch # User Steve Losh # Date 1334250860 14400 # Node ID cb94d1d947f52042257228ef0d03758723111aae # Parent 0bda165400292e5da28e7ac6dda6f23e34252d31 Moar. diff -r 0bda16540029 -r cb94d1d947f5 tmux/tmux.conf --- a/tmux/tmux.conf Tue Apr 10 10:01:32 2012 -0400 +++ b/tmux/tmux.conf Thu Apr 12 13:14:20 2012 -0400 @@ -7,6 +7,11 @@ set -sg escape-time 0 set -sg repeat-time 600 +# Mouse +set -g mode-mouse on +setw -g mouse-select-window on +setw -g mouse-select-pane on + # This is hilariously absurd. How many nerds use tmux on OS X every day and # it's still fundamentally broken? set -g default-command "dammit-tmux -l zsh" @@ -98,3 +103,5 @@ bind -t vi-copy v begin-selection bind -t vi-copy y copy-selection bind -t vi-copy Escape cancel +bind y run "tmux save-buffer - | reattach-to-user-namespace pbcopy" + diff -r 0bda16540029 -r cb94d1d947f5 vim/.vimrc --- a/vim/.vimrc Tue Apr 10 10:01:32 2012 -0400 +++ b/vim/.vimrc Thu Apr 12 13:14:20 2012 -0400 @@ -47,6 +47,7 @@ set linebreak set dictionary=/usr/share/dict/words set spellfile=~/.vim/custom-dictionary.utf-8.add +set colorcolumn=+1 " Time out on key codes but not mappings. " Basically this makes terminal Vim work sanely. @@ -78,16 +79,6 @@ augroup END " }}} -" Colorcolumn {{{ -" Only show colorcolumn in the current window. - -augroup ccol - au! - au WinLeave * setlocal colorcolumn=0 - au WinEnter * setlocal colorcolumn=+1 -augroup END - -" }}} " cpoptions+=J, dammit {{{ " Something occasionally removes this. If I manage to find it I'm going to @@ -148,7 +139,7 @@ " }}} " Tabs, spaces, wrapping {{{ -set tabstop=4 +set tabstop=8 set shiftwidth=4 set softtabstop=4 set expandtab @@ -237,7 +228,7 @@ nnoremap K :q " Unfuck my screen -nnoremap U :syntax sync fromstart:redraw! +nnoremap u :syntax sync fromstart:redraw! " System clipboard interaction " From https://github.com/henrik/dotfiles/blob/master/vim/config/mappings.vim @@ -427,7 +418,8 @@ " Easier to type, and I never use the default behavior. noremap H ^ -noremap L g_ +noremap L $ +vnoremap L g_ " Heresy inoremap I @@ -446,11 +438,16 @@ nnoremap Vab vabV nnoremap VaB vaBV +" Toggle "keep current line in the center of the screen" mode +nnoremap C :let &scrolloff=999-&scrolloff + " Directional Keys {{{ " It's 2012. noremap j gj noremap k gk +noremap gj j +noremap gk k " Easy buffer navigation noremap h @@ -1652,30 +1649,104 @@ end else " Console Vim + " For me, this means iTerm2, possibly through tmux - " Use a bar-shaped cursor for insert mode, even through tmux. + " Mouse support + set mouse=a + + " iTerm2 allows you to turn "focus reporting" on and off with these + " sequences. + " + " When reporting is on, iTerm2 will send [O when the window loses + " focus and [I when it gains focus. + " + " TODO: Look into how this works with iTerm tabs. Seems a bit wonky. + let enable_focus_reporting = "\[?1004h" + let disable_focus_reporting = "\[?1004l" + + " These sequences save/restore the screen. + " They should NOT be wrapped in tmux escape sequences for some reason! + let save_screen = "\[?1049h" + let restore_screen = "\[?1049l" + + " These sequences tell iTerm2 to change the cursor shape to a bar or block. + let cursor_to_bar = "\]50;CursorShape=1\x7" + let cursor_to_block = "\]50;CursorShape=0\x7" + if exists('$TMUX') - let &t_SI = "\Ptmux;\\]50;CursorShape=1\x7\\\" - let &t_EI = "\Ptmux;\\]50;CursorShape=0\x7\\\" - else - let &t_SI = "\]50;CursorShape=1\x7" - let &t_EI = "\]50;CursorShape=0\x7" + " Some escape sequences (not all, lol) need to be properly escaped to + " get them through tmux without being eaten. + " + " To escape a sequence through tmux: + " + " * Wrap it in these sequences. + " * Any characters inside it must be doubled. + let tmux_start = "\Ptmux;" + let tmux_end = "\\\" + + let enable_focus_reporting = tmux_start . "\" . enable_focus_reporting . tmux_end + let disable_focus_reporting = tmux_start . "\" . disable_focus_reporting . tmux_end + + let cursor_to_bar = tmux_start . "\" . cursor_to_bar . tmux_end + let cursor_to_block = tmux_start . "\" . cursor_to_block . tmux_end endif - " Save on losing focus. - " TODO: Make this work... - if exists('$TMUX') - " let &t_ti = "\Ptmux;\" . &t_ti . "\e[?1004h" . "\\\" - " let &t_te = "\Ptmux;\" . "\e[?1004l" . &t_te . "\\\" + " When starting Vim, enable focus reporting and save the screen. + " When exiting Vim, disable focus reporting and save the screen. + " + " The "focus/save" and "nofocus/restore" each have to be in this order. + " Trust me, you don't want to go down this rabbit hole. Just keep them in + " this order and no one gets hurt. + let &t_ti = enable_focus_reporting . save_screen + let &t_te = disable_focus_reporting . restore_screen + + " When entering insert mode, change the cursor to a bar. + " When exiting insert mode, change it back to a block. + let &t_SI = cursor_to_bar + let &t_EI = cursor_to_block + + " Map some of Vim's unused keycodes to the sequences iTerm2 is going to send + " on focus lost/gained. + " + " If you're already using f24 or f25, change them to something else. Vim + " support up to f37. + " + " Doing things this way is might nicer than just mapping the raw sequences + " directly, because Vim won't hang after a bare waiting for the rest + " of the mapping. + execute "set =\[O" + execute "set =\[I" - " noremap [O :echom "TEST" - else - " if &term =~ "xterm.*" - " let &t_ti = &t_ti . "\e[?1004h" - " let &t_te = "\e[?1004l" . &t_te - " noremap [O :echom "TEST" - " endif - endif + " Handle the focus gained/lost signals in each mode separately. + " + " The goal should be to do what you need and restore the state to what it + " was before, so it functions like an autocommand. This is easy for some + " modes and hard/impossible for others. + " + " If you don't need one it's best to map it to to be explicit (and + " prevent problems, especially in insert mode). + " + " EXAMPLES: + " nnoremap :echom "FOCUS LOST" + " nnoremap :echom "FOCUS GAINED" + + " onoremap :echom "FOCUS LOST" + " onoremap :echom "FOCUS GAINED" + + " vnoremap :echom "FOCUS LOST"gv + " vnoremap :echom "FOCUS GAINED"gv + + " inoremap :echom "FOCUS LOST"a + " inoremap :echom "FOCUS GAINED"a + + nnoremap :wa + nnoremap + onoremap :wa + onoremap + vnoremap :wagv + vnoremap + inoremap :waa + inoremap endif " }}}