-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d53a33d
commit 8c83c70
Showing
31 changed files
with
513 additions
and
200 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,131 @@ | ||
--- | ||
title: "Bind Ctrl + hjkl to arrow keys on a Mac Machine" | ||
description: "This is how you can bind Ctrl + hjkl as arrow keys on a mac machine" | ||
date: 2024-07-31T13:55:20-05:00 | ||
draft: false | ||
tags: ["Vim", "Neovim", "Lua", "Linux"] | ||
categories: ["Development"] | ||
# weight: 4 | ||
# lastmod: 2020-01-01T16:45:40+08:00 | ||
# author: "Dillon" | ||
# authorLink: "https://shivas.blog" | ||
# images: [] | ||
# resources: | ||
# - name: "featured-image" | ||
# src: "featured-image.png" | ||
# lightgallery: true | ||
--- | ||
|
||
### What this post covers? | ||
So instead of reaching to arrow keys, you can just use h (as left arrow), j (as down arrow) k (as up arrow) and l (as right arrow) by hoding ctrl key. | ||
|
||
### Before we start | ||
First things first, we need to install a free tool called Hammerspoon. This tool will allow us to configure the key bindings. | ||
|
||
## Keyboard Settings on Mac | ||
Navigate to System Settings > Keyboard > Keyboard Shortcut > Modifier Keys (left pane). Select your keyboard, and for the Caps Lock key, choose Control from the drop-down menu. | ||
|
||
This will make the Caps Lock key function as the Control key (you can always change it back to Caps Lock if needed). Since I rarely use the Caps Lock function, I repurposed this key. You can select any other key from the drop-down that suits you better. | ||
|
||
## Hammerspoon Config | ||
If don't exist already, creat a new file at the following location ~/.hammerspoon/init.lua and enter the following code | ||
``` | ||
mkdir -p ~/.hammerspoon | ||
touch ~/.hammerspoon/init.lua | ||
``` | ||
|
||
```lua | ||
-- Boolean to track if mappings are enabled: | ||
local mappingsEnabled = false | ||
|
||
-- Function to bind `hjkl` to arrow keys with Control as a modifier | ||
function mapControlToArrows() | ||
local controlModifier = {"ctrl"} | ||
local controlShiftModifier = {"ctrl", "shift"} | ||
local repeatDelay = 0.1 | ||
local repeatInterval = 0.05 | ||
|
||
-- Bind Control + h to left arrow | ||
hs.hotkey.bind(controlModifier, "h", function() | ||
hs.eventtap.keyStroke({}, "left") | ||
end, nil, function() | ||
hs.eventtap.keyStroke({}, "left") | ||
end) | ||
|
||
-- Bind Control + j to down arrow | ||
hs.hotkey.bind(controlModifier, "j", function() | ||
hs.eventtap.keyStroke({}, "down") | ||
end, nil, function() | ||
hs.eventtap.keyStroke({}, "down") | ||
end) | ||
|
||
-- Bind Control + k to up arrow | ||
hs.hotkey.bind(controlModifier, "k", function() | ||
hs.eventtap.keyStroke({}, "up") | ||
end, nil, function() | ||
hs.eventtap.keyStroke({}, "up") | ||
end) | ||
|
||
-- Bind Control + l to right arrow | ||
hs.hotkey.bind(controlModifier, "l", function() | ||
hs.eventtap.keyStroke({}, "right") | ||
end, nil, function() | ||
hs.eventtap.keyStroke({}, "right") | ||
end) | ||
|
||
-- Bind Control + Shift + h to Shift + left arrow | ||
hs.hotkey.bind(controlShiftModifier, "h", function() | ||
hs.eventtap.keyStroke({"shift"}, "left") | ||
end, nil, function() | ||
hs.eventtap.keyStroke({"shift"}, "left") | ||
end) | ||
|
||
-- Bind Control + Shift + j to Shift + down arrow | ||
hs.hotkey.bind(controlShiftModifier, "j", function() | ||
hs.eventtap.keyStroke({"shift"}, "down") | ||
end, nil, function() | ||
hs.eventtap.keyStroke({"shift"}, "down") | ||
end) | ||
|
||
-- Bind Control + Shift + k to Shift + up arrow | ||
hs.hotkey.bind(controlShiftModifier, "k", function() | ||
hs.eventtap.keyStroke({"shift"}, "up") | ||
end, nil, function() | ||
hs.eventtap.keyStroke({"shift"}, "up") | ||
end) | ||
|
||
-- Bind Control + Shift + l to Shift + right arrow | ||
hs.hotkey.bind(controlShiftModifier, "l", function() | ||
hs.eventtap.keyStroke({"shift"}, "right") | ||
end, nil, function() | ||
hs.eventtap.keyStroke({"shift"}, "right") | ||
end) | ||
end | ||
|
||
-- Function to unbind `hjkl` from arrow keys | ||
function unmapControlFromArrows() | ||
hs.hotkey.disableAll() | ||
end | ||
|
||
-- Function to toggle mappings | ||
function toggleMappings() | ||
if mappingsEnabled then | ||
unmapControlFromArrows() | ||
hs.alert.show("Control + hjkl as arrows disabled") | ||
else | ||
mapControlToArrows() | ||
hs.alert.show("Control + hjkl as arrows enabled") | ||
end | ||
mappingsEnabled = not mappingsEnabled | ||
end | ||
|
||
-- Bind the toggle function to a hotkey (e.g., Ctrl+Shift+F1) | ||
hs.hotkey.bind({"ctrl", "shift"}, "F1", toggleMappings) | ||
|
||
-- Initial setup to enable mappings | ||
toggleMappings() | ||
``` | ||
|
||
Save the file and open the Hammerspoon application on your system to reload the configuration. Alternatively, you can reload the config by clicking the Hammerspoon icon in the taskbar and selecting "Reload Config." | ||
|
||
This setup allows you to use the hjkl keys as arrow keys when holding the Control key, helping you code faster and stay more productive. |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
--- | ||
title: "Top Secret" | ||
description: "Password to open the top secret: 1234 " | ||
date: 2024-07-07T13:55:20-05:00 | ||
draft: false | ||
tags: ["Hugo"] | ||
categories: ["Development"] | ||
hiddenFromHomePage: true | ||
password: | ||
|
||
--- | ||
|
||
{{< admonition type=danger title="Top Secret" open=true >}} | ||
1234567890 | ||
{{< /admonition >}} | ||
|
||
just kidding ;) |
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,14 +4,32 @@ | |
<link>https://shiva.dev/categories/development/</link> | ||
<description>Development - Category - shiva.dev</description> | ||
<generator>Hugo -- gohugo.io</generator><language>en</language><managingEditor>[email protected] (Shiva)</managingEditor> | ||
<webMaster>[email protected] (Shiva)</webMaster><lastBuildDate>Sun, 07 Jul 2024 13:55:20 -0500</lastBuildDate><atom:link href="https://shiva.dev/categories/development/" rel="self" type="application/rss+xml" /><item> | ||
<webMaster>[email protected] (Shiva)</webMaster><lastBuildDate>Wed, 31 Jul 2024 13:55:20 -0500</lastBuildDate><atom:link href="https://shiva.dev/categories/development/" rel="self" type="application/rss+xml" /><item> | ||
<title>Bind Ctrl + hjkl to arrow keys on a Mac Machine</title> | ||
<link>https://shiva.dev/posts/bind_ctrl_hjkl_to_arrow_keys_on_mac/</link> | ||
<pubDate>Wed, 31 Jul 2024 13:55:20 -0500</pubDate> | ||
<author>Shiva</author> | ||
<guid>https://shiva.dev/posts/bind_ctrl_hjkl_to_arrow_keys_on_mac/</guid> | ||
<description><![CDATA[What this post covers? So instead of reaching to arrow keys, you can just use h (as left arrow), j (as down arrow) k (as up arrow) and l (as right arrow) by hoding ctrl key. | ||
Before we start First things first, we need to install a free tool called Hammerspoon. This tool will allow us to configure the key bindings. | ||
Keyboard Settings on Mac Navigate to System Settings > Keyboard > Keyboard Shortcut > Modifier Keys (left pane).]]></description> | ||
</item> | ||
<item> | ||
<title>Adding Password Protection To A Hugo Post</title> | ||
<link>https://shiva.dev/posts/adding_password_protection_to_a_hugo_post/</link> | ||
<pubDate>Sun, 07 Jul 2024 13:55:20 -0500</pubDate> | ||
<author>Shiva</author> | ||
<guid>https://shiva.dev/posts/adding_password_protection_to_a_hugo_post/</guid> | ||
<description><![CDATA[In this post, I’ll show you the simplest way to protect a Hugo page with a password by using front matter and adding a new parameter called “password.” This allows you to set a unique password for each post. | ||
proceed with caution This method lacks complete security. Anyone with basic Hugo knowledge can access your repository and view the passwords. Therefore, it’s advisable to avoid sharing sensitive information using this approach.]]></description> | ||
proceed with caution This method lacks complete security. Anyone with basic computer knowledge can access your post or the repository and view the passwords. Therefore, it’s advisable to avoid sharing sensitive information using this approach.]]></description> | ||
</item> | ||
<item> | ||
<title>Top Secret</title> | ||
<link>https://shiva.dev/posts/password/</link> | ||
<pubDate>Sun, 07 Jul 2024 13:55:20 -0500</pubDate> | ||
<author>Shiva</author> | ||
<guid>https://shiva.dev/posts/password/</guid> | ||
<description><![CDATA[Top Secret 1234567890 just kidding ;)]]></description> | ||
</item> | ||
<item> | ||
<title>Top Secret</title> | ||
|
Oops, something went wrong.