Skip to content

Commit

Permalink
added new post on binding hjkl
Browse files Browse the repository at this point in the history
  • Loading branch information
lazydeveloper committed Aug 1, 2024
1 parent d53a33d commit 8c83c70
Show file tree
Hide file tree
Showing 31 changed files with 513 additions and 200 deletions.
5 changes: 4 additions & 1 deletion content/posts/adding_password_protection_to_a_hugo_post.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ categories: ["Development"]
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.

{{< admonition type=warning title="proceed with caution" open=true >}}
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.
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.
{{< /admonition >}}


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

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.

<img src="/images/password-protection.gif" width="original_width" height="original_height" alt="password-protection">


![password-protection](https://global.discourse-cdn.com/standard10/uploads/gohugo/original/3X/f/8/f8f86d4073b44b9e45899e30e92b6a3b8f26fdaf.gif)

----
Expand Down
131 changes: 131 additions & 0 deletions content/posts/bind_ctrl_hjkl_to_arrow_keys_on_mac.md
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.
17 changes: 17 additions & 0 deletions content/posts/password.md
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 ;)
19 changes: 11 additions & 8 deletions public/404.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,17 @@
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="robots" content="noodp" />
<title>404 Page not found - shiva.dev</title>
<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" />
<meta property="og:description" content="A tech blog by Shiva Inampudi" />
<meta property="og:type" content="website" />
<meta property="og:url" content="https://shiva.dev/404.html" /><meta property="og:site_name" content="www.shiva.dev" />
<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">
<meta property="og:site_name" content="shiva.dev">
<meta property="og:title" content="404 Page not found">
<meta property="og:description" content="A tech blog by Shiva Inampudi">
<meta property="og:locale" content="en">
<meta property="og:type" content="website">

<meta name="twitter:card" content="summary"/><meta name="twitter:title" content="404 Page not found"/>
<meta name="twitter:description" content="A tech blog by Shiva Inampudi"/>
<meta name="twitter:site" content="@SHlVA_DEV"/>
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="404 Page not found">
<meta name="twitter:description" content="A tech blog by Shiva Inampudi">
<meta name="twitter:site" content="@SHlVA_DEV">
<meta name="application-name" content="Shiva&#39;s Tech Blog">
<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" />
<link rel="icon" type="image/png" sizes="32x32" href="/favicon-32x32.png">
Expand Down Expand Up @@ -92,7 +95,7 @@ <h1 id="error-emoji"></h1>
})();
</script></div>
</main><footer class="footer">
<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>
<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>
</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>
</div>
</footer></div>
Expand Down
25 changes: 17 additions & 8 deletions public/categories/development/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,17 @@
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="robots" content="noodp" />
<title>Development - Category - shiva.dev</title>
<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" />
<meta property="og:description" content="A tech blog by Shiva Inampudi" />
<meta property="og:type" content="website" />
<meta property="og:url" content="https://shiva.dev/categories/development/" /><meta property="og:site_name" content="www.shiva.dev" />
<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/">
<meta property="og:site_name" content="shiva.dev">
<meta property="og:title" content="Development">
<meta property="og:description" content="A tech blog by Shiva Inampudi">
<meta property="og:locale" content="en">
<meta property="og:type" content="website">

<meta name="twitter:card" content="summary"/><meta name="twitter:title" content="Development"/>
<meta name="twitter:description" content="A tech blog by Shiva Inampudi"/>
<meta name="twitter:site" content="@SHlVA_DEV"/>
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="Development">
<meta name="twitter:description" content="A tech blog by Shiva Inampudi">
<meta name="twitter:site" content="@SHlVA_DEV">
<meta name="application-name" content="Shiva&#39;s Tech Blog">
<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" />
<link rel="icon" type="image/png" sizes="32x32" href="/favicon-32x32.png">
Expand Down Expand Up @@ -81,8 +84,14 @@
<div id="search-dropdown-mobile"></div>
</div><main class="main">
<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">
<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>
<span class="archive-item-date">07-31</span>
</article><article class="archive-item">
<a href="/posts/top_secret/" class="archive-item-link">Top Secret</a>
<span class="archive-item-date">07-07</span>
</article><article class="archive-item">
<a href="/posts/password/" class="archive-item-link">Top Secret</a>
<span class="archive-item-date">07-07</span>
</article><article class="archive-item">
<a href="/posts/adding_password_protection_to_a_hugo_post/" class="archive-item-link">Adding Password Protection To A Hugo Post</a>
<span class="archive-item-date">07-07</span>
Expand All @@ -91,7 +100,7 @@
<span class="archive-item-date">06-11</span>
</article></div></div>
</main><footer class="footer">
<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>
<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>
</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>
</div>
</footer></div>
Expand Down
22 changes: 20 additions & 2 deletions public/categories/development/index.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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 &#43; 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 &gt; Keyboard &gt; Keyboard Shortcut &gt; 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&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.
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>
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>
</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>
Expand Down
Loading

0 comments on commit 8c83c70

Please sign in to comment.