Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

macOS Sierra Support #10

Merged
merged 93 commits into from
Jan 28, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
93 commits
Select commit Hold shift + click to select a range
13bdcee
Port core caps lock mappings for macOS Sierra
jasonrudolph Nov 20, 2016
018e5e8
Translate caps lock + space to control + space
jasonrudolph Nov 20, 2016
794ad1d
:nail_care:
jasonrudolph Nov 20, 2016
d4ec969
Port hyper key app launching to macOS Sierra
jasonrudolph Nov 20, 2016
73a9264
Use caps lock + r to reload hammerspoon config
jasonrudolph Nov 20, 2016
5285cb5
Play nicely with Lua garbage collection
jasonrudolph Nov 20, 2016
50f81a8
Organize hammerspoon config into separate files
jasonrudolph Nov 20, 2016
b89f439
Add preliminary support for window management via hammerspoon
jasonrudolph Nov 20, 2016
f11c517
Use sequential keybindings for window layout
jasonrudolph Nov 20, 2016
2afe21b
Refactor: Extract function
jasonrudolph Nov 20, 2016
e2ff2e9
Use caps lock + ` to reload hammerspoon config
jasonrudolph Nov 20, 2016
b573aa1
Add placeholders for more window management fns
jasonrudolph Dec 11, 2016
cb1e76b
BetterCapsLockMode: Translate h/j/k/l to up/down/left/right
jasonrudolph Dec 11, 2016
33bcbb3
Remove obsolete assets related to legacy Karabiner & Seil
jasonrudolph Dec 11, 2016
88683df
Update README to describe beginnings of macOS Sierra port
jasonrudolph Dec 11, 2016
77a044d
Add screenshot for Hammerspoon accessibility permissions
jasonrudolph Dec 11, 2016
586756d
Improve screenshot
jasonrudolph Dec 11, 2016
89adde3
Fix comment
jasonrudolph Dec 15, 2016
032f9a9
BetterCapsLockMode: Translate i/o to previous/next tab
jasonrudolph Dec 15, 2016
3fb5e77
Implement (S)uper (D)uper Mode with Hammerspoon
jasonrudolph Dec 17, 2016
d5fd051
Translate caps lock + a/k/u to control + a/k/u
jasonrudolph Dec 18, 2016
b5eff7d
Remove obsolete line in README
jasonrudolph Dec 18, 2016
f650bc1
Extract keyUpDown function
jasonrudolph Dec 18, 2016
32f4381
Simplify logging
jasonrudolph Dec 18, 2016
a1bd49b
Fix logging
jasonrudolph Dec 18, 2016
1b89ca4
Remove scratchpad notes from README
jasonrudolph Dec 18, 2016
8cb45d3
Remove unnecessary setup steps from README
jasonrudolph Dec 18, 2016
d00db27
Configure ability to navigate to previous/next word in iTerm2
jasonrudolph Dec 18, 2016
7decd06
:nail_care:
jasonrudolph Dec 18, 2016
653307c
Use option+h/l to delete previous/next word
jasonrudolph Dec 18, 2016
ee44121
Use option+h/l to delete previous/next word in terminal
jasonrudolph Dec 18, 2016
5085f66
Translate caps lock + h/j/k/l to control + h/j/k/l
jasonrudolph Dec 18, 2016
1e73116
Improve variable name
jasonrudolph Dec 19, 2016
accbf18
Clarify process for using WindowLayout mode
jasonrudolph Jan 1, 2017
43aba11
Add support for sending windows to corners of screen
jasonrudolph Jan 1, 2017
bb4c494
Tweak docs
jasonrudolph Jan 1, 2017
07be5b7
Add support for centering window
jasonrudolph Jan 1, 2017
b2aeec7
Add support for moving window to next screen
jasonrudolph Jan 1, 2017
8027eff
Tweak language
jasonrudolph Jan 1, 2017
326a768
Reliably reset modifiers when exiting Super Duper Mode
jasonrudolph Jan 2, 2017
bcd34f7
Refactor: Extract function
jasonrudolph Jan 2, 2017
fff78c9
Remove unnecessary code
jasonrudolph Jan 2, 2017
7e12648
Super Duper Mode: Use u/p to go to first/last tab
jasonrudolph Jan 2, 2017
a31380a
Upgrade to Karabiner-Elements 0.90.72
jasonrudolph Jan 2, 2017
e09a40e
Upgrade to Hammerspoon 0.9.52
jasonrudolph Jan 2, 2017
01a7a5b
Adopt alternative impl for mapping caps lock to ctrl/esc
jasonrudolph Jan 2, 2017
9f70290
Remove obsolete caps lock customizations
jasonrudolph Jan 2, 2017
c36f275
Tweak README
jasonrudolph Jan 2, 2017
1f5dd53
Remove obsolete reference to 'BetterCapsLock'
jasonrudolph Jan 3, 2017
1bbec3a
Port first bits of Markdown Mode to macOS Sierra
jasonrudolph Jan 3, 2017
0b6709c
Upgrade to Karabiner-Elements 0.90.73
jasonrudolph Jan 7, 2017
70bd98f
Port markdown inline link command to macOS Sierra
jasonrudolph Jan 7, 2017
d89e4f9
Bind WindowLayout Mode to Control+s instead of Control+w
jasonrudolph Jan 7, 2017
46d0efd
Use control+dash/pipe to split iTerm 2 panes
jasonrudolph Jan 7, 2017
9672f5d
Don't show HS notification until *everything* has run
jasonrudolph Jan 7, 2017
60a6286
Refer to iTerm2 consistently
jasonrudolph Jan 7, 2017
89e8bb4
Use control+h/j/k/l to navigate panes in iTerm2
jasonrudolph Jan 7, 2017
9559c17
Refactor panes.lua
jasonrudolph Jan 7, 2017
32066f5
Update set-up steps to ensure ~/.config/karabiner/ exists
jasonrudolph Jan 8, 2017
25e74a4
Use custom keystroke fn to trigger esc faster after ctrl tap
jasonrudolph Jan 9, 2017
7e73ebe
Upgrade to Karabiner-Elements 0.90.75
jasonrudolph Jan 9, 2017
0f65ca4
Extract fn: enableHotkeyForWindowsMatchingFilter
jasonrudolph Jan 10, 2017
bcccbf8
Remove unnecessary comment
jasonrudolph Jan 10, 2017
2d97b84
Use control+u to delete to beginning of line
jasonrudolph Jan 10, 2017
657a58b
:nail_care:
jasonrudolph Jan 11, 2017
82b3a2d
We only need 1 keystroke (not 2) to delete to start of line
jasonrudolph Jan 11, 2017
cee11c7
Define keybinding earlier
jasonrudolph Jan 11, 2017
35ac2af
Upgrade to Karabiner-Elements 0.90.76
jasonrudolph Jan 12, 2017
617316f
Link to relevant docs in inputrc
jasonrudolph Jan 13, 2017
266997e
Use control+; to delete to end of line
jasonrudolph Jan 13, 2017
721d4a3
Allow a bit more time for async events to complete
jasonrudolph Jan 13, 2017
2d7a38d
Port simple version of Markdown Mode status message to Sierra
jasonrudolph Jan 14, 2017
6250982
Show status message when in WindowLayout Mode
jasonrudolph Jan 14, 2017
2a11b0b
Construct status message drawings lazily
jasonrudolph Jan 14, 2017
fe2c0c4
Tell Karabiner-Elements to ignore yubikey
jasonrudolph Jan 14, 2017
eb4b829
Show status message when in (S)uper (D)uper Mode
jasonrudolph Jan 14, 2017
8dcedef
Destroy any existing status drawings before creating new ones
jasonrudolph Jan 14, 2017
3598ce5
Allow control-s to exit WindowLayout Mode
jasonrudolph Jan 14, 2017
45ad832
Allow control-m to exit Markdown Mode
jasonrudolph Jan 14, 2017
c895198
Disable debug logging
jasonrudolph Jan 14, 2017
f5fe71f
Rename screenshot file
jasonrudolph Jan 16, 2017
19c780b
Add screenshot for configuring apps to launch at login
jasonrudolph Jan 16, 2017
65bbdd8
Update to latest release of Karabiner-Elements
jasonrudolph Jan 22, 2017
24d438d
Fix slow-down in WindowLayout Mode & Markdown Mode
jasonrudolph Jan 23, 2017
7dd4871
Use Hammerspoon's top-level API for emitting keystroke
jasonrudolph Jan 25, 2017
f8c2d3b
Use Hackable Slack Client as chat app
jasonrudolph Jan 27, 2017
67e4c75
Remove obsolete directory
jasonrudolph Jan 27, 2017
c53f64f
Overhaul the README
jasonrudolph Jan 27, 2017
2082427
Fix mode name in README
jasonrudolph Jan 27, 2017
b30eb6c
Add keyboard images for Window Layout Mode
jasonrudolph Jan 27, 2017
dc3c7dc
Use higher-resolution images
jasonrudolph Jan 28, 2017
21e9394
Add keyboard images for (S)uper (D)uper Mode
jasonrudolph Jan 28, 2017
6835316
Render images a bit larger in README
jasonrudolph Jan 28, 2017
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
198 changes: 112 additions & 86 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,133 +43,159 @@ While I find that these customizations yield a more-useful keyboard for me, they
These customizations currently provide a fraction of what I want from my more-useful keyboard.
I find it to be a very useful fraction, but I don't consider it complete by any means.

Here's what it provides so far:
## Features

![Karabiner Change Key Configuration - 01](screenshots/karabiner-change-key-config-01.png)
- [Access **control** and **escape** on the home row](#a-more-useful-caps-lock-key)
- [Navigate (up/down/left/right) via the home row](#super-duper-mode)
- [Navigate to previous/next word via the home row](#super-duper-mode)
- [Arrange windows via the home row](#window-layout-mode)
- [Enable other commonly-used actions on or near the home row](#miscellaneous-goodness)
- [Format text as Markdown](#markdown-mode)
- [Launch commonly-used apps via global keyboard shortcuts](#hyper-key-for-quickly-launching-apps)
- [And more...](#miscellaneous-goodness)

![Karabiner Change Key Configuration - 02](screenshots/karabiner-change-key-config-02.png)
### A more useful caps lock key

![Karabiner Change Key Configuration - 03](screenshots/karabiner-change-key-config-03.png)
By repurposing the anachronistic **caps lock** key, we can make **control** and **escape** accessible via the home row.

![Karabiner Change Key Configuration - 04](screenshots/karabiner-change-key-config-04.png)
- Tap **caps lock** for **escape**
- Hold **caps lock** for **control**

## Dependencies
### (S)uper (D)uper Mode

This setup is honed and tested with the following dependencies.
To activate, push the **s** and **d** keys simultaneously and hold them down. Now you're in (S)uper (D)uper Mode. It's like a secret keyboard _inside_ your keyboard. (Whoa.) It's optimized for keeping you on the home row, or very close to it. Now you can:

- OS X El Capitan, 10.11
- [Seil 12.1][seil]
- [Karabiner 10.21][karabiner]
- [SizeUp 1.7][sizeup] (optional)
- Use **h**/**j**/**k**/**l** for **up**/**down**/**left**/**right** respectively
- Use **a** for **option** (AKA **alt**)
- Use **f** for **command**
- Use **space** for **shift**
- Use **a** + **j**/**k** for **page down**/**page up**
- Use **i**/**o** to move to the previous/next tab
- Use **u**/**p** to go to the first/last tab (in most apps)
- Use **a** + **h**/**l** to move to previous/next word (in most apps)

## The Setup
[<img width="400" alt="(S)uper (D)uper Mode Keybindings" src="https://cloud.githubusercontent.com/assets/2988/22397420/f2b3e346-e53e-11e6-97bb-9db71f86994b.png">](https://cloud.githubusercontent.com/assets/2988/22397420/f2b3e346-e53e-11e6-97bb-9db71f86994b.png)

### Grab the bits
### Window Layout Mode

```sh
git clone https://github.com/jasonrudolph/keyboard.git
Quickly arrange and resize windows in common configurations, using keyboard shortcuts that are on or near the home row.

cd keyboard
Use **control** + **s** to turn on Window Layout Mode. Then, use any shortcut below to make windows do your bidding. For example, to send the window left, hit **control** + **s**, and then hit **h**.

mkdir -p ~/Library/Application\ Support/Karabiner
- Use **h** to send window left (left half of screen)
- Use **j** to send window down (bottom half of screen)
- Use **k** to send window up (top half of screen)
- Use **l** to send window right (right half of screen)
- Use **i** to send window to upper left quarter of screen
- Use **o** to send window to upper right quarter of screen
- Use **,** to send window to lower left quarter of screen
- Use **.** to send window to lower right quarter of screen
- Use **space** to send window to center of screen
- Use **enter**: Resize window to fill the screen
- Use **n** to send window to next monitor
- Use **control** + **s** to exit Window Layout Mode without moving any windows

# Prepare custom settings for Karabiner
ln -s $PWD/karabiner/private.xml \
~/Library/Application\ Support/Karabiner/private.xml
[<img src="https://cloud.githubusercontent.com/assets/2988/22397114/715cc12e-e538-11e6-9dcd-b3447af0d9dd.png" alt="Window Layout Mode Keybindings (1)" width="400"/>](https://cloud.githubusercontent.com/assets/2988/22397114/715cc12e-e538-11e6-9dcd-b3447af0d9dd.png) [<img src="https://cloud.githubusercontent.com/assets/2988/22397111/45672fe6-e538-11e6-905d-5b0234e290bb.png" alt="Window Layout Mode Keybindings (2)" width="400"/>](https://cloud.githubusercontent.com/assets/2988/22397111/45672fe6-e538-11e6-905d-5b0234e290bb.png)

ln -s $PWD/karabiner/ext \
~/Library/Application\ Support/Karabiner/ext
```
### Markdown Mode

### Install the apps
Perform common Markdown-formatting tasks anywhere that you're editing text (e.g. in a GitHub comment, in your editor, in your email client).

- Install [Seil][seil]
- Install [Karabiner][karabiner]
- Install [SizeUp][sizeup] (optional)
Use **control** + **m** to turn on Markdown Mode. Then, use any shortcut below to perform an action. For example, to wrap the selected text in double asterisks, hit **control** + **m**, and then **b**.

### Put _control_ and _escape_ on the home row
- Use **b** to wrap the currently-selected text in double asterisks ("B" for "Bold")

#### Goals
Example: `**selection**`

- Tap **caps lock** for **escape**
- Hold **caps lock** for **control**
- Access the default **caps lock** behavior in those rare cases where it's helpful
- Use **i** to wrap the currently-selected text in single asterisks ("I" for "Italic")

#### Making it happen
Example: `**selection**`

1. Launch Seil.
2. Enable the "Change Caps Lock" option, and map **caps lock** to keycode 80.
(80 is **F19**. I don't have a physical **F19** key, so this setting will not
conflict with any existing keys.)
[[screenshot][seil-screenshot]]
3. Launch Karabiner.
4. In the "Change Key" tab, enable the "F19 to Escape/Control" option.
[[screenshot][karabiner-change-key-screenshot-01]]
5. In the "Change Key" tab, enable the "Double-tap Left Shift for CapsLock" option.
6. In the "Key Repeat" tab, change the "[Key Overlaid Modifier] Timeout" to
300ms. (As [recommended][modern-space-cadet-key-repeat] by Steve Losh, I find
that this avoids accidentally triggering **escape** when you meant to trigger
**control**.)
[[screenshot][karabiner-key-repeat-screenshot]]
- Use **s** to wrap the currently-selected text in double tildes ("S" for "Strikethrough")

### Unleash (S)uper (D)uper mode
Example: `~~selection~~`

#### Goals
- Use **l** to convert the currently-selected text to an inline link, using a URL from the clipboard ("L" for "Link")

- Enable navigation (up/down/left/right) via the home row
- Enable word navigation (option+left/right) via the home row
- Enable other commonly-used actions on or near the home row
Example: `[selection](clipboard)`

#### Making it happen
- Use **control** + **m** to exit Markdown Mode without performing any actions

1. Launch Karabiner.
2. In the "Change Key" tab, enable the "(S)uper (D)uper Mode" option.
[[screenshot][karabiner-change-key-screenshot-02]]
### Hyper key for quickly launching apps

### Control SizeUp from the home row
macOS doesn't have a native **hyper** key. But thanks to Karabiner-Elements, we can [create our own](karabiner/karabiner.json).

#### Goals
In this setup, we'll use the **right option** key as our **hyper** key. With a new modifier key defined, we open a whole world of possibilities. I find it especially useful for providing global shortcuts for launching apps:

- Quickly arrange and resize windows in common configurations, using keyboard
shortcuts that are on or near the home row
- **hyper** + **a** to open iTunes ("A" for "Apple Music")
- **hyper** + **b** to open Google Chrome ("B" for "Browser")
- **hyper** + **c** to open [Hackable Slack Client](https://github.com/bhuga/hackable-slack-client) ("C for "Chat")
- **hyper** + **d** to open [Remember The Milk](https://www.rememberthemilk.com/) ("D" for "Do!" ... or "Done!")
- **hyper** + **e** to open [Atom Beta](https://atom.io/beta) ("E" for "Editor")
- **hyper** + **f** to open Finder ("F" for "Finder")
- **hyper** + **g** to open [Mailplane](http://mailplaneapp.com/) ("G" for "Gmail")
- **hyper** + **t** to open [iTerm2](https://www.iterm2.com/) ("T" for "Terminal")

#### Making it happen
Edit [`hammerspoon/hyper.lua`](hammerspoon/hyper.lua) to configure shortcuts to launch your most commonly-used apps.

1. Launch Karabiner.
2. In the "Change Key" tab, enable the "SizeUp Mode" option.
[[screenshot][karabiner-change-key-screenshot-03]]
### Miscellaneous goodness

### Format text as Markdown
- Use **control** + **-** (dash) to split iTerm2 panes horizontally
- Use **control** + **|** (pipe) split iTerm2 panes vertically
- Use **control** + **h**/**j**/**k**/**l** to move left/down/up/right by one pane in iTerm2
- Use **control** + **u** to delete to the start of the line
- Use **control** + **;** to delete to the end of the line
- Use **option** + **h**/**l** to delete the previous/next word

#### Goals
## Dependencies

- Perform common Markdown-formatting tasks anywhere that you're editing text
(e.g. in a GitHub comment, in your editor, in your email client)
This setup is honed and tested with the following dependencies.

#### Making it happen
- macOS Sierra, 10.12
- [Karabiner-Elements 0.90.83][karabiner]
- [Hammerspoon 0.9.52][hammerspoon]

1. Launch Karabiner.
2. In the "Change Key" tab, enable the "Markdown Mode" option.
[[screenshot][karabiner-change-key-screenshot-04]]
## Installation

## TODO
1. Grab the bits

```sh
git clone https://github.com/jasonrudolph/keyboard.git

- Document usage of "Hyper" key
- Incorporate [Keyboard Maestro][keyboard-maestro] configuration
- Add `./script/setup` command to automate the manual setup steps
cd keyboard

# Prepare custom settings for Karabiner-Elements
mkdir -p ~/.config/karabiner/
ln -s $PWD/karabiner/karabiner.json ~/.config/karabiner/karabiner.json

# Prepare custom settings for Hammerspoon
ln -s $PWD/hammerspoon ~/.hammerspoon

# Prepare custom settings for navigating between words in iTerm2
cat $PWD/inputrc >> ~/.inputrc
```

2. Install [Karabiner-Elements][karabiner]

1. Install it
2. Launch it
3. Configure it to launch at login [[screenshot](screenshots/login-items-for-karabiner-and-hammerspoon.png)]

3. Install [Hammerspoon][hammerspoon-releases]

1. Install it
2. Launch it
3. Configure it to launch at login [[screenshot](screenshots/login-items-for-karabiner-and-hammerspoon.png)]
4. Enable accessibility to allow Hammerspoon to do its thing [[screenshot]](screenshots/accessibility-permissions-for-hammerspoon.png)

## TODO

- [ ] Add `./script/setup` command to automate the manual setup steps

[customize]: http://dictionary.reference.com/browse/customize
[don't-make-me-think]: http://en.wikipedia.org/wiki/Don't_Make_Me_Think
[keyboard-maestro]: http://keyboardmaestro.com
[karabiner]: http://pqrs.org/macosx/karabiner/
[karabiner-change-key-screenshot-01]: screenshots/karabiner-change-key-config-01.png
[karabiner-change-key-screenshot-02]: screenshots/karabiner-change-key-config-02.png
[karabiner-change-key-screenshot-03]: screenshots/karabiner-change-key-config-03.png
[karabiner-change-key-screenshot-04]: screenshots/karabiner-change-key-config-04.png
[karabiner-key-repeat-screenshot]: screenshots/karabiner-key-repeat-config.png
[karabiner]: https://github.com/tekezo/Karabiner-Elements
[hammerspoon]: http://www.hammerspoon.org
[hammerspoon-releases]: https://github.com/Hammerspoon/hammerspoon/releases
[modern-space-cadet]: http://stevelosh.com/blog/2012/10/a-modern-space-cadet
[modern-space-cadet-key-repeat]: http://stevelosh.com/blog/2012/10/a-modern-space-cadet/#controlescape
[seil]: https://pqrs.org/macosx/keyremap4macbook/seil.html.en
[seil-screenshot]: screenshots/seil-config.png
[sizeup]: http://www.irradiatedsoftware.com/sizeup/
43 changes: 43 additions & 0 deletions hammerspoon/control-escape.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
-- Credit for this implementation goes to @arbelt and @jasoncodes 馃檱鈿★笍馃樆
--
-- https://gist.github.com/arbelt/b91e1f38a0880afb316dd5b5732759f1
-- https://github.com/jasoncodes/dotfiles/blob/ac9f3ac/hammerspoon/control_escape.lua

send_escape = false
last_mods = {}

control_key_handler = function()
send_escape = false
end

control_key_timer = hs.timer.delayed.new(0.15, control_key_handler)

control_handler = function(evt)
local new_mods = evt:getFlags()
if last_mods["ctrl"] == new_mods["ctrl"] then
return false
end
if not last_mods["ctrl"] then
last_mods = new_mods
send_escape = true
control_key_timer:start()
else
if send_escape then
keyUpDown({}, 'escape')
end
last_mods = new_mods
control_key_timer:stop()
end
return false
end

control_tap = hs.eventtap.new({hs.eventtap.event.types.flagsChanged}, control_handler)
control_tap:start()

other_handler = function(evt)
send_escape = false
return false
end

other_tap = hs.eventtap.new({hs.eventtap.event.types.keyDown}, other_handler)
other_tap:start()
70 changes: 70 additions & 0 deletions hammerspoon/delete-words.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
local log = hs.logger.new('delete-words.lua', 'debug')

local isInTerminal = function()
app = hs.application.frontmostApplication():name()
return app == 'iTerm2' or app == 'Terminal'
end

-- Use option + h to delete previous word
hs.hotkey.bind({'alt'}, 'h', function()
if isInTerminal() then
keyUpDown({'ctrl'}, 'w')
else
keyUpDown({'alt'}, 'delete')
end
end)

-- Use option + l to delete next word
hs.hotkey.bind({'alt'}, 'l', function()
if isInTerminal() then
keyUpDown({}, 'escape')
keyUpDown({}, 'd')
else
keyUpDown({'alt'}, 'forwarddelete')
end
end)

-- Use control + u to delete to beginning of line
--
-- In bash, control + u automatically deletes to the beginning of the line, so
-- we don't need (or want) this hotkey in the terminal. If this hotkey was
-- enabled in the terminal, it would break the standard control + u behavior.
-- Therefore, we only enable this hotkey for non-terminal apps.
local wf = hs.window.filter.new():setFilters({iTerm2 = false, Terminal = false})
enableHotkeyForWindowsMatchingFilter(wf, hs.hotkey.new({'ctrl'}, 'u', function()
keyUpDown({'cmd'}, 'delete')
end))

-- Use control + ; to delete to end of line
--
-- I prefer to use control+h/j/k/l to move left/down/up/right by one pane in all
-- multi-pane apps (e.g., iTerm, various editors). That's convenient and
-- consistent, but it conflicts with the default macOS binding for deleting to
-- the end of the line (i.e., control+k). To maintain that very useful
-- functionality, and to keep it on the home row, this hotkey binds control+; to
-- delete to the end of the line.
hs.hotkey.bind({'ctrl'}, ';', function()
-- If we're in the terminal, then temporarily disable our custom control+k
-- hotkey used for pane navigation, then fire control+k to delete to the end
-- of the line, and then renable the control+k hotkey.
--
-- If we're not in the terminal, then just select to the end of the line and
-- then delete the selected text.
if isInTerminal() then
hotkeyForControlK = hs.fnutils.find(hs.hotkey.getHotkeys(), function(hotkey)
return hotkey.idx == '鈱僈'
end)
if hotkeyForControlK then hotkeyForControlK:disable() end

keyUpDown({'ctrl'}, 'k')

-- Allow some time for the control+k keystroke to fire asynchronously before
-- we re-enable our custom control+k hotkey.
hs.timer.doAfter(0.2, function()
if hotkeyForControlK then hotkeyForControlK:enable() end
end)
else
keyUpDown({'cmd', 'shift'}, 'right')
keyUpDown({}, 'forwarddelete')
end
end)
33 changes: 33 additions & 0 deletions hammerspoon/hyper.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
-- A global variable for Hyper Mode
hyperMode = hs.hotkey.modal.new({}, 'F18')

-- Keybindings for launching apps in Hyper Mode
hyperModeAppMappings = {
{ 'a', 'iTunes' }, -- "A" for "Apple Music"
{ 'b', 'Google Chrome' }, -- "B" for "Browser"
{ 'c', 'Hackable Slack Client' }, -- "C for "Chat"
{ 'd', 'Remember The Milk' }, -- "D" for "Do!" ... or "Done!"
{ 'e', 'Atom Beta' }, -- "E" for "Editor"
{ 'f', 'Finder' }, -- "F" for "Finder"
{ 'g', 'Mailplane 3' }, -- "G" for "Gmail"
{ 't', 'iTerm' }, -- "T" for "Terminal"
}

for i, mapping in ipairs(hyperModeAppMappings) do
hyperMode:bind({}, mapping[1], function()
hs.application.launchOrFocus(mapping[2])
end)
end

-- Enter Hyper Mode when F17 (right option key) is pressed
pressedF17 = function()
hyperMode:enter()
end

-- Leave Hyper Mode when F17 (right option key) is released.
releasedF17 = function()
hyperMode:exit()
end

-- Bind the Hyper key
f17 = hs.hotkey.bind({}, 'F17', pressedF17, releasedF17)
Loading