diff --git a/helix-term/src/commands.rs b/helix-term/src/commands.rs index 22e9ec1e5371c..6d97b870d3850 100644 --- a/helix-term/src/commands.rs +++ b/helix-term/src/commands.rs @@ -1335,6 +1335,15 @@ mod cmd { } } + fn show_directory(editor: &mut Editor, args: &[&str], _: PromptEvent) { + match std::env::current_dir() { + Ok(cwd) => editor.set_status(format!("Current working directory is {}", cwd.display())), + Err(e) => { + editor.set_error(format!("Couldn't get the current working directory: {}", e)) + } + } + } + pub const TYPABLE_COMMAND_LIST: &[TypableCommand] = &[ TypableCommand { name: "quit", @@ -1504,6 +1513,13 @@ mod cmd { fun: change_directory, completer: Some(completers::directory), }, + TypableCommand { + name: "show-directory", + alias: Some("pwd"), + doc: "Show the current working directory.", + fun: show_directory, + completer: None, + }, ]; pub static COMMANDS: Lazy> = Lazy::new(|| {