<commit_before>function getContext()
    local win = hs.window.focusedWindow()
    local f = win:frame()
    local screen = win:screen()
    local max = screen:frame()
    return win, f, screen, max
end

function nextScreen()
    local win = hs.window.focusedWindow()
    local f = win:frame()
    local screen = win:screen():next()
    local max = screen:frame()

    f.x = max.x
    f.y = max.y

    win:setFrame(f)
end

function previousScreen()
    local win = hs.window.focusedWindow()
    local f = win:frame()
    local screen = win:screen():previous()
    local max = screen:frame()

    f.x = max.x
    f.y = max.y

    win:setFrame(f)
end

--left half
hs.hotkey.bind({"cmd"}, "1", function()
    local win, f, screen, max = getContext()

    if f.x == max.x and f.y == max.y and f.h == (max.h - 5) and f.w == (max.w / 2) then
        screen = win:screen():next()
    end
    f.x = max.x
    f.y = max.y
    f.h = max.h
    f.w = max.w / 2

    win:setFrame(f)
end)

--right half
hs.hotkey.bind({"cmd"}, "2", function()
    local win, f, screen, max = getContext()

    f.x = max.x + (max.w / 2)
    f.y = max.y
    f.h = max.h
    f.w = max.w / 2

    win:setFrame(f)
end)


--full screen
hs.hotkey.bind({"cmd"}, "3", function()
    local win, f, screen, max = getContext()

    f.x = max.x
    f.y = max.y
    f.h = max.h
    f.w = max.w

    win:setFrame(f)
end)

--left third
hs.hotkey.bind({"cmd", "alt"}, "1", function()
    local win, f, screen, max = getContext()
    f.x = max.x
    f.y = max.y
    f.h = max.h
    f.w = max.w / 3

    win:setFrame(f)
end)

--middle third<commit_msg>Full and half screens switch windows when pressed twice<commit_after>function getContext()
    local win = hs.window.focusedWindow()
    local f = win:frame()
    local screen = win:screen()
    local max = screen:frame()
    return win, f, screen, max
end

function nextScreen()
    local win = hs.window.focusedWindow()
    local f = win:frame()
    local screen = win:screen():next()
    local max = screen:frame()

    f.x = max.x
    f.y = max.y

    win:setFrame(f)
end

function previousScreen()
    local win = hs.window.focusedWindow()
    local f = win:frame()
    local screen = win:screen():previous()
    local max = screen:frame()

    f.x = max.x
    f.y = max.y

    win:setFrame(f)
end

--left half
hs.hotkey.bind({"cmd"}, "1", function()
    local win, f, screen, max = getContext()

    if f.x == max.x and f.y == max.y and f.h == max.h and f.w == (max.w / 2) then
        nextScreen()
        win, f, screen, max = getContext()
    end

    f.x = max.x
    f.y = max.y
    f.h = max.h
    f.w = max.w / 2

    win:setFrame(f)
end)

--right half
hs.hotkey.bind({"cmd"}, "2", function()
    local win, f, screen, max = getContext()

    if f.x == max.x + (max.w / 2) and f.y == max.y and f.h == max.h and f.w == max.w / 2 then
        nextScreen()
        win, f, screen, max = getContext()
    end

    f.x = max.x + (max.w / 2)
    f.y = max.y
    f.h = max.h
    f.w = max.w / 2

    win:setFrame(f)
end)


--full screen
hs.hotkey.bind({"cmd"}, "3", function()
    local win, f, screen, max = getContext()

    if f.x == max.x and f.y == max.y and f.h == max.h and f.w == max.w then
        nextScreen()
        win, f, screen, max = getContext()
    end

    f.x = max.x
    f.y = max.y
    f.h = max.h
    f.w = max.w
    win:setFrame(f)

end)

--left third
hs.hotkey.bind({"cmd", "alt"}, "1", function()
    local win, f, screen, max = getContext()
    f.x = max.x
    f.y = max.y
    f.h = max.h
    f.w = max.w / 3

    win:setFrame(f)
end)

--middle third
{'fraction_non_alphanumeric': 0.16908482142857142, 'fraction_numerical': 0.005859375, 'mean_word_length': 2.117391304347826, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6852677', 'n_tokens_mistral': 1437, 'n_tokens_neox': 1385, 'n_words': 393}