on master help sign in
Implement show_current_directory command
commit16883e754399eb5bfacdbc1f9c1c4ac57fd5de06 authorLionel Flandrin <lfg@svkt.eu> dateMon 21 Jun 2021, 16:49 (5 years ago) parentb56174d
1 file changed+16
helix-term/src/commands.rs+16
helix-term/src/commands.rs+16
@@ -1386,6 +1386,15 @@ mod cmd {
13861386 }
13871387 }
13881388
1389+ fn show_current_directory(editor: &mut Editor, args: &[&str], _: PromptEvent) {
1390+ match std::env::current_dir() {
1391+ Ok(cwd) => editor.set_status(format!("Current working directory is {}", cwd.display())),
1392+ Err(e) => {
1393+ editor.set_error(format!("Couldn't get the current working directory: {}", e))
1394+ }
1395+ }
1396+ }
1397+
13891398 pub const TYPABLE_COMMAND_LIST: &[TypableCommand] = &[
13901399 TypableCommand {
13911400 name: "quit",
@@ -1562,6 +1571,13 @@ mod cmd {
15621571 fun: change_current_directory,
15631572 completer: Some(completers::directory),
15641573 },
1574+ TypableCommand {
1575+ name: "show-directory",
1576+ alias: Some("pwd"),
1577+ doc: "Show the current working directory.",
1578+ fun: show_current_directory,
1579+ completer: None,
1580+ },
15651581 ];
15661582
15671583 pub static COMMANDS: Lazy<HashMap<&'static str, &'static TypableCommand>> = Lazy::new(|| {