Ability to delete/hide variables
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 40.5k
- Forks
- 2.3k
- Avg merge
- 1d 19h
- Merged PRs (30d)
- 85
Description
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).
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by tracing the existing hide entry point and how variable declarations are represented across the current and enclosing scopes. Define completion behavior for a hidden variable, then verify that hide $variablename removes the declaration without requiring a shell restart and that the reported scenarios are covered by tests.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust, shell
- Domain
- cli
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100