Skip to content

Document the percent sigil#2167

Open
samoylovfp wants to merge 1 commit into
nushell:mainfrom
samoylovfp:main
Open

Document the percent sigil#2167
samoylovfp wants to merge 1 commit into
nushell:mainfrom
samoylovfp:main

Conversation

@samoylovfp
Copy link
Copy Markdown
Contributor

Fixes #2166

Is the example too convoluted? Maybe just

let cmd = "is-empty"
[ 1 ] | %$cmd

?

@Juhan280
Copy link
Copy Markdown
Contributor

Primary use case for % is to call builtins that are overriden by other custom command.

alias cd = __zoxide_z
%cd some_dir # can be used to run builtin cd

This can also be used for wrapping a builtin command with the same name

def ls [] {
  %ls | sort-by size
}

Comment thread lang-guide/chapters/strings_and_text.md Outdated
@samoylovfp
Copy link
Copy Markdown
Contributor Author

Now that I understood the intention, I think I found a better place for this piece of information.

Comment thread book/aliases.md Outdated
@fdncred
Copy link
Copy Markdown
Contributor

fdncred commented May 21, 2026

I think it's fine here but the it shouldn't be the only place because I didn't write the code for aliases. I wrote it to be able to run built-ins from anywhere. So, either that's another special section in another area or it's around where ^ is documented.

@samoylovfp samoylovfp reopened this May 31, 2026
@samoylovfp
Copy link
Copy Markdown
Contributor Author

@fdncred
I've added mentions of the percent sigil to both the section about overriding commands and one about executing strings.
Does this look better?


```nu
let cmd = "ls"
%$cmd
Copy link
Copy Markdown
Contributor

@fdncred fdncred May 31, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's fine but I'd do something like this just to drive the point home.

# call internal `ls` command
%$cmd
# call external `ls` command
^$cmd

@@ -40,6 +40,13 @@ let arguments = ["arg1", "-a", "arg2"]

The caret `^` before the string interpolation symbol `$` allows that external command to be executed.

This comment was marked as low quality.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nvm, I didn't expand the diff, and just assumed the wrong thing

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Percent sigil is undocumented

3 participants