on master help sign in
Implement show_current_directory command
16883e7Lionel Flandrin
helix-term/src/commands.rs+16
@@ -1386,6 +1386,15 @@ mod cmd {
1386 }
1386 }
1387 }
1387 }
1388
1388
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+
1389 pub const TYPABLE_COMMAND_LIST: &[TypableCommand] = &[
1398 pub const TYPABLE_COMMAND_LIST: &[TypableCommand] = &[
1390 TypableCommand {
1399 TypableCommand {
1391 name: "quit",
1400 name: "quit",
@@ -1562,6 +1571,13 @@ mod cmd {
1562 fun: change_current_directory,
1571 fun: change_current_directory,
1563 completer: Some(completers::directory),
1572 completer: Some(completers::directory),
1564 },
1573 },
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+ },
1565 ];
1581 ];
1566
1582
1567 pub static COMMANDS: Lazy<HashMap<&'static str, &'static TypableCommand>> = Lazy::new(|| {
1583 pub static COMMANDS: Lazy<HashMap<&'static str, &'static TypableCommand>> = Lazy::new(|| {