From 8cde1c2e1edd0d5c54a53c9a07ea70532247f22d Mon Sep 17 00:00:00 2001 From: qkzk Date: Mon, 26 Sep 2022 09:30:22 +0200 Subject: expandpath --- Cargo.toml | 1 + readme.md | 3 +++ src/main.rs | 8 ++++++-- 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 21598a6b..c19e5a7b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -17,3 +17,4 @@ users = "0.11.0" tuikit = "*" chrono = "*" serde_yaml = "0.9.13" +shellexpand = "2.1.2" diff --git a/readme.md b/readme.md index f8eb9e2a..9b00c1c6 100644 --- a/readme.md +++ b/readme.md @@ -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()); } -- cgit v1.2.3