dc4190209ffa

Add keymando and more.
[view raw] [browse files]
author Steve Losh <steve@stevelosh.com>
date Wed, 03 Aug 2011 11:22:53 -0400
parents 05179960d29b
children 2dc37adbdc0e
branches/tags (none)
files .zshrc dotjs/democratandchronicle.com.js keymando/keymandorc.rb vim/.vimrc

Changes

--- a/.zshrc	Mon Aug 01 15:11:39 2011 -0400
+++ b/.zshrc	Wed Aug 03 11:22:53 2011 -0400
@@ -43,6 +43,7 @@
 export PATH="${PATH}:/usr/local/Cellar/python/2.6.4/bin"
 export PATH="${PATH}:/usr/local/Cellar/ruby/1.9.2-p0/bin"
 export PATH="${PATH}:/usr/local/Cellar/ruby/1.9.2-p180/bin"
+export PATH="${PATH}:/Developer/usr/bin/"
 export PYTHONPATH="$PYTHONPATH:/usr/local/lib/python2.7.1/site-packages"
 export PYTHONPATH="$PYTHONPATH:/usr/local/lib/python2.7/site-packages"
 export PYTHONPATH="$PYTHONPATH:/usr/local/lib/python2.6/site-packages"
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dotjs/democratandchronicle.com.js	Wed Aug 03 11:22:53 2011 -0400
@@ -0,0 +1,4 @@
+$('.fb_recommend, .aside center, .aside table, #taboola-leftcolumn-div').remove();
+$('#dir_widget_wrapper, #conveyorbottom, .ody-ob-taboola-wrapper').remove();
+$('.footer-partners, .footer-gannett, .footer-bottom').remove();
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/keymando/keymandorc.rb	Wed Aug 03 11:22:53 2011 -0400
@@ -0,0 +1,144 @@
+# Basic ----------------------------------------------------------------------------
+start_at_login
+
+disable "Remote Desktop Connection"
+disable /VirtualBox/
+
+map "<Ctrl-m>", "<Ctrl-F2>"
+map "<Ctrl-Shift-R>", lambda { reload() }
+
+# Application Switching ------------------------------------------------------------
+map "<Ctrl-Shift-J>", lambda { activate('Firefox') }
+map "<Ctrl-Shift-K>", lambda { activate('MacVim') }
+map "<Ctrl-Shift-M>" do
+    activate('iTerm')
+    sleep(1)
+    send('<Ctrl-F>')
+    send('3')
+end
+map "<Ctrl-Shift-G>" do
+    activate('iTerm')
+    sleep(1)
+    send('<Ctrl-F>')
+    send('1')
+end
+
+# Leader ---------------------------------------------------------------------------
+map "<Ctrl-,>" do
+    input()
+end
+
+# Vim ------------------------------------------------------------------------------
+class Vim < Plugin
+  @oldmode = 'n'
+  @mode = 'n'
+  @maps = {}
+
+  class << self; attr_accessor :mode, :maps, :oldmode; end
+
+  def before
+  end
+
+  def fire(key)
+      fn = Vim.maps[Vim.mode][key]
+      if fn
+          fn.call()
+      else
+          send(key)
+      end
+  end
+
+  def tomode(m)
+      oldmap = Vim.maps[Vim.mode]
+      newmap = Vim.maps[m]
+
+      oldmap.keys.each do |k|
+          #unmap k
+      end
+
+      newmap.keys.each do |k|
+          #map(k, lambda { self.fire(k) })
+      end
+  end
+
+  def toggle()
+      if Vim.mode == 'disabled'
+          Vim.mode = Vim.oldmode
+          system '/usr/local/bin/growlnotify -m "" -a Keymando Vim mode enabled.'
+      else
+          Vim.oldmode = Vim.mode
+          Vim.mode = 'disabled'
+          system '/usr/local/bin/growlnotify -m "" -a Keymando Vim mode disabled.'
+      end
+  end
+
+  def after
+      except /iTerm/, /MacVim/, /Firefox/, /PeepOpen/, /Quicksilver/ do
+          Vim.maps['disabled'] = {}
+          Vim.maps['n'] = {
+              'h' => lambda { send("<Left>") },
+              'j' => lambda { send("<Down>") },
+              'k' => lambda { send("<Up>") },
+              'l' => lambda { send("<Right>") },
+
+              'w' => lambda { send("<Alt-Right><Alt-Right><Alt-Left>") },
+              'b' => lambda { send("<Alt-Left>") },
+              'e' => lambda { send("<Alt-Right>") },
+              '0' => lambda { send("<Cmd-Left>") },
+
+              'i' => lambda { Vim.mode = 'i' },
+              'a' => lambda { Vim.mode = 'i'; send("<Right>") },
+              'A' => lambda { Vim.mode = 'i'; send("<Ctrl-e>") },
+              'I' => lambda { Vim.mode = 'i'; send("<Ctrl-a>") },
+              'o' => lambda { Vim.mode = 'i'; send("<Cmd-Right><Return>") },
+              'O' => lambda { Vim.mode = 'i'; send("<Cmd-Left><Return><Up>") },
+
+              'd' => lambda { Vim.mode = 'od' },
+              'c' => lambda { Vim.mode = 'oc' },
+
+              'p' => lambda { send("<Cmd-Left><Down><Cmd-v>") },
+              'P' => lambda { send("<Cmd-Left><Cmd-v>") },
+
+              'u' => lambda { send("<Cmd-z>") },
+              '<Ctrl-R>' => lambda { send("<Shift-Cmd-z>") },
+
+              'x' => lambda { send("<Shift-Right><Cmd-x>") },
+
+              '<Escape>' => lambda { send("<Escape>") },
+          }
+          Vim.maps['i'] = {
+              '<Ctrl-[>' => lambda { Vim.mode = 'n' },
+              '<Escape>' => lambda { Vim.mode = 'n' },
+          }
+          Vim.maps['od'] = {
+              'w'  => lambda { send("<Shift-Alt-Right><Cmd-x>"); Vim.mode = 'n' },
+              'b'  => lambda { send("<Shift-Alt-Left><Cmd-x>"); Vim.mode = 'n' },
+              'd'  => lambda { send("<Cmd-Left><Shift-Down><Cmd-x>"); Vim.mode = 'n' },
+
+              #'iw' => lambda { send("<Alt-Right><Shift-Alt-Left><Delete>"); Vim.mode = 'n' },
+
+              '<Escape>' => lambda { Vim.mode = 'n' },
+          }
+          Vim.maps['oc'] = {
+              'w' => lambda { send("<Shift-Alt-Right><Cmd-x>"); Vim.mode = 'i' },
+              'b'  => lambda { send("<Shift-Alt-Left><Cmd-x>"); Vim.mode = 'i' },
+              'c' => lambda { send("<Cmd-Left><Shift-Down><Cmd-x><Return><Up>"); Vim.mode = 'i' },
+
+              #'iw' => lambda { send("<Alt-Right><Shift-Alt-Left><Delete>"); Vim.mode = 'i' },
+
+              '<Escape>' => lambda { Vim.mode = 'n' },
+          }
+
+          keys = Vim.maps.values.reduce([]) do |l, m|
+              l = l + m.keys
+          end
+          keys.uniq.each do |k|
+              map(k, lambda { self.fire(k) })
+          end
+      end
+
+      map "<Alt-Escape>", lambda { self.toggle }
+  end
+end
+
+
--- a/vim/.vimrc	Mon Aug 01 15:11:39 2011 -0400
+++ b/vim/.vimrc	Wed Aug 03 11:22:53 2011 -0400
@@ -141,6 +141,10 @@
 nnoremap n nzzzv
 nnoremap N Nzzzv
 
+" Same when jumping around
+nnoremap g; g;zz
+nnoremap g, g,zz
+
 " L is easier to type, and I never use the default behavior.
 noremap L $
 
@@ -423,6 +427,11 @@
 au Filetype rst nnoremap <buffer> <localleader>4 yypVr`
 
 " }}}
+" Ruby {{{
+
+au Filetype ruby setlocal foldmethod=syntax
+
+" }}}
 " Vagrant {{{
 
 au BufRead,BufNewFile Vagrantfile set ft=ruby
@@ -444,6 +453,7 @@
 nnoremap <leader>eh <C-w>s<C-w>j<C-w>L:e ~/.hgrc<cr>
 nnoremap <leader>em <C-w>s<C-w>j<C-w>L:e ~/.mutt/muttrc<cr>
 nnoremap <leader>ez <C-w>s<C-w>j<C-w>L:e ~/lib/dotfiles/zsh<cr>4j
+nnoremap <leader>ek <C-w>s<C-w>j<C-w>L:e ~/lib/dotfiles/keymando/keymandorc.rb<cr>
 
 " }}}
 " Convenience mappings -------------------------------------------------------- {{{