Subject: [PATCH] gnu: add bash-preexec

From: Javier Olaechea <[email-masked]>
Date: Sat, 2 Nov 2024 21:14:17 +0000

Hi,

Attached is a patch to package bash-preexec. It provides hooks that other
programs can use to to register commands to run when one runs a command on
the shell w/o clobbering each other. For example it allows me to use both
direnv and atuin. ej.

(home-environment
 (services
  (list (service home-bash-service-type
                 (home-bash-configuration
                  (bashrc (list (mixed-text-file "source-bash-preexec"
                                                 "source " bash-preexec
"/bin/bash-preexec.sh")
                                (mixed-text-file "eval-direnv"
                                                 "eval \"$(" direnv
"/bin/direnv hook bash)\"")
                                (mixed-text-file
                                 "eval-atuin"
                                 "eval \"$(" atuin-bin "/bin/atuin init
bash --disable-up-arrow)\""))))))))

Cheers

-- 
"I object to doing things that computers can do." — Olin Shivers
From 77ee4a5a57271f69f801270a7d045e3fde982e99 Mon Sep 17 00:00:00 2001
Message-ID: <[email-masked]>
From: Javier Olaechea <[email-masked]>
Date: Sat, 2 Nov 2024 15:57:54 -0500
Subject: [PATCH] gnu: add bash-preexec

* gnu/packages/bash.scm: (bash-preexec): New variable.

Change-Id: I642be370c903183c89174da30666b08f07d3a118
---
 gnu/packages/bash.scm | 30 ++++++++++++++++++++++++++++++
 1 file changed, 30 insertions(+)

diff --git a/gnu/packages/bash.scm b/gnu/packages/bash.scm
index 93641a78d5..be2f03092d 100644
--- a/gnu/packages/bash.scm
+++ b/gnu/packages/bash.scm
@@ -488,3 +488,33 @@ (define-public blesh
 which replaces the default GNU Readline.  It adds syntax highlighting, auto
 suggestions, vim modes, and more to Bash interactive sessions.")
     (license license:bsd-3)))
+
+(define-public bash-preexec
+  (package
+    (name "bash-preexec")
+    (version "0.5.0")
+    (source
+     (origin
+       (method git-fetch)
+       (uri (git-reference
+             (url "https://github.com/rcaloras/bash-preexec")
+             (commit "da64ad4b7bb965d19dbeb5bb7447f1a63e3de2e3")))
+
+       (sha256
+        (base32 "0nx0m1bhm4f4v033ngi2m9zq3vppimsmn8kmwqbvyqr4n6gkjmgq"))))
+    (build-system gnu-build-system)
+    (arguments
+     (list
+      #:phases #~(modify-phases %standard-phases
+                   (delete 'configure)
+                   (delete 'build)
+                   (delete 'check)
+                   (replace 'install
+                     (lambda _
+                       (install-file "bash-preexec.sh"
+                                     (string-append #$output "/bin")))))))
+    (home-page "https://github.com/rcaloras/bash-preexec")
+    (synopsis "preexec and precmd functions for Bash just like Zsh")
+    (description
+     "preexec and precmd hook functions for Bash 3.1+ in the style of Zsh.")
+    (license license:expat)))

base-commit: ea11d3608566174c4bae70faa4f9d0c67748d2db
-- 
2.46.0