nushell

How to show a function/command definition in nushell


How can I see the definition for a function (aka command)?

In Zsh, I can do this:

# Define some function
% tarx () { tar xzvf $1 }

# Come back later, see what it is
% declare -f tarx
tarx () { tar xzvf $1 }

In nushell, the equivalent seems to be:

> def tarx [tb] { tar xzvf $tb }

But when I'm poking around to see (and learn) what other commands actually do, I would like to be able to see definitions. Tried help tarx which is neat, but seems I need something like a help def tarx.


Solution

  • Use the view source command to "View the source of a custom command":

    def tarx [tb] { tar xzvf $tb }; view source tarx
    
    def tarx [ tb: any ] { tar xzvf $tb }