Skip to content

show alias definition when using which #9637

Closed

Description

@a13h

Related problem

Mentioned in #8577 here, it would be useful to display the definition of an alias when using which, e.g.:

> alias foo = print "foo!";
> which foo
╭───┬─────┬─────────────────────────────┬──────────╮
│ # │ arg │             path            │ built-in │
├───┼─────┼─────────────────────────────┼──────────┤
│ 0 │ foo │ Nushell alias: print "foo!" │ false    │
╰───┴─────┴─────────────────────────────┴──────────╯

Describe the solution you'd like

TBC: I'll spend some time updating this section after going through the existing implementation to detail how I will go about doing this. I assume the definition is saved anyway and it's a matter of extracting and displaying it correctly.

Describe alternatives you've considered

No response

Additional context and details

No response

Activity

  1. added
    category:enhancement
    status:needs-triage
    on Jul 9, 2023
  2. fdncred commented on Jul 9, 2023

    @fdncred
    Contributor

    I'd think it would be better to update view source to support aliases. Right now it seems to kind of support it but it shows the source of custom command that has been aliases.

  3. hardfau1t commented on Jul 10, 2023

    @hardfau1t
    Contributor

    i think adding description in path field will break many scripts

  4. a13h commented on Jul 10, 2023

    @a13h
    ContributorAuthor

    i think adding description in path field will break many scripts

    @hardfau18 hmm, interesting, do you have examples of the kind of scripts that use the path field? I can understand anything that might use it to figure out the type of an alias/command would break though so makes sense

    I'd think it would be better to update view source to support aliases. Right now it seems to kind of support it but it shows the source of custom command that has been aliases.

    @fdncred will check how this works currently to see if it can be extended from custom commands to aliases too

  5. added
    A:alias
    on Jul 10, 2023
  6. hardfau1t commented on Jul 10, 2023

    @hardfau1t
    Contributor

    do you have examples of the kind of scripts that use the path field

    I don't have specific example i just thought it might happen, i find myself using (which <fille>).0.path for moving or removing any custom binaries etc.

    EDIT: my bad builtin commands do not have path and it will show similar to aliases😄

  7. amtoine commented on Jul 10, 2023

    @amtoine
    Member

    instead of having which return the following columns

    • arg
    • path
    • built-in

    we might prefer having

    • command: same as arg but more explicit name
    • path: same as before, null when built-in
    • type: instead of buil-in: bool says if it's a built-in a custom command, an alias or an external

    what do you guys think?

  8. c-git commented on Feb 25, 2026

    @c-git

    I think this is fixed now. I'm using version 0.110.0. The OP asked for the definition of the alias and that shows now.

    ~> alias foo = print "foo!";
    ~> which foo
    ╭───┬─────────┬──────┬───────┬──────────────╮
    │ # │ command │ path │ type  │  definition  │
    ├───┼─────────┼──────┼───────┼──────────────┤
    │ 0 │ foo     │      │ alias │ print "foo!" │
    ╰───┴─────────┴──────┴───────┴──────────────╯
  9. BrainBacon commented on Feb 25, 2026

    @BrainBacon

    I can also confirm that this feature is available in version 109.1

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    A:aliascategory:enhancementstatus:needs-triage

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions