mirror of
https://github.com/sajenim/rush.git
synced 2025-06-28 09:54:21 +08:00
feat: better cd
This commit is contained in:
parent
2061bb4f74
commit
fa47639ef3
1 changed files with 11 additions and 2 deletions
|
@ -1,8 +1,17 @@
|
|||
// Provides Built-In Shell Functions.
|
||||
|
||||
pub fn cd(args: &[String]) {
|
||||
let path = args[0].to_string();
|
||||
assert!(std::env::set_current_dir(&path).is_ok());
|
||||
let path = if args.is_empty() {
|
||||
std::env::var("HOME").unwrap_or_default()
|
||||
} else {
|
||||
shellexpand::tilde(&args[0]).to_string()
|
||||
};
|
||||
|
||||
let status = std::env::set_current_dir(&path);
|
||||
|
||||
if status.is_err() {
|
||||
println!("cd: no such file or directory: {}", &path);
|
||||
}
|
||||
}
|
||||
|
||||
pub fn help() {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue