docs: fix syntax
Add missing ) to docs.
Working example is now
$env.config = ($env.config | upsert hooks {
env_change: {
PWD: [{
code: 'print $"changing directory from ($before) to ($after)"'
}]
}
})
website at https://www.nushell.sh/book/hooks.html#hooks-as-strings currently shows broken example:
$env.config = ($env.config | upsert hooks {
env_change: {
PWD: {
code: 'print $"changing directory from ($before) to ($after)"'
}
}
}
Are the parentheses even needed at all? This works but it will also overwrite your existing env_change.PWD if it already exists.
$env.config = $env.config | upsert hooks {
env_change: {
PWD: [{
code: 'print $"changing directory from ($before) to ($after)"'
}]
}
}
We should probably go further and update these to use the "modern" style:
# Make sure the `PWD` hook list exists
$env.config.hooks.env_change.PWD = $env.config.hooks.env_change.PWD? | default []
# Add hook(s)
$env.config.hooks.env_change.PWD ++= [
{
condition: {|_, after| $after == /some/path/to/directory }
code: 'def foo [] { print "foo" }'
}
{
condition: {|before, _| $before == /some/path/to/directory }
code: 'hide foo'
}
]
$env.config.hooks.env_change.PWD ++= [
{
code: 'print $"changing directory from ($before) to ($after)"'
}
]
I like to merged this pull request but how do I get access to the repository?
I like to merged this pull request but how do I get access to the repository?
Only maintainers have access.
If this PR gets updated similar to bahex's suggestion, we'll land it.