Skip to content

Conversation

@IanManske
Copy link
Member

Description

Follow up to #14341. Changes the fields of Hooks to Vec or Hashmap to match the new config defaults.

User-Facing Changes

Mostly the same as #14341. pre_prompt and pre_execution must now be a list, and env_change must be a record.

@IanManske IanManske added the notes:breaking-changes This PR implies a change affecting users and has to be noted in the release notes label Nov 15, 2024
@NotTheDr01ds
Copy link
Contributor

NotTheDr01ds commented Nov 15, 2024

Nice! Haven't played with it yet, but tightening up the types allowed for hooks is a good thing. This will make the documentation even easier, as there are fewer corner-cases to have to explain.

Question 1: Is it possible to restrict env_change a bit more to require a hashmap of vecs?

Question 2:

I was even thinking last night about preloading env_change with an empty PWD record. That would allow "out-of-the-box":

$env.config.hooks.env_change.PWD ++= [{print (ls | grid -c -i)}]
$env.config.hooks.env_change.PWD ++= [{process-env-file}]

Today, you first have to check if PWD exists or not.

Of course, that doesn't solve the problem for other environment variables, but I think PWD is so common that it might deserve a convenience default-value?

@IanManske IanManske marked this pull request as ready for review November 16, 2024 22:28
@sholderbach sholderbach added A:configuration Issue related to nu's configuration A:hooks Hooks are used to react to changes during interactive execution labels Nov 29, 2024
@sholderbach
Copy link
Member

What is the status on this one, if I remember we talked about it briefly two meetings ago and said we like it as soon as the technical side is good to got?

@IanManske IanManske merged commit 6bc695f into nushell:main Nov 29, 2024
13 checks passed
@github-actions github-actions bot added this to the v0.101.0 milestone Nov 29, 2024
@IanManske IanManske deleted the non-optional-hooks branch March 9, 2025 21:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A:configuration Issue related to nu's configuration A:hooks Hooks are used to react to changes during interactive execution notes:breaking-changes This PR implies a change affecting users and has to be noted in the release notes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants