Skip to content

Commit 16883e7

Browse files
Lionel FlandrinCBenoit
authored andcommitted
Implement show_current_directory command
1 parent b56174d commit 16883e7

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

helix-term/src/commands.rs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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(|| {

0 commit comments

Comments
 (0)