Skip to content

armgit / peel

Public Imported from GitHub
0

Uninstall Mac apps with every file they leave behind, and see why each belongs. Free up space, fine-tune macOS, and set up Terminal.

Developer lists zsh's completion dump and Oh My Zsh's completions

Țugui Dragoș3bd053522c60
diff --git a/Packages/PeelCore/Sources/PeelCore/Developer/DeveloperCaches.swift b/Packages/PeelCore/Sources/PeelCore/Developer/DeveloperCaches.swift
index 16eac382..1a241c8b 100644
--- a/Packages/PeelCore/Sources/PeelCore/Developer/DeveloperCaches.swift
+++ b/Packages/PeelCore/Sources/PeelCore/Developer/DeveloperCaches.swift
@@ -577,6 +577,15 @@ public enum DeveloperCaches {
Definition(id: "mise", name: "mise", systemImage: "shippingbox", appBundleIdentifiers: [], folders: [
Folder("Library/Caches/mise", .cache, source: "https://github.com/jdx/mise/blob/main/docs/directories.md#L34-L41"),
]),
+ // Shells
+ Definition(id: "zsh", name: "zsh", systemImage: "terminal", appBundleIdentifiers: [], folders: [
+ Folder(".zcompdump*", .cache, source: "https://zsh.sourceforge.io/Doc/Release/Completion-System.html#Use-of-compinit"),
+ ]),
+ // Only the completion scripts plug-ins make again when missing: `dotenv` keeps the files a person allowed
+ // beside them in the same cache folder.
+ Definition(id: "ohmyzsh", name: "Oh My Zsh", systemImage: "terminal", appBundleIdentifiers: [], folders: [
+ Folder(".oh-my-zsh/cache/completions", .cache, source: "https://github.com/ohmyzsh/ohmyzsh/blob/master/oh-my-zsh.sh#L59-L68"),
+ ]),
// Editors
// A JetBrains IDE keeps `LocalHistory` beside its caches: the edits it recorded while a project was
// open, which are in no repository and nowhere else. The cache folders are listed one by one, so
diff --git a/Packages/PeelCore/Tests/PeelCoreTests/DeveloperCachesTests.swift b/Packages/PeelCore/Tests/PeelCoreTests/DeveloperCachesTests.swift
index 56412186..b151da0a 100644
--- a/Packages/PeelCore/Tests/PeelCoreTests/DeveloperCachesTests.swift
+++ b/Packages/PeelCore/Tests/PeelCoreTests/DeveloperCachesTests.swift
@@ -214,9 +214,10 @@ struct DeveloperCachesTests {
".npm", ".cargo", ".gradle", ".m2", ".android", ".nuget", ".gem", ".bundle", ".aws", ".config", ".cache",
".local", ".local/share", "go", ".vscode", ".ollama", ".lmstudio", ".cache/huggingface",
]
- // The only top-level folders in the table, each owned outright by the one tool that made it.
+ // The only top-level entries in the table, each owned outright by the one tool that made it.
let ownedOutright: Set<String> = [
".ccache", ".electron-gyp", ".gitlibs", ".node-gyp", ".virtualenvs", "nltk_data", "tensorflow_datasets",
+ ".zcompdump*",
]
for definition in DeveloperCaches.definitions {
for path in definition.folders.map(\.path) {
@@ -742,6 +743,19 @@ struct DeveloperCachesTests {
#expect(locations.first?.kind == .downloads)
}
+ @Test func offersZshsCompletionDumpsAndOhMyZshsCompletionsAndNotTheChoicesKeptBeside() async throws {
+ let directory = try TemporaryDirectory()
+ try directory.file(".zcompdump", bytes: 4_096)
+ try directory.file(".zcompdump-Mac-5.9", bytes: 4_096)
+ try directory.file(".oh-my-zsh/cache/completions/_gh", bytes: 4_096)
+ try directory.file(".oh-my-zsh/cache/dotenv-allowed.list", bytes: 64)
+ let shells = DeveloperCaches.definitions.filter { ["zsh", "ohmyzsh"].contains($0.id) }
+
+ let locations = await DeveloperCaches.scan(shells, homeDirectory: directory.url).flatMap(\.locations)
+
+ #expect(Set(locations.map(\.url.lastPathComponent)) == [".zcompdump", ".zcompdump-Mac-5.9", "completions"])
+ }
+
/// virtualenvwrapper keeps the user's hook scripts beside the environments in `~/.virtualenvs`, so only the
/// environments are offered, and a link among them is left where it is, never followed.
@Test func offersVirtualenvwrappersEnvironmentsAndNotItsHooks() async throws {