aboutsummaryrefslogtreecommitdiff
path: root/helix-term
diff options
context:
space:
mode:
authorLionel Flandrin2021-06-21 15:49:21 +0000
committerBenoƮt Cortier2021-06-22 23:20:51 +0000
commit16883e754399eb5bfacdbc1f9c1c4ac57fd5de06 (patch)
tree5be7743887b717e83a2c8aff2029dbacd98ab556 /helix-term
parentb56174d7380fd299c4bcb8ded2f0127821dbe588 (diff)
Implement show_current_directory command
Diffstat (limited to 'helix-term')
-rw-r--r--helix-term/src/commands.rs16
1 files changed, 16 insertions, 0 deletions
diff --git a/helix-term/src/commands.rs b/helix-term/src/commands.rs
index 2f1db4b6..131a881e 100644
--- a/helix-term/src/commands.rs
+++ b/helix-term/src/commands.rs
@@ -1386,6 +1386,15 @@ mod cmd {
}
}
+ 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 @@ mod cmd {
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(|| {