diff options
author | qkzk <qu3nt1n@gmail.com> | 2022-09-26 09:30:22 +0200 |
---|---|---|
committer | quentin konieczko <konieczko@gmail.com> | 2022-09-28 09:11:00 +0200 |
commit | 8cde1c2e1edd0d5c54a53c9a07ea70532247f22d (patch) | |
tree | 3d2023d5dcf0c6640318a19dbed2f420fb02f6bd | |
parent | 0b902b87584da64f5b4cf8bb0388f41323eb9f16 (diff) |
expandpath
-rw-r--r-- | Cargo.toml | 1 | ||||
-rw-r--r-- | readme.md | 3 | ||||
-rw-r--r-- | src/main.rs | 8 |
3 files changed, 10 insertions, 2 deletions
@@ -17,3 +17,4 @@ users = "0.11.0" tuikit = "*" chrono = "*" serde_yaml = "0.9.13" +shellexpand = "2.1.2" @@ -42,6 +42,7 @@ - [x] refactor FileInfo, use an enum - [x] '\*' flag all - [x] v reverse flags +- [x] allow '~' in GOTO mode ## TODO @@ -53,6 +54,8 @@ - [ ] regex - [ ] search - [ ] mark multiple files +- [ ] installed config file, user config file +- [ ] completion in goto mode, exec mode, searchmode (???) ## BUGS diff --git a/src/main.rs b/src/main.rs index e6fe3de5..794fc376 100644 --- a/src/main.rs +++ b/src/main.rs @@ -15,6 +15,7 @@ use fm::args::Args; use fm::config::{load_file, str_to_tuikit, Colors, Keybindings}; use fm::fileinfo::{FileInfo, FileKind, PathContent}; +extern crate shellexpand; // 1.0.0 pub mod fileinfo; const WINDOW_PADDING: usize = 4; @@ -678,9 +679,12 @@ impl Status { } fn exec_goto(&mut self) { - let target = self.input_string.clone(); + use std::borrow::Borrow; + let target_string = self.input_string.clone(); + let expanded_cow_path = shellexpand::tilde(&target_string); + let expanded_target: &str = expanded_cow_path.borrow(); self.input_string.clear(); - if let Ok(path) = std::fs::canonicalize(path::Path::new(&target)) { + if let Ok(path) = std::fs::canonicalize(expanded_target) { self.path_content = PathContent::new(path, self.args.hidden); self.window.reset(self.path_content.files.len()); } |