もがき系プログラマの日常

もがき系エンジニアの勉強したこと、日常のこと、気になっている技術、備忘録などを紹介するブログです。

ShiftItを卒業してHammerspoonをインストールした

はじめに

こんにちは。

画面分割アプリつかってますか?

僕はだいぶ前から shiftIt を使用していました。

github.com

ただ、なんか最近うまく動かないときが続いており、気づくと応答なしになることが多くなってました。

githubみると、そもそもだいぶメンテされてないぞとなってたので、代替品を調べてたら他にも考えた方がいらっしゃいました。

kawase-k.hatenablog.com

いいのがありました。

それで Hammerspoon となるいい第かえツールがありました。

www.hammerspoon.org

shiftIt ライクに動かせるようにインストール後、設定ファイルを修正する必要があるので、参考を見てたらまた、ドンピシャなことを書いていた方がいました。

qiita.com

こちらの記事で紹介されているコードを参考にさらに 左上 右上 左下 右下 を追加しました。

本題

hs.window.animationDuration = 0
units = {
  rightHalf  = { x = 0.50, y = 0.00, w = 0.50, h = 1.00 },
  leftHalf   = { x = 0.00, y = 0.00, w = 0.50, h = 1.00 },
  topHalf    = { x = 0.00, y = 0.00, w = 1.00, h = 0.50 },
  bottomHalf = { x = 0.00, y = 0.50, w = 1.00, h = 0.50 },
  upperLest  = { x = 0.00, y = 0.00, w = 0.50, h = 0.50 },
  upperRight = { x = 0.50, y = 0.00, w = 0.50, h = 0.50 },
  lowerLest  = { x = 0.00, y = 0.50, w = 0.50, h = 0.50 },
  lowerRight = { x = 0.50, y = 0.50, w = 0.50, h = 0.50 },
  maximum    = { x = 0.00, y = 0.00, w = 1.00, h = 1.00 },
}

mash = { 'option', 'ctrl', 'cmd' }
hs.hotkey.bind(mash, 'right', function() hs.window.focusedWindow():move(units.rightHalf, nil, true) end)
hs.hotkey.bind(mash, 'left', function() hs.window.focusedWindow():move(units.leftHalf, nil, true) end)
hs.hotkey.bind(mash, 'up', function() hs.window.focusedWindow():move(units.topHalf, nil, true) end)
hs.hotkey.bind(mash, 'down', function() hs.window.focusedWindow():move(units.bottomHalf, nil, true) end)
hs.hotkey.bind(mash, '1', function() hs.window.focusedWindow():move(units.upperLest, nil, true) end)
hs.hotkey.bind(mash, '2', function() hs.window.focusedWindow():move(units.upperRight, nil, true) end)
hs.hotkey.bind(mash, '3', function() hs.window.focusedWindow():move(units.lowerLest, nil, true) end)
hs.hotkey.bind(mash, '4', function() hs.window.focusedWindow():move(units.lowerRight, nil, true) end)
hs.hotkey.bind(mash, 'm', function() hs.window.focusedWindow():move(units.maximum, nil, true) end)

動作確認

gyazo.com

いい感じです!

shiftIt ではzoomとかmeetとかやってると動作しないことがあったので、 Hammerspoon で効くかどうか気になります。

現場からは以上です。