Skip to content

allow the use of const in a module #8248

@amtoine

Description

@amtoine

Related problem

i have some modules where i use preview strings for fzf that i want to define at the top level

Note
such a preview is just a string, containing some code, here bash, and that gets executed on each line of the fzf fuzzy finder to show some preview, e.g. if the entries are file paths, the preview might show the content of the files in a panel to the side

before the recent alias rewrite, i used to define them as aliases, e.g.

alias FZF_PREVIEW = "..."

and used as

fzf {options} --preview (FZF_LOG_PREVIEW)

now, with the new change, i can not do that anymore and am, afaik, forced to do that as

def FZF_PREVIEW [] {"
   ...
"}

Describe the solution you'd like

i think it could be cool to just be able to define constants in nushell modules

for instance,

const FZF_PREVIEW = "..."

and then

fzf {options} --preview $FZF_PREVIEW

Describe alternatives you've considered

No response

Additional context and details

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    A:parserIssues related to parsingcategory:enhancementNew feature or requestsemanticsPlaces where we should define/clarify nushell's semantics

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions