Uninstall Mac apps with every file they leave behind, and see why each belongs. Free up space, fine-tune macOS, and set up Terminal.
Swift cache-cleanercleanerclideveloper-toolsdisk-cleanupdisk-spaceduplicate-finderhomebrewliquid-glassmac-cleanermacosmacos-appmacos-golden-gatemacos-tahoemacos-tweaksswiftswiftuiterminal-themesuninstalluninstaller
Put a person's profile back after they deleted Peel's theme in Terminal
Țugui Dragoșa2344a0c190e
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 6569dc91..3ad40366 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -381,6 +381,7 @@ its changes the way [Keep a Changelog](https://keepachangelog.com/) suggests.#### Terminal+- Put Back on the Themes tab brings back the profile you had, also once you deleted Peel's theme in Terminal.- A switch on the Shell tab turned on while zsh answers stays on, and the next one doesn't lose it.- The Tools tab no longer has Homebrew fetch its lists where its `brew.env` asks it to do so before answering.- The Git tab reads a signing key written in Git's settings as a key, not a path, and its commands quote what the shelldiff --git a/Packages/PeelCore/Sources/PeelCore/Terminal/TerminalThemeLedger.swift b/Packages/PeelCore/Sources/PeelCore/Terminal/TerminalThemeLedger.swiftindex bcd9ee40..b2e18286 100644--- a/Packages/PeelCore/Sources/PeelCore/Terminal/TerminalThemeLedger.swift+++ b/Packages/PeelCore/Sources/PeelCore/Terminal/TerminalThemeLedger.swift@@ -104,7 +104,10 @@ public struct TerminalThemeLedger {guard !terminal.isTerminalOpen else { return .terminalIsOpen }guard !terminal.isManaged else { return .managed }guard var profiles = terminal.profiles() else { return .unreadable }- for role in TerminalProfileRole.allCases where terminal.profileName(for: role) == chosen {+ // A role on another profile was changed by the person and stays, unless the theme is gone: Terminal itself+ // moves a role off a profile deleted there, which is no choice of a profile.+ let isGone = chosen.map { profiles[$0] == nil } ?? false+ for role in TerminalProfileRole.allCases where isGone || terminal.profileName(for: role) == chosen {guard terminal.setProfileName(before[role], for: role) else { return .refused }}let inUse = Set(TerminalProfileRole.allCases.compactMap { terminal.profileName(for: $0) })diff --git a/Packages/PeelCore/Tests/PeelCoreTests/TerminalThemeLedgerTests.swift b/Packages/PeelCore/Tests/PeelCoreTests/TerminalThemeLedgerTests.swiftindex 43e9c616..f8fa9b1d 100644--- a/Packages/PeelCore/Tests/PeelCoreTests/TerminalThemeLedgerTests.swift+++ b/Packages/PeelCore/Tests/PeelCoreTests/TerminalThemeLedgerTests.swift@@ -54,6 +54,18 @@ struct TerminalThemeLedgerTests {#expect(ledger.canPutBack)}+ @Test func putsBackWhatWasThereBeforeOnceTerminalMovedOffAThemeDeletedThere() throws {+ let terminal = InMemoryTerminalSettings()+ var ledger = TerminalThemeLedger()+ #expect(try ledger.use(theme, in: terminal) == .changed)++ terminal.storedProfiles[theme.profileName] = nil+ terminal.names = [.newWindows: "Pro", .startup: "Pro"]++ #expect(ledger.putBack(in: terminal) == .changed)+ #expect(terminal.names == [.newWindows: "Basic", .startup: "Basic"])+ }+@Test func aThemeInUseOpensEveryTerminalWindowWithIt() throws {let terminal = InMemoryTerminalSettings()var ledger = TerminalThemeLedger()