diff options
author | Matthew Blode <m@blode.co> | 2021-01-20 09:56:29 +1100 |
---|---|---|
committer | Matthew Blode <m@blode.co> | 2021-01-20 09:56:29 +1100 |
commit | 0eae92bc7038219247ebb72de324933372f26213 (patch) | |
tree | 9fd782a6121cdab63a2554fbc0040f9feac57890 | |
parent | f07eee4abb6fec4cb57b535143720763c9e0848b (diff) |
cd with tilde expansion
-rw-r--r-- | Cargo.lock | 77 | ||||
-rw-r--r-- | Cargo.toml | 3 | ||||
-rw-r--r-- | config/mimetype.toml | 16 | ||||
-rw-r--r-- | src/commands/key_command.rs | 7 | ||||
-rw-r--r-- | src/main.rs | 2 | ||||
-rw-r--r-- | src/ui/views/tui_progress_view.rs | 10 |
6 files changed, 88 insertions, 27 deletions
@@ -143,7 +143,28 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3fd78930633bd1c6e35c4b42b1df7b0cbc6bc191146e512bb3bedf243fcc3901" dependencies = [ "libc", - "redox_users", + "redox_users 0.3.5", + "winapi", +] + +[[package]] +name = "dirs-next" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b98cf8ebf19c3d1b223e151f99a4f9f0690dca41414773390fc824184ac833e1" +dependencies = [ + "cfg-if 1.0.0", + "dirs-sys-next", +] + +[[package]] +name = "dirs-sys-next" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4ebda144c4fe02d1f7ea1a7d9641b6fc6b580adcfa024ae48797ecdeb6825b4d" +dependencies = [ + "libc", + "redox_users 0.4.0", "winapi", ] @@ -159,6 +180,17 @@ dependencies = [ ] [[package]] +name = "getrandom" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c9495705279e7140bf035dde1f6e750c162df8b625267cd52cc44e0b156732c8" +dependencies = [ + "cfg-if 1.0.0", + "libc", + "wasi 0.10.0+wasi-snapshot-preview1", +] + +[[package]] name = "heck" version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -182,7 +214,7 @@ version = "0.8.5" dependencies = [ "alphanumeric-sort", "chrono", - "dirs", + "dirs-next", "lazy_static", "libc", "open", @@ -192,6 +224,7 @@ dependencies = [ "serde", "serde_derive", "shell-words", + "shellexpand", "signal-hook", "structopt", "termion", @@ -382,7 +415,7 @@ version = "0.7.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6a6b1679d49b24bbfe0c803429aa1874472f50d9b363131f0e89fc356b544d03" dependencies = [ - "getrandom", + "getrandom 0.1.15", "libc", "rand_chacha", "rand_core", @@ -406,7 +439,7 @@ version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "90bde5296fc891b0cef12a6d03ddccc162ce7b2aff54160af9338f8d40df6d19" dependencies = [ - "getrandom", + "getrandom 0.1.15", ] [[package]] @@ -434,12 +467,21 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "41cc0f7e4d5d4544e8861606a285bb08d3e70712ccc7d2b84d7c0ccfaf4b05ce" [[package]] +name = "redox_syscall" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "05ec8ca9416c5ea37062b502703cd7fcb207736bc294f6e0cf367ac6fc234570" +dependencies = [ + "bitflags", +] + +[[package]] name = "redox_termios" version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7e891cfe48e9100a70a3b6eb652fef28920c117d366339687bd5576160db0f76" dependencies = [ - "redox_syscall", + "redox_syscall 0.1.57", ] [[package]] @@ -448,12 +490,22 @@ version = "0.3.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "de0737333e7a9502c789a36d7c7fa6092a49895d4faa31ca5df163857ded2e9d" dependencies = [ - "getrandom", - "redox_syscall", + "getrandom 0.1.15", + "redox_syscall 0.1.57", "rust-argon2", ] [[package]] +name = "redox_users" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "528532f3d801c87aec9def2add9ca802fe569e44a544afe633765267840abe64" +dependencies = [ + "getrandom 0.2.2", + "redox_syscall 0.2.4", +] + +[[package]] name = "rust-argon2" version = "0.8.3" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -506,6 +558,15 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b6fa3938c99da4914afedd13bf3d79bcb6c277d1b2c398d23257a304d9e1b074" [[package]] +name = "shellexpand" +version = "2.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "83bdb7831b2d85ddf4a7b148aa19d0587eddbe8671a436b7bd1182eaad0f2829" +dependencies = [ + "dirs-next", +] + +[[package]] name = "signal-hook" version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -579,7 +640,7 @@ checksum = "c22cec9d8978d906be5ac94bceb5a010d885c626c4c8855721a4dbd20e3ac905" dependencies = [ "libc", "numtoa", - "redox_syscall", + "redox_syscall 0.1.57", "redox_termios", ] @@ -10,7 +10,7 @@ edition = "2018" [dependencies] alphanumeric-sort = "^1" chrono = "^0" -dirs = "^1" +dirs-next = "^2" lazy_static = "^1" libc = "^0" open = "^1" @@ -30,6 +30,7 @@ users = "^0" whoami = "^0" xdg = "^2" phf = { version = "^0", features = ["macros"] } +shellexpand = "^2" # notify = { version = "5.0.0-pre.2" } # fs_extra = "*" diff --git a/config/mimetype.toml b/config/mimetype.toml index b56a5cd..c104366 100644 --- a/config/mimetype.toml +++ b/config/mimetype.toml @@ -60,28 +60,28 @@ ts = [ ## video formats avi = [ { command = "mpv", fork = true, silent = true }, - { command = "mediainfo", confirm_exit = true }, + { command = "mediainfo", confirm_exit = true } ] av1 = [ { command = "mpv", fork = true, silent = true }, - { command = "mediainfo", confirm_exit = true }, + { command = "mediainfo", confirm_exit = true } ] flv = [ { command = "mpv", fork = true, silent = true }, - { command = "mediainfo", confirm_exit = true }, + { command = "mediainfo", confirm_exit = true } ] mkv = [ { command = "mpv", fork = true, silent = true }, - { command = "mediainfo", confirm_exit = true }, + { command = "mediainfo", confirm_exit = true } ] mov = [ { command = "mpv", fork = true, silent = true }, - { command = "mediainfo", confirm_exit = true }, + { command = "mediainfo", confirm_exit = true } ] mp4 = [ { command = "mpv", fork = true, silent = true }, - { command = "mediainfo", confirm_exit = true }, + { command = "mediainfo", confirm_exit = true } ] webm = [ { command = "mpv", fork = true, silent = true }, - { command = "mediainfo", confirm_exit = true }, + { command = "mediainfo", confirm_exit = true } ] wmv = [ { command = "mpv", fork = true, silent = true }, - { command = "mediainfo", confirm_exit = true }, + { command = "mediainfo", confirm_exit = true } ] ## text formats build = [ diff --git a/src/commands/key_command.rs b/src/commands/key_command.rs index 3bdb57d..73257fa 100644 --- a/src/commands/key_command.rs +++ b/src/commands/key_command.rs @@ -8,6 +8,8 @@ use crate::util::load_child::LoadChild; use crate::util::sort::SortType; use crate::HOME_DIR; +use dirs_next::home_dir; +use shellexpand::tilde_with_context; use super::*; @@ -136,7 +138,10 @@ impl KeyCommand { )), }, ".." => Ok(Self::ParentDirectory), - arg => Ok(Self::ChangeDirectory(path::PathBuf::from(arg))), + arg => Ok({ + let path_accepts_tilde = tilde_with_context(arg, home_dir); + Self::ChangeDirectory(path::PathBuf::from(path_accepts_tilde.as_ref())) + }), }, "close_tab" => Ok(Self::CloseTab), "copy_files" => Ok(Self::CopyFiles), diff --git a/src/main.rs b/src/main.rs index ed866b3..4962cb6 100644 --- a/src/main.rs +++ b/src/main.rs @@ -46,7 +46,7 @@ lazy_static! { static ref MIMETYPE_T: JoshutoMimetype = JoshutoMimetype::get_config(); static ref PREVIEW_T: JoshutoPreview = JoshutoPreview::get_config(); - static ref HOME_DIR: Option<PathBuf> = dirs::home_dir(); + static ref HOME_DIR: Option<PathBuf> = dirs_next::home_dir(); static ref USERNAME: String = whoami::username(); static ref HOSTNAME: String = whoami::hostname(); } diff --git a/src/ui/views/tui_progress_view.rs b/src/ui/views/tui_progress_view.rs index 9dad78f..8b0c283 100644 --- a/src/ui/views/tui_progress_view.rs +++ b/src/ui/views/tui_progress_view.rs @@ -33,16 +33,11 @@ impl<'a> Widget for TuiProgressView<'a> { let terminal = backend.terminal_mut(); loop { - terminal - .draw(|mut frame| { - }) - .unwrap(); + terminal.draw(|mut frame| {}).unwrap(); if let Ok(event) = context.events.next() { match event { - Event::IOWorkerProgress(_) => { - - } + Event::IOWorkerProgress(_) => {} Event::Input(key) => { match key { Key::Backspace => { @@ -125,6 +120,5 @@ impl<'a> Widget for TuiProgressView<'a> { }; } } - } } |