0

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.

Micah Elliott
  • 9,600
  • 5
  • 51
  • 54

1 Answers1

1

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 }
pmf
  • 24,478
  • 2
  • 22
  • 31
  • Thanks! And wow, I also see that `help view source` shows a bunch of nice examples. And shows that it works for aliases and modules too! – Micah Elliott Aug 29 '23 at 20:41