New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
changing default display_output
hook disable ls_colors
#7368
Comments
I have two thoughts on this right now.
|
I tried without |
@fdncred |
I'm not sure what you mean but we know when
You can look at how the |
No , actually we know when |
I'm up for alternate solutions to help with this but I'm not sure what a good one would look like exactly. Maybe @kubouch or @sholderbach know if what you're suggesting sounds reasonable. Also, I'm sure there are a few other issues other than this one that talk about ls colors like maybe #4319 #4501 #7169 and maybe others. I mention this because there could be more information in other issues. Thanks @Mehrbod2002 for jumping in and trying to help! |
Do you mean by history using the command history to do the metadata propagation or do you want to look at the previous steps in the current pipeline? Or is this rather related to some metatdata you want to express for the
Yeah adding more metadata on the So I think, it boils down to correctly implementing that for more commands/add utilities to do that properly without too much boilerplate. Might be worth a little tracking label/issue/project, feels like a good issue for contributors starting out with command implementations and |
Can we look at the previous step in the current pipeline ? |
Not out of the box and this requires explicitly using the pipeline metadata at the moment: See how for ls this is available as it is a special case in nushell/crates/nu-command/src/core_commands/metadata.rs Lines 78 to 93 in 35b12fe
The last example shows that such metadata also gets lost if data travels between different pipelines in nu evaluation (closure, subexpression) |
Thanks a lot . |
Not absolutely impossible as the pipeline gets parsed initially but technically not implemented in any flexible form at the moment at the evaluation time which basically does a bunch of |
As I understood we finally should detect |
This should help work around issues like nushell#7368 without having to propagate metadata everywhere (which would be a much larger refactor).
This should help work around issues like nushell#7368 without having to propagate metadata everywhere (which would be a much larger refactor).
This should help work around issues like nushell#7368 without having to propagate metadata everywhere (which would be a much larger refactor).
This should help work around issues like nushell#7368 without having to propagate metadata everywhere (which would be a much larger refactor).
This should help work around issues like nushell#7368 without having to propagate metadata everywhere (which would be a much larger refactor).
I have got something like you want using #7950: let-env v = []
def v [index:int=0] { $env.v | get -i $index }
def-env store_last_output [] {
let-with-metadata data metadata = $in
let-env LAST_OUTPUT = $data
$data | set-metadata $metadata
}
let-env config = $env.config | update hooks.display_output store_last_output |
…tadata This should help work around issues like nushell#7368 without having to propagate metadata everywhere (which would be a much larger refactor).
I couldn't get this to work. |
Yeah I've simplified my actual config and I cannot get it to work, I don't know why yet. Here is my actual config Code inlined here
(And yeah I could replace the bubbling of the values with a reduce, it just grew from one to a couple of values) |
D'oh figured out where I messed up, forgot the parentheses for the let-env. Also need double braces for the update let-env LAST_OUTPUT = null
def-env store_last_output [] {
let-with-metadata data metadata = $in
let-env LAST_OUTPUT = $data
$data | set-metadata $metadata
}
let-env config = ($env.config | update hooks.display_output {{store_last_output}}) |
I haven't tried this yet, but I worry about the way you're treating an environment variable as a mutable variable. There are unknown consequences and known consequences to doing this. The one known one that I can rattle off the top of my head is that, on Windows, there is a limit to the size of the environment. That limit is 32,767 bytes. That is the entire environment, not just one variable.
https://devblogs.microsoft.com/oldnewthing/20100203-00/?p=15083 We've talked about having something like |
It's also what the OP is doing -- and yeah it can cause problems, on Linux this seems to happen when starting a process, e.g. my direnv and starship hooks break. But since I cannot use a mutable variable that is captured by blocks, this is the only option for mutability I think. ~ at 17:20:06 nu
❯ let-env foo = (0..(2 ** 15) | each {"hello"} | str join ":")
Error: nu::shell::external_command (link)
× External command failed
╭─[hook:1:1]
1 │
2 │ let direnv = (/nix/store/9ikwbnl8c5sniawwn8rai5bi6pgp6mxq-direnv-2.32.2/bin/direnv export json | from json)
· ──────────────────────────────────┬─────────────────────────────────
· ╰── can't run executable
3 │ let direnv = if ($direnv | length) == 1 { $direnv } else { {} }
╰────
help: Argument list too long (os error 7)
Error: nu::shell::external_command (link)
× External command failed
╭─[init.nu:11:1]
11 │ let width = (term size).columns
12 │ ^/etc/profiles/per-user/rmk/bin/starship prompt $"--cmd-duration=($env.CMD_DURATION_MS)" $"--status=($env.LAST_EXIT_CODE)" $"--terminal-width=($width)"
· ───────────────────┬───────────────────
· ╰── can't run executable
13 │ }
╰────
help: Argument list too long (os error 7)
Error: nu::shell::external_command (link)
× External command failed
╭─[init.nu:34:1]
34 │ let width = (term size).columns
35 │ ^/etc/profiles/per-user/rmk/bin/starship prompt --right $"--cmd-duration=($env.CMD_DURATION_MS)" $"--status=($env.LAST_EXIT_CODE)" $"--terminal-width=($width)"
· ───────────────────┬───────────────────
· ╰── can't run executable
36 │ } else {
╰────
help: Argument list too long (os error 7)
/home/rmk I can get it back though, by setting /home/rmk$env.foo = ""
~ at 17:20:15 nu
❯ |
But you can use let-env ENV_CONVERSIONS = ($env.ENV_CONVERSIONS | insert LAST_OUTPUT ({
from_string: {|str| ""}
to_string: {|str| ""}
})) |
…tadata This should help work around issues like nushell#7368 without having to propagate metadata everywhere (which would be a much larger refactor).
…tadata This should help work around issues like nushell#7368 without having to propagate metadata everywhere (which would be a much larger refactor).
…tadata This should help work around issues like nushell#7368 without having to propagate metadata everywhere (which would be a much larger refactor).
…tadata This should help work around issues like nushell#7368 without having to propagate metadata everywhere (which would be a much larger refactor).
…tadata This should help work around issues like nushell#7368 without having to propagate metadata everywhere (which would be a much larger refactor).
…tadata This should help work around issues like nushell#7368 without having to propagate metadata everywhere (which would be a much larger refactor).
…tadata This should help work around issues like nushell#7368 without having to propagate metadata everywhere (which would be a much larger refactor).
…tadata This should help work around issues like nushell#7368 without having to propagate metadata everywhere (which would be a much larger refactor).
…tadata This should help work around issues like nushell#7368 without having to propagate metadata everywhere (which would be a much larger refactor).
…tadata This should help work around issues like nushell#7368 without having to propagate metadata everywhere (which would be a much larger refactor).
…tadata This should help work around issues like nushell#7368 without having to propagate metadata everywhere (which would be a much larger refactor).
…tadata This should help work around issues like nushell#7368 without having to propagate metadata everywhere (which would be a much larger refactor).
…tadata This should help work around issues like nushell#7368 without having to propagate metadata everywhere (which would be a much larger refactor).
…tadata This should help work around issues like nushell#7368 without having to propagate metadata everywhere (which would be a much larger refactor).
…tadata This should help work around issues like nushell#7368 without having to propagate metadata everywhere (which would be a much larger refactor).
…tadata This should help work around issues like nushell#7368 without having to propagate metadata everywhere (which would be a much larger refactor).
…tadata This should help work around issues like nushell#7368 without having to propagate metadata everywhere (which would be a much larger refactor).
…tadata This should help work around issues like nushell#7368 without having to propagate metadata everywhere (which would be a much larger refactor).
…tadata This should help work around issues like nushell#7368 without having to propagate metadata everywhere (which would be a much larger refactor).
…tadata This should help work around issues like nushell#7368 without having to propagate metadata everywhere (which would be a much larger refactor).
…tadata This should help work around issues like nushell#7368 without having to propagate metadata everywhere (which would be a much larger refactor).
…tadata This should help work around issues like nushell#7368 without having to propagate metadata everywhere (which would be a much larger refactor).
…tadata This should help work around issues like nushell#7368 without having to propagate metadata everywhere (which would be a much larger refactor).
…tadata This should help work around issues like nushell#7368 without having to propagate metadata everywhere (which would be a much larger refactor).
…tadata This should help work around issues like nushell#7368 without having to propagate metadata everywhere (which would be a much larger refactor).
…tadata This should help work around issues like nushell#7368 without having to propagate metadata everywhere (which would be a much larger refactor).
…tadata This should help work around issues like nushell#7368 without having to propagate metadata everywhere (which would be a much larger refactor).
…tadata This should help work around issues like nushell#7368 without having to propagate metadata everywhere (which would be a much larger refactor).
…tadata This should help work around issues like nushell#7368 without having to propagate metadata everywhere (which would be a much larger refactor).
…tadata This should help work around issues like nushell#7368 without having to propagate metadata everywhere (which would be a much larger refactor).
…tadata This should help work around issues like nushell#7368 without having to propagate metadata everywhere (which would be a much larger refactor).
Describe the bug
hey, I'm trying to change the default
display_output
hook in this way:This is in a file named
nu_config.nu
that I source inconfig.nu
via:However, now
ls
output doesn't have colors.If I leave the default:
lscolors
works againHow to reproduce
Already explained
Expected behavior
lscolors
should worksScreenshots
No response
Configuration
Additional context
No response
The text was updated successfully, but these errors were encountered: