nushell icon indicating copy to clipboard operation
nushell copied to clipboard

Ability to delete/hide variables

Open NotTheDr01ds opened this issue 1 year ago • 0 comments

Related problem

We can hide $env variables, command declarations (even builtins!), and aliases. Unless I'm missing something obvious, however, we can't hide variables that were declared in the current scope or above. We can shadow, but not get rid of them.

Scenario 1:

I know it seems like a nit, but today, I accidentally typed something like:

> let comands = help commands | get name
# Oops!
> let commands = help commands | get name

No biggie, right? But if I'd gotten it right the first time, I could Tab-complete $commands on subsequent command lines just with $com + Tab.

Now, I get both the desired completion as well as the error when I try to Tab-complete. The only way to recover is to restart the shell.

Scenario #11410

sourceing the default Carapace init.nu results in dangling variable declaration for $current, which was just an internal variable declaration.

There are ways that this could have been handled, had the person implementing it taken the time (no offense, we all make mistakes):

  • Probably should be a module
  • Could have been wrapped in a function or even a closure in the init.nu

But an additional way might have been the ability to hide the declaration after using it.

Describe the solution you'd like

hide $variablename

Describe alternatives you've considered

No response

Additional context and details

I know that the idea is to think of Nu as a "compiled language", but (a) we have hide implementations for other declarations and (b) I can't think of another shell that doesn't have the ability to delete variables (POSIX unset; Fish set --erase).

NotTheDr01ds avatar Feb 09 '24 19:02 NotTheDr01ds