summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorrabite <rabite@posteo.de>2019-04-07 14:00:50 +0200
committerrabite <rabite@posteo.de>2019-04-07 14:00:50 +0200
commit63fe77c997fe8a5807fde1836a85d72b7694021d (patch)
treebb9a0529c8cc697609f64e45f00dea2e58cb5c1e
parent7f70fa29046e09be414b52ba572eb9675979cd46 (diff)
parent62474ff6bcbd78745a66a753cb5d3578ba52bc05 (diff)
Merge branch 'master' into evilv1.0-evil
-rw-r--r--README.md15
-rw-r--r--extra/hunter_cd.sh6
-rw-r--r--src/file_browser.rs24
-rw-r--r--src/proclist.rs6
4 files changed, 39 insertions, 12 deletions
diff --git a/README.md b/README.md
index 072a69c..bc96b8c 100644
--- a/README.md
+++ b/README.md
@@ -5,17 +5,17 @@ hunter
hunter is a fast and lag-free file browser/manager for the terminal. It features a heavily asychronous and multi-threaded design and all disk IO happens off the main thread in a non-blocking fashion, so that hunter will always stay responsive, even under heavy load on a slow spinning rust disk, even with all the previews enabled.
-It's heavily inspired by the excellent ranger, but a little more Emacs-flavoured, and written in Rust to make sure it starts up quickly and to take advantage of it's strong guarantees around concurrency. It's so fast I actually built in animations for some parts as a joke, but in fact it turned out to look really nice and makes it look much smoother. YMMV, of course, and this can be disabled.
+It's heavily inspired by the excellent ranger, but a little more Emacs-flavoured, and written in Rust to make sure it starts up quickly and to take advantage of its strong guarantees around concurrency. It's so fast I actually built in animations for some parts as a joke, but in fact it turned out to look really nice and makes it look much smoother. YMMV, of course, and this can be disabled.
Most things you would expect are implementend, among them tabs, bookmarks (with ranger-import), search/filter, previews of files/directories (including size information in previewed directories), a minibuffer at the bottom with file name completion, multi file selection, etc., etc. There are also a few original ideas, especially around subprocess handling. The process viewer actually shows the output of started subprocesses, their pids and exit codes, notifies on new output and process completion. It's somewhat of a primitive TUI shell. File names are handled using raw OsString, so there is no file it can't handle, no matter what garbage the name contains. It also sets the tmux/terminal title to the current directory on supported terminals.
To speed up the loading of direcories metadata in the preview/backview is only loaded for files you can see, except in the main view. Still, metadata is also loaded asynchronously, so you can sometimes see it updating file listings while browsing through your files. I think this is better than waiting though :).
-Technically hunter is not a file "manager" itself. It has no built in primitives for file manipulation like delete, rename, move, and so on. Instead it relies on it's easy and extensive integration with the standard cli tools to do it's job. For that purpose there are various file name/path substitution patterns and an auto-completing for executables you want to run.
+Technically hunter is not a file "manager" itself. It has no built in primitives for file manipulation like delete, rename, move, and so on. Instead it relies on its easy and extensive integration with the standard cli tools to do its job. For that purpose there are various file name/path substitution patterns and an auto-completing for executables you want to run.
This is a young project and probably (definitely) has some bugs and edge cases. It hasn't been tested on a lot of terminals, but at least alacritty, kitty and urxvt work fine. It should work on most Unix-flavoured systems supported by Rust, but was only tested on GNU/Linux. I haven't lost any files so far, at least.
-A big thanks to ranger and its developers. Without its inspiration this wouldn't have been possible. hunter not a drop-in replacement and doesn't cover every use-care, especially if you're into advanced customization, since hunter has basically none unless you modify the code, but if you just need fast above all else it's might be a good coice.
+A big thanks to ranger and its developers. Without its inspiration this wouldn't have been possible. hunter not a drop-in replacement and doesn't cover every use-care, especially if you're into advanced customization, since hunter has basically none unless you modify the code, but if you just need fast above all else it might be a good coice.
## Features:
* Lag-free architecture, always responsive
@@ -39,6 +39,15 @@ hunter reads $XDG_CONFIG_HOME/hunter/config at startup. There are two options, w
animation=on
show_hidden=off
+## Drop into hunter cwd on quit
+To change the directory of your shell when quitting hunter with Q you need to source extra/hunter_cd.sh, which is a wrapper that runs hunter and checks for ~/.hunter_cwd after hunter exits and cd's into the contained directory if it exists.
+
+## Filename Substitution
+| Pattern | Substituted with |
+|-----------|:------------------------|
+| $s | selected file(s) |
+| $n | tab directory |
+| $ns | selected files in tab |
Keybindings:
diff --git a/extra/hunter_cd.sh b/extra/hunter_cd.sh
new file mode 100644
index 0000000..6d73be1
--- /dev/null
+++ b/extra/hunter_cd.sh
@@ -0,0 +1,6 @@
+function hunter() {
+ env hunter
+ test -e ~/.hunter_cwd &&
+ source ~/.hunter_cwd &&
+ rm ~/.hunter_cwd && cd $HUNTER_CWD
+}
diff --git a/src/file_browser.rs b/src/file_browser.rs
index 9458da7..dc24fa8 100644
--- a/src/file_browser.rs
+++ b/src/file_browser.rs
@@ -148,9 +148,7 @@ impl Tabbable for TabView<FileBrowser> {
.widgets
.iter()
.map(|w| {
- w.selected_files()
- .map_err(|_| Vec::<Files>::new())
- .unwrap()
+ w.selected_files().unwrap_or(vec![])
}).collect();
self.widgets[self.active].exec_cmd(tab_dirs, selected_files)
@@ -838,21 +836,29 @@ impl FileBrowser {
tab_files: Vec<Vec<File>>) -> HResult<()> {
let cwd = self.cwd()?.clone();
- let selected_file = self.selected_file()?;
- let selected_files = self.selected_files()?;
+ let selected_file = self.selected_file().ok();
+ let selected_files = self.selected_files().ok();
let cmd = self.minibuffer("exec")?.trim_start().to_string() + " ";
- let cwd_files = if selected_files.len() == 0 {
- vec![selected_file]
- } else { selected_files };
+ let cwd_files = selected_files.map(|selected_files| {
+ if selected_files.len() == 0 {
+ if selected_file.is_some() {
+ vec![selected_file.unwrap()]
+ } else {
+ selected_files
+ }
+ } else {
+ selected_files
+ }
+ });
let cmd = crate::proclist::Cmd {
cmd: OsString::from(cmd),
short_cmd: None,
args: None,
cwd: cwd,
- cwd_files: Some(cwd_files),
+ cwd_files: cwd_files,
tab_files: Some(tab_files),
tab_paths: Some(tab_dirs)
};
diff --git a/src/proclist.rs b/src/proclist.rs
index 74912ea..69dc1e8 100644
--- a/src/proclist.rs
+++ b/src/proclist.rs
@@ -51,6 +51,8 @@ impl Cmd {
}
fn substitute_cwd_files(&mut self, cmd: Vec<OsString>) -> Vec<OsString> {
+ if self.cwd_files.is_none() { return cmd; }
+
let cwd_pat = OsString::from("$s");
let cwd_files = self.cwd_files
.take()
@@ -66,6 +68,8 @@ impl Cmd {
}
fn substitute_tab_files(&mut self, cmd: Vec<OsString>) -> Vec<OsString> {
+ if self.tab_files.is_none() { return cmd; }
+
let tab_files = self.tab_files.take().unwrap();
tab_files.into_iter()
@@ -84,6 +88,8 @@ impl Cmd {
}
fn substitute_tab_paths(&mut self, cmd: Vec<OsString>) -> Vec<OsString> {
+ if self.tab_paths.is_none() { return cmd; }
+
let tab_paths = self.tab_paths.take().unwrap();
tab_paths.into_iter()