diff --git a/crates/nu-command/src/system/which_.rs b/crates/nu-command/src/system/which_.rs index 62154cf229..3e89a9896d 100644 --- a/crates/nu-command/src/system/which_.rs +++ b/crates/nu-command/src/system/which_.rs @@ -77,6 +77,8 @@ fn get_entry_in_commands(engine_state: &EngineState, name: &str, span: Span) -> if let Some(decl_id) = engine_state.find_decl(name.as_bytes(), &[]) { let (msg, is_builtin) = if engine_state.get_decl(decl_id).is_custom_command() { ("Nushell custom command", false) + } else if engine_state.get_decl(decl_id).is_alias() { + ("Nushell alias", false) } else { ("Nushell built-in command", true) }; diff --git a/crates/nu-command/tests/commands/which.rs b/crates/nu-command/tests/commands/which.rs index 75557d9beb..b9f02e8b63 100644 --- a/crates/nu-command/tests/commands/which.rs +++ b/crates/nu-command/tests/commands/which.rs @@ -21,6 +21,19 @@ fn which_alias_ls() { assert_eq!(actual.out, "Nushell alias: ls -a"); } +#[test] +fn which_custom_alias() { + let actual = nu!( + cwd: ".", + r#"alias foo = print "foo!"; which foo | to nuon"# + ); + + assert_eq!( + actual.out, + "[[arg, path, built-in]; [foo, \"Nushell alias\", false]]" + ); +} + #[test] fn which_def_ls() { let actual = nu!(