1
0
Fork 0
mirror of https://github.com/helix-editor/helix synced 2024-06-12 20:46:17 +02:00

Implement show_current_directory command

This commit is contained in:
Lionel Flandrin 2021-06-21 16:49:21 +01:00 committed by Benoît Cortier
parent b56174d738
commit 16883e7543

View File

@ -1386,6 +1386,15 @@ fn change_current_directory(editor: &mut Editor, args: &[&str], _: PromptEvent)
}
}
fn show_current_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",
@ -1562,6 +1571,13 @@ fn change_current_directory(editor: &mut Editor, args: &[&str], _: PromptEvent)
fun: change_current_directory,
completer: Some(completers::directory),
},
TypableCommand {
name: "show-directory",
alias: Some("pwd"),
doc: "Show the current working directory.",
fun: show_current_directory,
completer: None,
},
];
pub static COMMANDS: Lazy<HashMap<&'static str, &'static TypableCommand>> = Lazy::new(|| {