My personal dotfiles
Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

init.lua 5.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225
  1. -- Makes window movement instant i.e. remove animations
  2. hs.window.animationDuration = 0
  3. -- Moves window to left 50% of screen
  4. hs.hotkey.bind({"cmd", "shift"}, "H", function()
  5. local win = hs.window.focusedWindow()
  6. local f = win:frame()
  7. local screen = win:screen()
  8. local max = screen:frame()
  9. f.x = max.x
  10. f.y = max.y
  11. f.w = max.w / 2
  12. f.h = max.h
  13. win:setFrame(f)
  14. max_iterm()
  15. end)
  16. -- Moves window to right 50% of screen
  17. hs.hotkey.bind({"cmd", "shift"}, "L", function()
  18. local win = hs.window.focusedWindow()
  19. local f = win:frame()
  20. local screen = win:screen()
  21. local max = screen:frame()
  22. f.x = max.x + (max.w / 2)
  23. f.y = max.y
  24. f.w = max.w / 2
  25. f.h = max.h
  26. win:setFrame(f)
  27. max_iterm()
  28. end)
  29. -- Moves window to fill the screen
  30. hs.hotkey.bind({"cmd", "shift"}, "J", function()
  31. local win = hs.window.focusedWindow()
  32. local f = win:frame()
  33. local screen = win:screen()
  34. local max = screen:frame()
  35. f.x = max.x
  36. f.y = max.y
  37. f.w = max.w
  38. f.h = max.h
  39. win:setFrame(f)
  40. max_iterm()
  41. end)
  42. -- Moves the window to the centre and sizes it to be 2/3 of screen
  43. hs.hotkey.bind({"cmd", "shift"}, "K", function()
  44. local win = hs.window.focusedWindow()
  45. local f = win:frame()
  46. local screen = win:screen()
  47. local max = screen:frame()
  48. f.x = max.x + (max.w / 3)/2
  49. f.y = max.y
  50. f.w = max.w * 2/3
  51. f.h = max.h
  52. win:setFrame(f)
  53. max_iterm()
  54. end)
  55. -- Moves the window to the left 33.3% of the screen
  56. hs.hotkey.bind({"cmd", "shift"}, "N", function()
  57. local win = hs.window.focusedWindow()
  58. local f = win:frame()
  59. local screen = win:screen()
  60. local max = screen:frame()
  61. f.x = max.x
  62. f.y = max.y
  63. f.w = max.w / 3
  64. f.h = max.h
  65. win:setFrame(f)
  66. max_iterm()
  67. end)
  68. -- Moves the window to the right 33.3% of the screen
  69. hs.hotkey.bind({"cmd", "shift"}, ".", function()
  70. local win = hs.window.focusedWindow()
  71. local f = win:frame()
  72. local screen = win:screen()
  73. local max = screen:frame()
  74. f.x = max.x + (max.w / 3)*2
  75. f.y = max.y
  76. f.w = max.w / 3
  77. f.h = max.h
  78. win:setFrame(f)
  79. max_iterm()
  80. end)
  81. -- Moves the window to the left 66.6% of the screen
  82. hs.hotkey.bind({"cmd", "shift"}, "M", function()
  83. local win = hs.window.focusedWindow()
  84. local f = win:frame()
  85. local screen = win:screen()
  86. local max = screen:frame()
  87. f.x = max.x
  88. f.y = max.y
  89. f.w = (max.w / 3)*2
  90. f.h = max.h
  91. win:setFrame(f)
  92. max_iterm()
  93. end)
  94. -- Moves the window to the right 66.6% of the screen
  95. hs.hotkey.bind({"cmd", "shift"}, ",", function()
  96. local win = hs.window.focusedWindow()
  97. local f = win:frame()
  98. local screen = win:screen()
  99. local max = screen:frame()
  100. f.x = max.x + (max.w / 3)
  101. f.y = max.y
  102. f.w = 2*(max.w / 3)
  103. f.h = max.h
  104. win:setFrame(f)
  105. max_iterm()
  106. end)
  107. -- Moves the window to the left 40% of the screen
  108. hs.hotkey.bind({"cmd", "shift"}, "U", function()
  109. local win = hs.window.focusedWindow()
  110. local f = win:frame()
  111. local screen = win:screen()
  112. local max = screen:frame()
  113. f.x = max.x
  114. f.y = max.y
  115. f.w = max.w * (4 / 10)
  116. f.h = max.h
  117. win:setFrame(f)
  118. max_iterm()
  119. end)
  120. -- Moves the window to the right 40% of the screen
  121. hs.hotkey.bind({"cmd", "shift"}, "P", function()
  122. local win = hs.window.focusedWindow()
  123. local f = win:frame()
  124. local screen = win:screen()
  125. local max = screen:frame()
  126. f.x = max.x + (max.w * (6/10))
  127. f.y = max.y
  128. f.w = max.w * (4 / 10)
  129. f.h = max.h
  130. win:setFrame(f)
  131. max_iterm()
  132. end)
  133. -- Moves the window to the left 60% of the screen
  134. hs.hotkey.bind({"cmd", "shift"}, "I", function()
  135. local win = hs.window.focusedWindow()
  136. local f = win:frame()
  137. local screen = win:screen()
  138. local max = screen:frame()
  139. f.x = max.x
  140. f.y = max.y
  141. f.w = max.w * (6 / 10)
  142. f.h = max.h
  143. win:setFrame(f)
  144. max_iterm()
  145. end)
  146. -- Moves the window to the right 60% of the screen
  147. hs.hotkey.bind({"cmd", "shift"}, "O", function()
  148. local win = hs.window.focusedWindow()
  149. local f = win:frame()
  150. local screen = win:screen()
  151. local max = screen:frame()
  152. f.x = max.x + (max.w * (4/10))
  153. f.y = max.y
  154. f.w = max.w * (6 / 10)
  155. f.h = max.h
  156. win:setFrame(f)
  157. max_iterm()
  158. end)
  159. -- Launches or focuses iTerm
  160. hs.hotkey.bind({"cmd"}, "\\", function()
  161. hs.application.launchOrFocus("iTerm2")
  162. end)
  163. -- Launches new Incognito Window IF chrome is active window
  164. function chrome_new_incognito()
  165. local win = hs.window.focusedWindow()
  166. if win:application():name() == "Google Chrome" then
  167. hs.application.launchOrFocus("Google Chrome")
  168. local chrome = hs.appfinder.appFromName("Google Chrome")
  169. local str_default = {"File", "New Incognito Window"}
  170. local default = chrome:findMenuItem(str_default)
  171. chrome:selectMenuItem(str_default)
  172. end
  173. end
  174. hs.hotkey.bind({"cmd", "alt", "shift"}, 'N', chrome_new_incognito)
  175. function max_iterm()
  176. local win = hs.window.focusedWindow()
  177. if win:application():name() == "iTerm2" then
  178. hs.application.launchOrFocus("iTerm2")
  179. local term = hs.appfinder.appFromName("iTerm2")
  180. local str_default = {"Window", "Zoom"}
  181. local default = term:findMenuItem(str_default)
  182. term:selectMenuItem(str_default)
  183. end
  184. end