summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorqkzk <qu3nt1n@gmail.com>2022-09-26 09:30:22 +0200
committerquentin konieczko <konieczko@gmail.com>2022-09-28 09:11:00 +0200
commit8cde1c2e1edd0d5c54a53c9a07ea70532247f22d (patch)
tree3d2023d5dcf0c6640318a19dbed2f420fb02f6bd
parent0b902b87584da64f5b4cf8bb0388f41323eb9f16 (diff)
expandpath
-rw-r--r--Cargo.toml1
-rw-r--r--readme.md3
-rw-r--r--src/main.rs8
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());
}