Skip to content

Commit 8c83c70

Browse files
committed
added new post on binding hjkl
1 parent d53a33d commit 8c83c70

31 files changed

+513
-200
lines changed

content/posts/adding_password_protection_to_a_hugo_post.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ categories: ["Development"]
1010
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.
1111

1212
{{< admonition type=warning title="proceed with caution" open=true >}}
13-
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. For full password protection, consider using GitHub secrets or variables instead of passwords, though this topic is not covered in this post.
13+
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. For full password protection, consider using GitHub secrets or variables instead of passwords, though this topic is not covered in this post.
1414
{{< /admonition >}}
1515

1616

@@ -22,6 +22,9 @@ This method lacks complete security. Anyone with basic Hugo knowledge can access
2222

2323
Before we proceed, open the post [Top Secret](http://localhost:1313/posts/top_secret/) that is protection with a password. When prompted, enter the password `1234` to read the top secret.
2424

25+
<img src="/images/password-protection.gif" width="original_width" height="original_height" alt="password-protection">
26+
27+
2528
![password-protection](https://global.discourse-cdn.com/standard10/uploads/gohugo/original/3X/f/8/f8f86d4073b44b9e45899e30e92b6a3b8f26fdaf.gif)
2629

2730
----
Lines changed: 131 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,131 @@
1+
---
2+
title: "Bind Ctrl + hjkl to arrow keys on a Mac Machine"
3+
description: "This is how you can bind Ctrl + hjkl as arrow keys on a mac machine"
4+
date: 2024-07-31T13:55:20-05:00
5+
draft: false
6+
tags: ["Vim", "Neovim", "Lua", "Linux"]
7+
categories: ["Development"]
8+
# weight: 4
9+
# lastmod: 2020-01-01T16:45:40+08:00
10+
# author: "Dillon"
11+
# authorLink: "https://shivas.blog"
12+
# images: []
13+
# resources:
14+
# - name: "featured-image"
15+
# src: "featured-image.png"
16+
# lightgallery: true
17+
---
18+
19+
### What this post covers?
20+
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.
21+
22+
### Before we start
23+
First things first, we need to install a free tool called Hammerspoon. This tool will allow us to configure the key bindings.
24+
25+
## Keyboard Settings on Mac
26+
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.
27+
28+
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.
29+
30+
## Hammerspoon Config
31+
If don't exist already, creat a new file at the following location ~/.hammerspoon/init.lua and enter the following code
32+
```
33+
mkdir -p ~/.hammerspoon
34+
touch ~/.hammerspoon/init.lua
35+
```
36+
37+
```lua
38+
-- Boolean to track if mappings are enabled:
39+
local mappingsEnabled = false
40+
41+
-- Function to bind `hjkl` to arrow keys with Control as a modifier
42+
function mapControlToArrows()
43+
local controlModifier = {"ctrl"}
44+
local controlShiftModifier = {"ctrl", "shift"}
45+
local repeatDelay = 0.1
46+
local repeatInterval = 0.05
47+
48+
-- Bind Control + h to left arrow
49+
hs.hotkey.bind(controlModifier, "h", function()
50+
hs.eventtap.keyStroke({}, "left")
51+
end, nil, function()
52+
hs.eventtap.keyStroke({}, "left")
53+
end)
54+
55+
-- Bind Control + j to down arrow
56+
hs.hotkey.bind(controlModifier, "j", function()
57+
hs.eventtap.keyStroke({}, "down")
58+
end, nil, function()
59+
hs.eventtap.keyStroke({}, "down")
60+
end)
61+
62+
-- Bind Control + k to up arrow
63+
hs.hotkey.bind(controlModifier, "k", function()
64+
hs.eventtap.keyStroke({}, "up")
65+
end, nil, function()
66+
hs.eventtap.keyStroke({}, "up")
67+
end)
68+
69+
-- Bind Control + l to right arrow
70+
hs.hotkey.bind(controlModifier, "l", function()
71+
hs.eventtap.keyStroke({}, "right")
72+
end, nil, function()
73+
hs.eventtap.keyStroke({}, "right")
74+
end)
75+
76+
-- Bind Control + Shift + h to Shift + left arrow
77+
hs.hotkey.bind(controlShiftModifier, "h", function()
78+
hs.eventtap.keyStroke({"shift"}, "left")
79+
end, nil, function()
80+
hs.eventtap.keyStroke({"shift"}, "left")
81+
end)
82+
83+
-- Bind Control + Shift + j to Shift + down arrow
84+
hs.hotkey.bind(controlShiftModifier, "j", function()
85+
hs.eventtap.keyStroke({"shift"}, "down")
86+
end, nil, function()
87+
hs.eventtap.keyStroke({"shift"}, "down")
88+
end)
89+
90+
-- Bind Control + Shift + k to Shift + up arrow
91+
hs.hotkey.bind(controlShiftModifier, "k", function()
92+
hs.eventtap.keyStroke({"shift"}, "up")
93+
end, nil, function()
94+
hs.eventtap.keyStroke({"shift"}, "up")
95+
end)
96+
97+
-- Bind Control + Shift + l to Shift + right arrow
98+
hs.hotkey.bind(controlShiftModifier, "l", function()
99+
hs.eventtap.keyStroke({"shift"}, "right")
100+
end, nil, function()
101+
hs.eventtap.keyStroke({"shift"}, "right")
102+
end)
103+
end
104+
105+
-- Function to unbind `hjkl` from arrow keys
106+
function unmapControlFromArrows()
107+
hs.hotkey.disableAll()
108+
end
109+
110+
-- Function to toggle mappings
111+
function toggleMappings()
112+
if mappingsEnabled then
113+
unmapControlFromArrows()
114+
hs.alert.show("Control + hjkl as arrows disabled")
115+
else
116+
mapControlToArrows()
117+
hs.alert.show("Control + hjkl as arrows enabled")
118+
end
119+
mappingsEnabled = not mappingsEnabled
120+
end
121+
122+
-- Bind the toggle function to a hotkey (e.g., Ctrl+Shift+F1)
123+
hs.hotkey.bind({"ctrl", "shift"}, "F1", toggleMappings)
124+
125+
-- Initial setup to enable mappings
126+
toggleMappings()
127+
```
128+
129+
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."
130+
131+
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.

content/posts/password.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
---
2+
title: "Top Secret"
3+
description: "Password to open the top secret: 1234 "
4+
date: 2024-07-07T13:55:20-05:00
5+
draft: false
6+
tags: ["Hugo"]
7+
categories: ["Development"]
8+
hiddenFromHomePage: true
9+
password:
10+
11+
---
12+
13+
{{< admonition type=danger title="Top Secret" open=true >}}
14+
1234567890
15+
{{< /admonition >}}
16+
17+
just kidding ;)

public/404.html

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,17 @@
55
<meta name="viewport" content="width=device-width, initial-scale=1">
66
<meta name="robots" content="noodp" />
77
<title>404 Page not found - shiva.dev</title>
8-
<script src="https://cdnjs.cloudflare.com/ajax/libs/lunr.js/2.3.9/lunr.min.js"></script><meta name="Description" content="A tech blog by Shiva Inampudi"><meta property="og:title" content="404 Page not found" />
9-
<meta property="og:description" content="A tech blog by Shiva Inampudi" />
10-
<meta property="og:type" content="website" />
11-
<meta property="og:url" content="https://shiva.dev/404.html" /><meta property="og:site_name" content="www.shiva.dev" />
8+
<script src="https://cdnjs.cloudflare.com/ajax/libs/lunr.js/2.3.9/lunr.min.js"></script><meta name="Description" content="A tech blog by Shiva Inampudi"><meta property="og:url" content="https://shiva.dev/404.html">
9+
<meta property="og:site_name" content="shiva.dev">
10+
<meta property="og:title" content="404 Page not found">
11+
<meta property="og:description" content="A tech blog by Shiva Inampudi">
12+
<meta property="og:locale" content="en">
13+
<meta property="og:type" content="website">
1214

13-
<meta name="twitter:card" content="summary"/><meta name="twitter:title" content="404 Page not found"/>
14-
<meta name="twitter:description" content="A tech blog by Shiva Inampudi"/>
15-
<meta name="twitter:site" content="@SHlVA_DEV"/>
15+
<meta name="twitter:card" content="summary">
16+
<meta name="twitter:title" content="404 Page not found">
17+
<meta name="twitter:description" content="A tech blog by Shiva Inampudi">
18+
<meta name="twitter:site" content="@SHlVA_DEV">
1619
<meta name="application-name" content="Shiva&#39;s Tech Blog">
1720
<meta name="apple-mobile-web-app-title" content="Shiva&#39;s Tech Blog"><meta name="theme-color" content="#ffffff"><meta name="msapplication-TileColor" content="#da532c"><link rel="shortcut icon" type="image/x-icon" href="/favicon.ico" />
1821
<link rel="icon" type="image/png" sizes="32x32" href="/favicon-32x32.png">
@@ -92,7 +95,7 @@ <h1 id="error-emoji"></h1>
9295
})();
9396
</script></div>
9497
</main><footer class="footer">
95-
<div class="footer-container"><div class="footer-line">Powered by <a href="https://gohugo.io/" target="_blank" rel="noopener noreffer" title="Hugo 0.121.1">Hugo</a> | Theme - <a href="https://github.com/dillonzq/LoveIt" target="_blank" rel="noopener noreffer" title="LoveIt 0.2.10"><i class="far fa-kiss-wink-heart fa-fw" aria-hidden="true"></i> LoveIt</a>
98+
<div class="footer-container"><div class="footer-line">Powered by <a href="https://gohugo.io/" target="_blank" rel="noopener noreffer" title="Hugo 0.129.0">Hugo</a> | Theme - <a href="https://github.com/dillonzq/LoveIt" target="_blank" rel="noopener noreffer" title="LoveIt 0.2.10"><i class="far fa-kiss-wink-heart fa-fw" aria-hidden="true"></i> LoveIt</a>
9699
</div><div class="footer-line" itemscope itemtype="http://schema.org/CreativeWork"><i class="far fa-copyright fa-fw" aria-hidden="true"></i><span itemprop="copyrightYear">2019 - 2024</span><span class="author" itemprop="copyrightHolder">&nbsp;<a href="https://shiva.dev" target="_blank">Shiva</a></span></div>
97100
</div>
98101
</footer></div>

public/categories/development/index.html

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,17 @@
55
<meta name="viewport" content="width=device-width, initial-scale=1">
66
<meta name="robots" content="noodp" />
77
<title>Development - Category - shiva.dev</title>
8-
<script src="https://cdnjs.cloudflare.com/ajax/libs/lunr.js/2.3.9/lunr.min.js"></script><meta name="Description" content="A tech blog by Shiva Inampudi"><meta property="og:title" content="Development" />
9-
<meta property="og:description" content="A tech blog by Shiva Inampudi" />
10-
<meta property="og:type" content="website" />
11-
<meta property="og:url" content="https://shiva.dev/categories/development/" /><meta property="og:site_name" content="www.shiva.dev" />
8+
<script src="https://cdnjs.cloudflare.com/ajax/libs/lunr.js/2.3.9/lunr.min.js"></script><meta name="Description" content="A tech blog by Shiva Inampudi"><meta property="og:url" content="https://shiva.dev/categories/development/">
9+
<meta property="og:site_name" content="shiva.dev">
10+
<meta property="og:title" content="Development">
11+
<meta property="og:description" content="A tech blog by Shiva Inampudi">
12+
<meta property="og:locale" content="en">
13+
<meta property="og:type" content="website">
1214

13-
<meta name="twitter:card" content="summary"/><meta name="twitter:title" content="Development"/>
14-
<meta name="twitter:description" content="A tech blog by Shiva Inampudi"/>
15-
<meta name="twitter:site" content="@SHlVA_DEV"/>
15+
<meta name="twitter:card" content="summary">
16+
<meta name="twitter:title" content="Development">
17+
<meta name="twitter:description" content="A tech blog by Shiva Inampudi">
18+
<meta name="twitter:site" content="@SHlVA_DEV">
1619
<meta name="application-name" content="Shiva&#39;s Tech Blog">
1720
<meta name="apple-mobile-web-app-title" content="Shiva&#39;s Tech Blog"><meta name="theme-color" content="#ffffff"><meta name="msapplication-TileColor" content="#da532c"><link rel="shortcut icon" type="image/x-icon" href="/favicon.ico" />
1821
<link rel="icon" type="image/png" sizes="32x32" href="/favicon-32x32.png">
@@ -81,8 +84,14 @@
8184
<div id="search-dropdown-mobile"></div>
8285
</div><main class="main">
8386
<div class="container"><div class="page archive"><h2 class="single-title animate__animated animate__pulse animate__faster"><i class="far fa-folder-open fa-fw" aria-hidden="true"></i>&nbsp;Development</h2><h3 class="group-title">2024</h3><article class="archive-item">
87+
<a href="/posts/bind_ctrl_hjkl_to_arrow_keys_on_mac/" class="archive-item-link">Bind Ctrl &#43; hjkl to arrow keys on a Mac Machine</a>
88+
<span class="archive-item-date">07-31</span>
89+
</article><article class="archive-item">
8490
<a href="/posts/top_secret/" class="archive-item-link">Top Secret</a>
8591
<span class="archive-item-date">07-07</span>
92+
</article><article class="archive-item">
93+
<a href="/posts/password/" class="archive-item-link">Top Secret</a>
94+
<span class="archive-item-date">07-07</span>
8695
</article><article class="archive-item">
8796
<a href="/posts/adding_password_protection_to_a_hugo_post/" class="archive-item-link">Adding Password Protection To A Hugo Post</a>
8897
<span class="archive-item-date">07-07</span>
@@ -91,7 +100,7 @@
91100
<span class="archive-item-date">06-11</span>
92101
</article></div></div>
93102
</main><footer class="footer">
94-
<div class="footer-container"><div class="footer-line">Powered by <a href="https://gohugo.io/" target="_blank" rel="noopener noreffer" title="Hugo 0.121.1">Hugo</a> | Theme - <a href="https://github.com/dillonzq/LoveIt" target="_blank" rel="noopener noreffer" title="LoveIt 0.2.10"><i class="far fa-kiss-wink-heart fa-fw" aria-hidden="true"></i> LoveIt</a>
103+
<div class="footer-container"><div class="footer-line">Powered by <a href="https://gohugo.io/" target="_blank" rel="noopener noreffer" title="Hugo 0.129.0">Hugo</a> | Theme - <a href="https://github.com/dillonzq/LoveIt" target="_blank" rel="noopener noreffer" title="LoveIt 0.2.10"><i class="far fa-kiss-wink-heart fa-fw" aria-hidden="true"></i> LoveIt</a>
95104
</div><div class="footer-line" itemscope itemtype="http://schema.org/CreativeWork"><i class="far fa-copyright fa-fw" aria-hidden="true"></i><span itemprop="copyrightYear">2019 - 2024</span><span class="author" itemprop="copyrightHolder">&nbsp;<a href="https://shiva.dev" target="_blank">Shiva</a></span></div>
96105
</div>
97106
</footer></div>

public/categories/development/index.xml

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,32 @@
44
<link>https://shiva.dev/categories/development/</link>
55
<description>Development - Category - shiva.dev</description>
66
<generator>Hugo -- gohugo.io</generator><language>en</language><managingEditor>[email protected] (Shiva)</managingEditor>
7-
<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>
7+
<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>
8+
<title>Bind Ctrl &#43; hjkl to arrow keys on a Mac Machine</title>
9+
<link>https://shiva.dev/posts/bind_ctrl_hjkl_to_arrow_keys_on_mac/</link>
10+
<pubDate>Wed, 31 Jul 2024 13:55:20 -0500</pubDate>
11+
<author>Shiva</author>
12+
<guid>https://shiva.dev/posts/bind_ctrl_hjkl_to_arrow_keys_on_mac/</guid>
13+
<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.
14+
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.
15+
Keyboard Settings on Mac Navigate to System Settings &gt; Keyboard &gt; Keyboard Shortcut &gt; Modifier Keys (left pane).]]></description>
16+
</item>
17+
<item>
818
<title>Adding Password Protection To A Hugo Post</title>
919
<link>https://shiva.dev/posts/adding_password_protection_to_a_hugo_post/</link>
1020
<pubDate>Sun, 07 Jul 2024 13:55:20 -0500</pubDate>
1121
<author>Shiva</author>
1222
<guid>https://shiva.dev/posts/adding_password_protection_to_a_hugo_post/</guid>
1323
<description><![CDATA[In this post, I&rsquo;ll show you the simplest way to protect a Hugo page with a password by using front matter and adding a new parameter called &ldquo;password.&rdquo; This allows you to set a unique password for each post.
14-
proceed with caution This method lacks complete security. Anyone with basic Hugo knowledge can access your repository and view the passwords. Therefore, it&rsquo;s advisable to avoid sharing sensitive information using this approach.]]></description>
24+
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&rsquo;s advisable to avoid sharing sensitive information using this approach.]]></description>
25+
</item>
26+
<item>
27+
<title>Top Secret</title>
28+
<link>https://shiva.dev/posts/password/</link>
29+
<pubDate>Sun, 07 Jul 2024 13:55:20 -0500</pubDate>
30+
<author>Shiva</author>
31+
<guid>https://shiva.dev/posts/password/</guid>
32+
<description><![CDATA[Top Secret 1234567890 just kidding ;)]]></description>
1533
</item>
1634
<item>
1735
<title>Top Secret</title>

0 commit comments

Comments
 (0)