[PATCH] gnu: add bash-preexec

  • Open
  • quality assurance status badge
Details
2 participants
  • Nicolas Graves
  • Javier Olaechea
Owner
unassigned
Submitted by
Javier Olaechea
Severity
normal
J
J
Javier Olaechea wrote on 2 Nov 22:14 +0100
(address . guix-patches@gnu.org)
CAFVS=zCPdTC7L_fqfsyP8Mzfc=bp4ssSw9Us9q2RgToLVt95vQ@mail.gmail.com
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
Attachment: file
From 77ee4a5a57271f69f801270a7d045e3fde982e99 Mon Sep 17 00:00:00 2001
Message-ID: <77ee4a5a57271f69f801270a7d045e3fde982e99.1730581428.git.pirata@gmail.com>
From: Javier Olaechea <pirata@gmail.com>
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(+)

Toggle diff (42 lines)
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
N
N
Nicolas Graves wrote on 3 Nov 21:07 +0100
871pzsozdc.fsf@ngraves.fr
On 2024-11-02 21:14, Javier Olaechea wrote:

Toggle quote (14 lines)
> * gnu/packages/bash.scm: (bash-preexec): New variable.

> +
> +(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")))

You can use version here.

Toggle quote (5 lines)
> +
> + (sha256
> + (base32 "0nx0m1bhm4f4v033ngi2m9zq3vppimsmn8kmwqbvyqr4n6gkjmgq"))))
> + (build-system gnu-build-system)

Looks like you can simply use the copy-build-system here, no?

Toggle quote (16 lines)
> + (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.")

The description should be more descriptive. You can describe the two
functions like they do in the README. Use @command{bash/zsh}. Prefix
with "This package provides".

Toggle quote (4 lines)
> + (license license:expat)))
>
> base-commit: ea11d3608566174c4bae70faa4f9d0c67748d2db

--
Best regards,
Nicolas Graves
J
J
Javier Olaechea wrote on 4 Nov 05:27 +0100
(name . Nicolas Graves)(address . ngraves@ngraves.fr)(address . 74180@debbugs.gnu.org)
CAFVS=zDsu6ykXULk8KV1xOJr+4OB=x2Zbg7=2pqcoCRdYOaVXw@mail.gmail.com
Toggle quote (9 lines)
> > +
> > + (sha256
> > + (base32
> "0nx0m1bhm4f4v033ngi2m9zq3vppimsmn8kmwqbvyqr4n6gkjmgq"))))
> > + (build-system gnu-build-system)
>
> Looks like you can simply use the copy-build-system here, no?
>

Good call, I've updated the the package to do so. One thing I changed as
well is the location for bash-preexec.sh. I saw arch (
and nix package it under share/ instance of bin/.

Another thing I did was filtering the test files from the package. As they
require the bats package to run.


Toggle quote (9 lines)
> > + (description
> > + "preexec and precmd hook functions for Bash 3.1+ in the style of
> > Zsh.")
>
> The description should be more descriptive. You can describe the two
> functions like they do in the README. Use @command{bash/zsh}. Prefix
> with "This package provides".
>

Updated accordingly. Let me know if there are any other improvements

--
"I object to doing things that computers can do." — Olin Shivers
Attachment: file
From e4d7600ba9208f6850a92ba413eec32a764a79bb Mon Sep 17 00:00:00 2001
Message-ID: <e4d7600ba9208f6850a92ba413eec32a764a79bb.1730693960.git.pirata@gmail.com>
From: Javier Olaechea <pirata@gmail.com>
Date: Sat, 2 Nov 2024 15:57:54 -0500
Subject: [PATCH v2] 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(+)

Toggle diff (49 lines)
diff --git a/gnu/packages/bash.scm b/gnu/packages/bash.scm
index 93641a78d5..8a1de5a34c 100644
--- a/gnu/packages/bash.scm
+++ b/gnu/packages/bash.scm
@@ -47,6 +47,7 @@ (define-module (gnu packages bash)
#:use-module (guix gexp)
#:use-module (guix monads)
#:use-module (guix store)
+ #:use-module (guix build-system copy)
#:use-module (guix build-system gnu)
#:use-module (guix build-system trivial)
#:autoload (guix gnupg) (gnupg-verify*)
@@ -488,3 +489,32 @@ (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 version)))
+
+ (sha256
+ (base32 "0nx0m1bhm4f4v033ngi2m9zq3vppimsmn8kmwqbvyqr4n6gkjmgq"))))
+ (build-system copy-build-system)
+ (arguments
+ (list
+ #:install-plan #~'(("./" "share/bash-preexec/"
+ #:exclude-regexp (".travis.yml" ".github/"
+ "LICENSE.md" "README.md" "test/")))))
+ (home-page "https://github.com/rcaloras/bash-preexec")
+ (synopsis "preexec and precmd functions for Bash just like Zsh")
+ (description
+ "This package provides preexec and precmd hook functions for @command{Bash} 3.1+ in the style of @command{Zsh}.
+
+• preexec Executed just after a command has been read and is about to be executed. The string that the user typed is passed as the first argument.
+• precmd Executed just before each prompt. Equivalent to PROMPT_COMMAND, but more flexible and resilient.
+")
+ (license license:expat)))

base-commit: ea11d3608566174c4bae70faa4f9d0c67748d2db
--
2.46.0
?
Your comment

Commenting via the web interface is currently disabled.

To comment on this conversation send an email to 74180@debbugs.gnu.org

To respond to this issue using the mumi CLI, first switch to it
mumi current 74180
Then, you may apply the latest patchset in this issue (with sign off)
mumi am -- -s
Or, compose a reply to this issue
mumi compose
Or, send patches to this issue
mumi send-email *.patch