OSXのタイルマネージャのslate.jsを入れた

前々から入れようと思っていたのだけど、色々あって(転職+例のMBASSD破損)忘れていた。

dotfiles/slate.js at master · jigish/dotfiles

特に理由もなく設定ファイルを coffeeで書いて、$ coffee -wcb ~/.slate.coffee しながら確認 とはいっても、ほとんど JavaScript - OS X の Slate.js の設定 - Qiita [キータ] のパクリ

shell = (command) ->
  S.op 'shell', {command, wait: true}

focusTo = (direction) ->
  S.op 'focus', {direction}

pushTo = (direction) ->
  S.op 'push', {direction}

nudge = (x, y) ->
  S.op 'nudge', {x, y}

resize = (width, height) ->
  S.op 'resize', {width, height}

stretch = ({right, left, bottom, top}) ->
  (window) ->
    prevPos = window.topLeft()
    x = '-' + (left || '0')
    y = '-' + (top || '0')
    nudge(x, y).run()

    pos = window.topLeft()
    height = '+' + (bottom or (prevPos.y - pos.y))
    width  = '+' + (right  or (prevPos.x - pos.x))
    resize(width, height).run()

shrink = ({right, left, bottom, top}) ->
  (window) ->
    prevSize = window.size()

    width = '-' + (right || left || '0')
    height = '-' + (bottom || top || '0')
    resize(width, height).run()

    size = window.size()
    x = '+' + if left then (prevSize.width  - size.width)  else '0'
    y = '+' + if top  then (prevSize.height - size.height) else '0'
    nudge(x, y).run()


S.cfga
  defaultToCurrentScreen: true
  secondsBetweenRepeat  : 0.03
  checkDefaultsOnLoad   : true
  focusCheckWidthMax    : 3000
  windowHintsIgnoreHiddenWindows: false

trimSpace = (str) -> str.replace /\s/g, ''
bindAll = (obj) ->
  o = {}
  for k, v of obj
    o[trimSpace(k)] = v
  S.bindAll o

bindAll
  # util
  'r:ctrl,shift' : S.op('relaunch')
  'space:alt' : S.op('hint')

  # move
  'k:alt'            : nudge('+0%', '-3%')
  'j:alt'            : nudge('+0%', '+3%')
  'h:alt'            : nudge('-3%', '+0%')
  'l:alt'            : nudge('+3%', '+0%')

  # push
  'k:alt,shift'     : pushTo('up')
  'j:alt,shift'     : pushTo('down')
  'h:alt,shift'     : pushTo('left')
  'l:alt,shift'     : pushTo('right')

  # stretch | shrink
  'k:alt,cmd'        : [shrink (bottom: '3%'), true]
  'j:alt,cmd'        : [stretch(bottom: '3%'), true]
  'h:alt,cmd'        : [shrink (right : '3%'), true]
  'l:alt,cmd'        : [stretch(right : '3%'), true]

  '1:alt,cmd'   : S.op "move",
    "x"      : "screenOriginX"
    "y"      : "screenOriginY"
    "width"  : "screenSizeX"
    "height" : "screenSizeY"

  '2:alt,cmd'   : S.op "move",
    "x"      : "screenOriginX"
    "y"      : "screenOriginY"
    "width"  : "screenSizeX/2"
    "height" : "screenSizeY"