From c712a1b2542cc0f773da64f05ed7b91672e2115b Mon Sep 17 00:00:00 2001
From: Oliver Davies <oliver@oliverdavies.dev>
Date: Mon, 19 Aug 2024 22:08:01 +0100
Subject: [PATCH] Add aliases for `curl`

Use the cursor position to not have a trailing space after expanding the
abbreviation, making it easier to type any following characters.

See https://zsh-abbr.olets.dev/usage.html#place-the-cursor and
https://github.com/olets/zsh-abbr/discussions/97
---
 lib/shared/modules/zsh.nix               | 4 ++++
 lib/shared/modules/zsh/abbreviations.zsh | 4 ++++
 2 files changed, 8 insertions(+)

diff --git a/lib/shared/modules/zsh.nix b/lib/shared/modules/zsh.nix
index 307a4d93..b0ce8744 100644
--- a/lib/shared/modules/zsh.nix
+++ b/lib/shared/modules/zsh.nix
@@ -8,6 +8,10 @@
 
     shellAliases = (import ./zsh/aliases.nix);
 
+    localVariables = {
+      ABBR_SET_EXPANSION_CURSOR = 1;
+    };
+
     initExtra = ''
       git() {
         if [[ "''${1}" == "root" ]]; then
diff --git a/lib/shared/modules/zsh/abbreviations.zsh b/lib/shared/modules/zsh/abbreviations.zsh
index 62e54ade..87d4f826 100644
--- a/lib/shared/modules/zsh/abbreviations.zsh
+++ b/lib/shared/modules/zsh/abbreviations.zsh
@@ -64,3 +64,7 @@ abbr -g H="| head"
 abbr -g L="| less"
 abbr -g V="| vim -"
 abbr -g X="| xargs -I1"
+
+abbr clh="curl localhost:%"
+abbr clh3="curl localhost:3000%"
+abbr clh8="curl localhost:8000%"