A treemap for finding and removing what fills your disk, for Omarchy. Rust + GPUI.
Rust
app: Open Folder, rescan, quit and reveal shortcuts on Linux and Windows
Tobi Lütke13fd9ee158b5
diff --git a/README.md b/README.mdindex 172d0a9..708b04b 100644--- a/README.md+++ b/README.md@@ -202,15 +202,17 @@ and shows how much free space was actually gained.| `d` | disk usage or apparent size || `i` | include or skip hidden entries || `r` | scan again |+| `ctrl o` (`⌘O` on macOS) | choose another directory to scan || `g` | the whole disk || `p` | show or hide the selection line |-| `o` | show it in Finder or the file manager |+| `o` | show it in Finder, File Explorer or the file manager || `?` | every key || `q` | quit |-On macOS the menu bar also has ⌘O to open a folder, ⌘⇧R to show the-selection in Finder, ⌘R to rescan, and ⌘Q, ⌘H and ⌘W (closing the window-quits); other ⌘ chords are left to the system.+On macOS the menu bar also has ⌘⇧R to show the selection in Finder, ⌘R to+rescan, ⌘[ and ⌘] for back and forward, and ⌘Q, ⌘H and ⌘W (closing the+window quits); other ⌘ chords are left to the system. On Linux and Windows+the same work with ctrl, with F5 to rescan too.On the review screen: `m` trash, `p` permanent, `!` unmark all, `enter`commits, `esc` goes back.diff --git a/crates/disktree-app/src/app_menu.rs b/crates/disktree-app/src/app_menu.rsindex 00804ca..faee476 100644--- a/crates/disktree-app/src/app_menu.rs+++ b/crates/disktree-app/src/app_menu.rs@@ -1,9 +1,9 @@//! The menu bar and the application-wide shortcuts.//!//! GPUI adds neither on its own. On macOS an app without them has an empty-//! menu bar and no ⌘Q, so this is where disktree becomes a Mac app; on-//! Linux the desktop owns quitting and there is no menu bar to fill, so only-//! "closing the window quits" applies there.+//! menu bar and no ⌘Q, so this is where disktree becomes a Mac app. GPUI+//! draws no menu bar on Linux or Windows, so there the same actions get the+//! shortcuts their users expect, with ctrl, and nothing else.use gpui_kit::{App, KeyBinding, Menu, MenuItem, SystemMenuType};@@ -54,13 +54,7 @@ pub fn install(cx: &mut App) {}).detach();- if !cfg!(target_os = "macos") {- return;- }cx.on_action(|_: &Quit, cx| cx.quit());- cx.on_action(|_: &Hide, cx| cx.hide());- cx.on_action(|_: &HideOthers, cx| cx.hide_other_apps());- cx.on_action(|_: &ShowAll, cx| cx.unhide_other_apps());cx.on_action(|_: &CloseWindow, cx| {if let Some(window) = cx.active_window() {let _ = window.update(cx, |_, window, _| window.remove_window());@@ -68,6 +62,20 @@ pub fn install(cx: &mut App) {});// `Rescan`, `OpenFolder`, `ShowInFinder` and the history are handled by// the window, which owns the scan and the selection; see `views::root`.+ if !cfg!(target_os = "macos") {+ cx.bind_keys([+ KeyBinding::new("ctrl-q", Quit, None),+ KeyBinding::new("ctrl-w", CloseWindow, None),+ KeyBinding::new("ctrl-o", OpenFolder, None),+ KeyBinding::new("ctrl-r", Rescan, None),+ KeyBinding::new("f5", Rescan, None),+ KeyBinding::new("ctrl-shift-r", ShowInFinder, None),+ ]);+ return;+ }+ cx.on_action(|_: &Hide, cx| cx.hide());+ cx.on_action(|_: &HideOthers, cx| cx.hide_other_apps());+ cx.on_action(|_: &ShowAll, cx| cx.unhide_other_apps());cx.bind_keys([KeyBinding::new("cmd-q", Quit, None),KeyBinding::new("cmd-h", Hide, None),diff --git a/crates/disktree-app/src/views.rs b/crates/disktree-app/src/views.rsindex fc5541e..fcfd83c 100644--- a/crates/disktree-app/src/views.rs+++ b/crates/disktree-app/src/views.rs@@ -2944,12 +2944,17 @@ const MODIFIER_ZOOM: &str = if cfg!(target_os = "macos") {} else {"ctrl = / - / 0"};+const MODIFIER_OPEN: &str = if cfg!(target_os = "macos") {+ "\u{2318}O"+} else {+ "ctrl-o"+};fn help_overlay(app: &Disktree, cx: &gpui_kit::App) -> Div {let theme = cx.omarchy();// Sentence case, and the tile a key acts on is always the one under the// pointer if the pointer moved last, else the keyboard selection.- let rows: [(&str, &str); 26] = [+ let rows: [(&str, &str); 27] = [("space / x", "Mark or unmark the tile you point at"),(MODIFIER_CLICK, "Mark without moving the selection"),("enter", "Open that directory, at any depth"),@@ -2975,6 +2980,7 @@ fn help_overlay(app: &Disktree, cx: &gpui_kit::App) -> Div {("c", "Review the marked list"),("t", "Size, files or age: what areas and colours say"),("r", "Scan again from the same root"),+ (MODIFIER_OPEN, "Choose another directory to scan"),("g", "The whole disk; click any directory above to widen"),("d", "Disk usage or apparent size"),("i", "Include or skip hidden entries"),@@ -2983,6 +2989,8 @@ fn help_overlay(app: &Disktree, cx: &gpui_kit::App) -> Div {"o",if cfg!(target_os = "macos") {"Show it in Finder"+ } else if cfg!(windows) {+ "Show it in File Explorer"} else {"Show it in the file manager"},