Skip to content

Commit

Permalink
Implement show_current_directory command
Browse files Browse the repository at this point in the history
  • Loading branch information
Lionel Flandrin committed Jun 22, 2021
1 parent ec9d018 commit 5aabb54
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions helix-term/src/commands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1335,6 +1335,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",
Expand Down Expand Up @@ -1504,6 +1513,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(|| {
Expand Down

0 comments on commit 5aabb54

Please sign in to comment.