Last active
February 7, 2021 18:54
-
-
Save Dima-369/3a8fa43b54ef9a6f612e585bea2ee0dc to your computer and use it in GitHub Desktop.
Open 2 Finder windows side by side in Hammerspoon
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- using real hyper with shift breaks some hotkeys for whatever reason | |
hyper = {"cmd", "alt", "ctrl"} | |
-- workaround from https://github.com/Hammerspoon/hammerspoon/issues/2099#issuecomment-490503167 | |
function execAppleScript(scpt) | |
local scpt = 'run script ((POSIX file "' .. scpt .. '") as alias)' | |
hs.osascript.applescript(scpt) | |
end | |
hs.hotkey.bind(hyper, "n", function() | |
execAppleScript('/Users/Gira/dotfiles/mac/two-finders.scpt') | |
end) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- based on https://copiancestral.wordpress.com/2012/03/24/two-finders-side-by-side/ | |
tell application "Finder" | |
set targetFolder to POSIX file "/Users/Gira/" | |
-- get number of open finders | |
set NumberofFinders to count every Finder window | |
if NumberofFinders is 0 then | |
make Finder window to targetFolder | |
end if | |
set screenWidth to 1440 | |
set screenHeight to 900 | |
-- move finder and set the size | |
set the position of the front Finder window to {0, 0} | |
set the bounds of the front Finder window to {0, 0, screenWidth * 0.5, screenHeight * 0.9} | |
-- make second finder | |
make Finder window to targetFolder | |
set the target of Finder window 1 to home | |
set the position of the front Finder window to {screenWidth * 0.5, 0} | |
set the bounds of the front Finder window to {screenWidth * 0.5, 0, screenWidth, screenHeight * 0.9} | |
-- bring the finders to the front | |
activate | |
end tell |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment