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
Say why Peel's settings file in Terminal couldn't be read or saved
Țugui Dragoș5d17d679fa0c
diff --git a/Localization/Peel/Localizable.xcstrings b/Localization/Peel/Localizable.xcstringsindex 153e59df..4125aefc 100644--- a/Localization/Peel/Localizable.xcstrings+++ b/Localization/Peel/Localizable.xcstrings@@ -142498,6 +142498,112 @@}}},+ "Peel couldn’t save its settings file." : {+ "localizations" : {+ "cs" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Peel nemohl uložit svůj soubor nastavení."+ }+ },+ "de" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Peel konnte die eigene Einstellungsdatei nicht sichern."+ }+ },+ "es" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Peel no ha podido guardar su archivo de ajustes."+ }+ },+ "fr" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Peel n’a pas pu enregistrer son fichier de réglages."+ }+ },+ "it" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Peel non è riuscito a salvare il proprio file delle impostazioni."+ }+ },+ "ja" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Peelは自身の設定ファイルを保存できませんでした。"+ }+ },+ "ko" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Peel이 자신의 설정 파일을 저장할 수 없었습니다."+ }+ },+ "nl" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Peel kon zijn instellingenbestand niet bewaren."+ }+ },+ "pl" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Peel nie mógł zachować swojego pliku ustawień."+ }+ },+ "pt" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "O Peel não conseguiu salvar o próprio arquivo de ajustes."+ }+ },+ "ro" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Peel nu și‑a putut salva fișierul de configurare."+ }+ },+ "ru" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Peel не удалось сохранить свой файл настроек."+ }+ },+ "sv" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Peel kunde inte spara sin inställningsfil."+ }+ },+ "tr" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Peel kendi ayar dosyasını kaydedemedi."+ }+ },+ "uk" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Peel не вдалося зберегти свій файл налаштувань."+ }+ },+ "zh-Hans" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Peel未能保存它的设置文件。"+ }+ },+ "zh-Hant" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Peel無法儲存它的設定檔。"+ }+ }+ }+ },"Peel couldn’t save that these files belong to %@" : {"localizations" : {"cs" : {@@ -157640,108 +157746,108 @@}}},- "Peel’s settings file couldn’t be read" : {+ "Peel’s settings file couldn’t be read." : {"localizations" : {"cs" : {"stringUnit" : {"state" : "translated",- "value" : "Soubor nastavení Peelu nelze přečíst"+ "value" : "Soubor nastavení Peelu nelze přečíst."}},"de" : {"stringUnit" : {"state" : "translated",- "value" : "Die Einstellungsdatei von Peel konnte nicht gelesen werden"+ "value" : "Die Einstellungsdatei von Peel konnte nicht gelesen werden."}},"es" : {"stringUnit" : {"state" : "translated",- "value" : "No se ha podido leer el archivo de ajustes de Peel"+ "value" : "No se ha podido leer el archivo de ajustes de Peel."}},"fr" : {"stringUnit" : {"state" : "translated",- "value" : "Impossible de lire le fichier de réglages de Peel"+ "value" : "Impossible de lire le fichier de réglages de Peel."}},"it" : {"stringUnit" : {"state" : "translated",- "value" : "Impossibile leggere il file delle impostazioni di Peel"+ "value" : "Impossibile leggere il file delle impostazioni di Peel."}},"ja" : {"stringUnit" : {"state" : "translated",- "value" : "Peelの設定ファイルを読み取れませんでした"+ "value" : "Peelの設定ファイルを読み取れませんでした。"}},"ko" : {"stringUnit" : {"state" : "translated",- "value" : "Peel 설정 파일을 읽을 수 없음"+ "value" : "Peel 설정 파일을 읽을 수 없습니다."}},"nl" : {"stringUnit" : {"state" : "translated",- "value" : "Het instellingenbestand van Peel kon niet worden gelezen"+ "value" : "Het instellingenbestand van Peel kon niet worden gelezen."}},"pl" : {"stringUnit" : {"state" : "translated",- "value" : "Nie udało się odczytać pliku ustawień Peel"+ "value" : "Nie udało się odczytać pliku ustawień Peel."}},"pt" : {"stringUnit" : {"state" : "translated",- "value" : "Não foi possível ler o arquivo de ajustes do Peel"+ "value" : "Não foi possível ler o arquivo de ajustes do Peel."}},"ro" : {"stringUnit" : {"state" : "translated",- "value" : "Fișierul de configurare Peel nu a putut fi citit"+ "value" : "Fișierul de configurare Peel nu a putut fi citit."}},"ru" : {"stringUnit" : {"state" : "translated",- "value" : "Не удалось прочитать файл настроек Peel"+ "value" : "Не удалось прочитать файл настроек Peel."}},"sv" : {"stringUnit" : {"state" : "translated",- "value" : "Peels inställningsfil kunde inte läsas"+ "value" : "Peels inställningsfil kunde inte läsas."}},"tr" : {"stringUnit" : {"state" : "translated",- "value" : "Peel’in ayar dosyası okunamadı"+ "value" : "Peel’in ayar dosyası okunamadı."}},"uk" : {"stringUnit" : {"state" : "translated",- "value" : "Не вдалося прочитати файл налаштувань Peel"+ "value" : "Не вдалося прочитати файл налаштувань Peel."}},"zh-Hans" : {"stringUnit" : {"state" : "translated",- "value" : "未能读取Peel的设置文件"+ "value" : "未能读取Peel的设置文件。"}},"zh-Hant" : {"stringUnit" : {"state" : "translated",- "value" : "無法讀取Peel的設定檔"+ "value" : "無法讀取Peel的設定檔。"}}}diff --git a/Packages/PeelCore/Sources/PeelCore/Terminal/SSHFile.swift b/Packages/PeelCore/Sources/PeelCore/Terminal/SSHFile.swiftindex 9d7c684a..e1a3312b 100644--- a/Packages/PeelCore/Sources/PeelCore/Terminal/SSHFile.swift+++ b/Packages/PeelCore/Sources/PeelCore/Terminal/SSHFile.swift@@ -54,8 +54,20 @@ public enum SSHFile {}}- public static func write(_ settings: Set<SSHSetting>, to url: URL) -> Bool {- (try? PeelFolder.write(Data(contents(of: settings).utf8), to: url)) != nil+ /// Why the file at `url` can't be read, or nil when it can, or isn't there.+ public static func whyUnreadable(_ url: URL) -> FileProblem? {+ url.isMissing ? nil : BoundedRead.whyUnreadable(url, maximum: maximumBytes)+ }++ /// Writes `settings` to `url`, and answers why it couldn't, or nil once it did.+ @discardableResult+ public static func write(_ settings: Set<SSHSetting>, to url: URL) -> FileProblem? {+ do {+ try PeelFolder.write(Data(contents(of: settings).utf8), to: url)+ return nil+ } catch {+ return .failed(SystemError(error))+ }}/// The lines that make ssh read the file. `Match all` first, so they apply to every server even after a `Host`diff --git a/Packages/PeelCore/Sources/PeelCore/Terminal/ShellFile.swift b/Packages/PeelCore/Sources/PeelCore/Terminal/ShellFile.swiftindex 0f0fdc5f..86a1c227 100644--- a/Packages/PeelCore/Sources/PeelCore/Terminal/ShellFile.swift+++ b/Packages/PeelCore/Sources/PeelCore/Terminal/ShellFile.swift@@ -50,8 +50,20 @@ public enum ShellFile {return BoundedRead.data(at: url, maximum: maximumBytes).map { choices(in: String(decoding: $0, as: UTF8.self)) }}- public static func write(_ choices: Choices, to url: URL) -> Bool {- (try? PeelFolder.write(Data(contents(of: choices).utf8), to: url)) != nil+ /// Why the file at `url` can't be read, or nil when it can, or isn't there.+ public static func whyUnreadable(_ url: URL) -> FileProblem? {+ url.isMissing ? nil : BoundedRead.whyUnreadable(url, maximum: maximumBytes)+ }++ /// Writes `choices` to `url`, and answers why it couldn't, or nil once it did.+ @discardableResult+ public static func write(_ choices: Choices, to url: URL) -> FileProblem? {+ do {+ try PeelFolder.write(Data(contents(of: choices).utf8), to: url)+ return nil+ } catch {+ return .failed(SystemError(error))+ }}public static func line(sourcing url: URL, home: URL) -> String {diff --git a/Packages/PeelCore/Tests/PeelCoreTests/PeelFolderTests.swift b/Packages/PeelCore/Tests/PeelCoreTests/PeelFolderTests.swiftindex 98450cb4..34cf144c 100644--- a/Packages/PeelCore/Tests/PeelCoreTests/PeelFolderTests.swift+++ b/Packages/PeelCore/Tests/PeelCoreTests/PeelFolderTests.swift@@ -26,8 +26,8 @@ struct PeelFolderTests {FileLock.whileHeld(beside: file("a.json")) {}#expect(AppFolders(url: file("app-folders.json")).add([directory.url]) != .saved)#expect(HomebrewChoice(url: file("homebrew.json")).save(nil) != nil)- #expect(!ShellFile.write(ShellFile.Choices(), to: file("Terminal/zshrc")))- #expect(!SSHFile.write([], to: file("Terminal/ssh_config")))+ #expect(ShellFile.write(ShellFile.Choices(), to: file("Terminal/zshrc")) != nil)+ #expect(SSHFile.write([], to: file("Terminal/ssh_config")) != nil)await ReleaseNotesStore(url: file("release-notes.json")).save(ReleaseNotesMemory())let known = KnownDigests(entries: [:], day: 0)let identity = try #require(FileIdentity.of(try directory.file("a file")))diff --git a/Packages/PeelCore/Tests/PeelCoreTests/PromptTests.swift b/Packages/PeelCore/Tests/PeelCoreTests/PromptTests.swiftindex 4945ba4c..cadad6a9 100644--- a/Packages/PeelCore/Tests/PeelCoreTests/PromptTests.swift+++ b/Packages/PeelCore/Tests/PeelCoreTests/PromptTests.swift@@ -17,7 +17,7 @@ struct PromptTests {git.waitUntilExit()#expect(git.terminationStatus == 0)}- #expect(ShellFile.write(.init(prompt: prompt), to: shell.peelFile))+ #expect(ShellFile.write(.init(prompt: prompt), to: shell.peelFile) == nil)let shown = try shell.output(of: "cd ~/Projects/peel; (( $+functions[vcs_info] )) && vcs_info; true; print -rnP -- \"${(e)PROMPT}\"; "+ "print -n '|'; false; print -rnP -- \"${(e)PROMPT}\"; print -n '|'; print -rn -- \"$PROMPT\""@@ -41,7 +41,7 @@ struct PromptTests {let shell = try ZshHome()for start in Prompt.Start.allCases {let prompt = Prompt(start: start, showsBranch: false)- #expect(ShellFile.write(.init(prompt: prompt), to: shell.peelFile))+ #expect(ShellFile.write(.init(prompt: prompt), to: shell.peelFile) == nil)let shown = try shell.output(of: "cd ~; print -rnP -- \"${(e)PROMPT}\"")let sample = prompt.sample(user: NSUserName(), host: Prompt.hostName(), path: "~", branch: nil, failed: false)#expect(Self.merged(Self.segments(in: shown)) == Self.merged(sample), "\(start)")@@ -58,7 +58,7 @@ struct PromptTests {(["alias ll='ls -l'"], false),] {let shell = try ZshHome(thenRun: lines)- #expect(ShellFile.write(.init(prompt: peelsOwn), to: shell.peelFile))+ #expect(ShellFile.write(.init(prompt: peelsOwn), to: shell.peelFile) == nil)let startup = shell.home.appending(path: ".zshrc")#expect(ShellFile.setsItsOwnPrompt(after: shell.peelFile, in: startup, home: shell.home) == setsItsOwn, "\(lines)")let shown = try shell.output(of: "print -rnP -- \"$PROMPT\"")@@ -84,7 +84,7 @@ struct PromptTests {] {let shell = try ZshHome(before: lines)try "print noise after\n".write(to: shell.home.appending(path: ".zlogout"), atomically: true, encoding: .utf8)- #expect(ShellFile.write(.init(prompt: peels), to: shell.peelFile))+ #expect(ShellFile.write(.init(prompt: peels), to: shell.peelFile) == nil)let zsh = ShellSessions.zsh(startupFile: shell.home.appending(path: ".zshenv"))let zdotdir = shell.home.path(percentEncoded: false)let shown = try #require(await zsh.promptShown(home: shell.home, zdotdir: zdotdir))@@ -92,7 +92,7 @@ struct PromptTests {#expect(shown.setBeforeEachCommandBy == setters, "\(lines)")}let after = try ZshHome(thenRun: ["PROMPT='static> '"])- #expect(ShellFile.write(.init(prompt: peels), to: after.peelFile))+ #expect(ShellFile.write(.init(prompt: peels), to: after.peelFile) == nil)let zsh = ShellSessions.zsh(startupFile: after.home.appending(path: ".zshenv"))let zdotdir = after.home.path(percentEncoded: false)let shown = try #require(await zsh.promptShown(home: after.home, zdotdir: zdotdir))diff --git a/Packages/PeelCore/Tests/PeelCoreTests/SSHFileTests.swift b/Packages/PeelCore/Tests/PeelCoreTests/SSHFileTests.swiftindex 5f82ee19..203b49a9 100644--- a/Packages/PeelCore/Tests/PeelCoreTests/SSHFileTests.swift+++ b/Packages/PeelCore/Tests/PeelCoreTests/SSHFileTests.swift@@ -49,10 +49,10 @@ struct SSHFileTests {#expect(Set(Self.inEffect.keys) == Set(SSHSetting.allCases))for setting in SSHSetting.allCases {let wanted = try #require(Self.inEffect[setting])- #expect(SSHFile.write([], to: ssh.peelFile))+ #expect(SSHFile.write([], to: ssh.peelFile) == nil)let before = try await ssh.options(for: "example.org")#expect(wanted.allSatisfy { before[$0.key] != $0.value }, "\(setting)")- #expect(SSHFile.write([setting], to: ssh.peelFile))+ #expect(SSHFile.write([setting], to: ssh.peelFile) == nil)let after = try await ssh.options(for: "example.org")#expect(wanted.allSatisfy { after[$0.key] == $0.value }, "\(setting)")}@@ -61,11 +61,28 @@ struct SSHFileTests {@Test func whatTheConfigSetsForAServerEarlierStaysFirst() async throws {let ssh = try SSHHome(before: ["Host server", " ServerAliveInterval 10"])- #expect(SSHFile.write([.keepAlive], to: ssh.peelFile))+ #expect(SSHFile.write([.keepAlive], to: ssh.peelFile) == nil)#expect(try await ssh.options(for: "server")["serveraliveinterval"] == "10")#expect(try await ssh.options(for: "example.org")["serveraliveinterval"] == "60")}+ @Test(.permissionsHold) func saysWhyItsFileCouldNotBeReadOrSaved() throws {+ let directory = try TemporaryDirectory()+ let folder = try directory.directory("Terminal")+ let closed = try directory.file("Terminal/ssh_config", contents: Data("x".utf8))+ try directory.setPermissions(0o000, of: "Terminal/ssh_config")+ defer { try? directory.setPermissions(0o644, of: "Terminal/ssh_config") }++ #expect(SSHFile.read(closed) == nil)+ #expect(SSHFile.whyUnreadable(closed) == .failed(SystemError(domain: NSPOSIXErrorDomain, code: Int(EACCES))))+ #expect(SSHFile.whyUnreadable(folder.appending(path: "missing")) == nil)++ try directory.setPermissions(0o500, of: folder)+ defer { try? directory.setPermissions(0o755, of: folder) }+ let refusedWrite = SystemError(domain: NSCocoaErrorDomain, code: NSFileWriteNoPermissionError)+ #expect(SSHFile.write([], to: folder.appending(path: "ssh_config 2")) == .failed(refusedWrite))+ }+@Test func theSSHOnThisMacAcceptsEverySetting() async {#expect(await SSHFile.accepted() == Set(SSHSetting.allCases))}diff --git a/Packages/PeelCore/Tests/PeelCoreTests/ShellFileTests.swift b/Packages/PeelCore/Tests/PeelCoreTests/ShellFileTests.swiftindex 32e3b265..06f2ec29 100644--- a/Packages/PeelCore/Tests/PeelCoreTests/ShellFileTests.swift+++ b/Packages/PeelCore/Tests/PeelCoreTests/ShellFileTests.swift@@ -32,23 +32,23 @@ struct ShellFileTests {#expect(Set(Self.inEffect.keys) == Set(ShellSetting.allCases))for setting in ShellSetting.allCases {let check = try #require(Self.inEffect[setting])- #expect(ShellFile.write(.init(), to: shell.peelFile))+ #expect(ShellFile.write(.init(), to: shell.peelFile) == nil)#expect(try shell.answers(check) == false, "\(setting)")- #expect(ShellFile.write(.init(settings: [setting]), to: shell.peelFile))+ #expect(ShellFile.write(.init(settings: [setting]), to: shell.peelFile) == nil)#expect(try shell.answers(check) == true, "\(setting)")}}@Test func everySettingAtOnceIsInEffectWithoutAnError() throws {let shell = try ZshHome()- #expect(ShellFile.write(.init(settings: Set(ShellSetting.allCases)), to: shell.peelFile))+ #expect(ShellFile.write(.init(settings: Set(ShellSetting.allCases)), to: shell.peelFile) == nil)let all = ShellSetting.allCases.compactMap { Self.inEffect[$0] }.map { "{ \($0) }" }.joined(separator: " && ")#expect(try shell.answers(all))}@Test func upAndDownFindTheCommandsThatStartWithWhatWasTyped() throws {let shell = try ZshHome(thenRun: ["PS1='ready> '"])- #expect(ShellFile.write(.init(settings: [.prefixSearch]), to: shell.peelFile))+ #expect(ShellFile.write(.init(settings: [.prefixSearch]), to: shell.peelFile) == nil)for up in ["\u{1B}[A", "\u{1B}OA"] {try "echo alpha\necho beta\n".write(to: shell.home.appending(path: ".zsh_history"), atomically: true, encoding: .utf8)let terminal = try PseudoTerminal()@@ -75,6 +75,23 @@ struct ShellFileTests {}}+ @Test(.permissionsHold) func saysWhyItsFileCouldNotBeReadOrSaved() throws {+ let directory = try TemporaryDirectory()+ let folder = try directory.directory("Terminal")+ let closed = try directory.file("Terminal/zshrc", contents: Data("x".utf8))+ try directory.setPermissions(0o000, of: "Terminal/zshrc")+ defer { try? directory.setPermissions(0o644, of: "Terminal/zshrc") }++ #expect(ShellFile.read(closed) == nil)+ #expect(ShellFile.whyUnreadable(closed) == .failed(SystemError(domain: NSPOSIXErrorDomain, code: Int(EACCES))))+ #expect(ShellFile.whyUnreadable(folder.appending(path: "missing")) == nil)++ try directory.setPermissions(0o500, of: folder)+ defer { try? directory.setPermissions(0o755, of: folder) }+ let refusedWrite = SystemError(domain: NSCocoaErrorDomain, code: NSFileWriteNoPermissionError)+ #expect(ShellFile.write(.init(), to: folder.appending(path: "zshrc 2")) == .failed(refusedWrite))+ }+@Test func theFileReadsBackAsTheChoicesWrittenInIt() {for setting in ShellSetting.allCases {let choices = ShellFile.Choices(settings: [setting])@@ -102,7 +119,7 @@ struct ShellFileTests {try FileManager.default.createDirectory(at: file.deletingLastPathComponent(), withIntermediateDirectories: true)try "theirs\n".write(to: theirs, atomically: true, encoding: .utf8)try FileManager.default.createSymbolicLink(at: file, withDestinationURL: theirs)- #expect(ShellFile.write(.init(settings: [.comments]), to: file))+ #expect(ShellFile.write(.init(settings: [.comments]), to: file) == nil)#expect(try String(contentsOf: theirs, encoding: .utf8) == "theirs\n")#expect(try file.resourceValues(forKeys: [.isSymbolicLinkKey]).isSymbolicLink == false)#expect(ShellFile.read(file) == .init(settings: [.comments]))@@ -196,7 +213,7 @@ struct PeelLinesCommandTests {let home = directory.urllet file = ShellFile.url(in: home.appending(path: "Library/Application Support/Peel", directoryHint: .isDirectory))let zshrc = home.appending(path: ".zshrc")- #expect(ShellFile.write(.init(settings: [.autoCD]), to: file))+ #expect(ShellFile.write(.init(settings: [.autoCD]), to: file) == nil)try Data("export PEEL_PROBE=1".utf8).write(to: zshrc)let line = ShellFile.line(sourcing: file, home: home)#expect(try await run(ShellFile.command(adding: line, to: zshrc, home: home), home: home) == 0)diff --git a/Peel/Model/SSHLibrary.swift b/Peel/Model/SSHLibrary.swiftindex 1bd07785..1e9157e6 100644--- a/Peel/Model/SSHLibrary.swift+++ b/Peel/Model/SSHLibrary.swift@@ -6,6 +6,8 @@ import PeelCorefinal class SSHLibrary {struct State: Equatable {var settings: Set<SSHSetting>?+ /// Why Peel's file can't be read, while `settings` is nil, when Peel knows.+ var whyUnreadable: FileProblem?var isIncluded: Bool/// What the ssh on this Mac accepts, nil while it has not answered.var accepted: Set<SSHSetting>?@@ -15,7 +17,8 @@ final class SSHLibrary {let config: URLprivate let home: URLprivate(set) var state: State?- private(set) var wasRefused = false+ /// Why Peel's file couldn't be saved, until the page forgets it.+ private(set) var whyRefused: FileProblem?init(folder: URL = PeelFolder.url, home: URL = .homeDirectory) {file = SSHFile.url(in: folder)@@ -35,8 +38,10 @@ final class SSHLibrary {let accepted = if let accepted = state?.accepted { accepted } else { await SSHFile.accepted() }// A reading stopped because the page went away got no answer from ssh, which isn't ssh not answering.guard !Task.isCancelled else { return }+ let settings = SSHFile.read(file)state = State(- settings: SSHFile.read(file),+ settings: settings,+ whyUnreadable: settings == nil ? SSHFile.whyUnreadable(file) : nil,isIncluded: SSHFile.isIncluded(file, from: config, home: home),accepted: accepted)@@ -64,11 +69,13 @@ final class SSHLibrary {}func forgetRefusal() {- wasRefused = false+ whyRefused = nil}private func write(_ settings: Set<SSHSetting>) {- wasRefused = !SSHFile.write(settings, to: file)- state?.settings = SSHFile.read(file)+ whyRefused = SSHFile.write(settings, to: file)+ let written = SSHFile.read(file)+ state?.settings = written+ state?.whyUnreadable = written == nil ? SSHFile.whyUnreadable(file) : nil}}diff --git a/Peel/Model/ShellLibrary.swift b/Peel/Model/ShellLibrary.swiftindex 62ef032d..370869e5 100644--- a/Peel/Model/ShellLibrary.swift+++ b/Peel/Model/ShellLibrary.swift@@ -8,6 +8,8 @@ final class ShellLibrary {var shell: ShellSessions?var startupFile: URL?var choices: ShellFile.Choices?+ /// Why Peel's file can't be read, while `choices` is nil, when Peel knows.+ var whyUnreadable: FileProblem?var isSourced: Boolvar setsItsOwnPrompt: Bool/// What zsh answered when asked which prompt it shows, asked only while Peel's prompt is on and its line read.@@ -19,7 +21,8 @@ final class ShellLibrary {private let home: URLprivate let terminal: any TerminalSettingsStoringprivate(set) var state: State?- private(set) var wasRefused = false+ /// Why Peel's file couldn't be saved, until the page forgets it.+ private(set) var whyRefused: FileProblem?private(set) var draft = Prompt()init(@@ -61,6 +64,7 @@ final class ShellLibrary {shell: shell,startupFile: startupFile,choices: choices,+ whyUnreadable: choices == nil ? ShellFile.whyUnreadable(file) : nil,isSourced: isSourced,setsItsOwnPrompt: startupFile.map { ShellFile.setsItsOwnPrompt(after: file, in: $0, home: home) } ?? false,shownPrompt: shownPrompt,@@ -107,11 +111,13 @@ final class ShellLibrary {}func forgetRefusal() {- wasRefused = false+ whyRefused = nil}private func write(_ choices: ShellFile.Choices) {- wasRefused = !ShellFile.write(choices, to: file)- state?.choices = ShellFile.read(file)+ whyRefused = ShellFile.write(choices, to: file)+ let written = ShellFile.read(file)+ state?.choices = written+ state?.whyUnreadable = written == nil ? ShellFile.whyUnreadable(file) : nil}}diff --git a/Peel/Views/Presentation.swift b/Peel/Views/Presentation.swiftindex 30ee7784..a132dc4e 100644--- a/Peel/Views/Presentation.swift+++ b/Peel/Views/Presentation.swift@@ -284,6 +284,18 @@ extension FileProblem? {func said(after sentence: String, about url: URL) -> String {self?.said(after: sentence, about: url) ?? sentence}++ /// What the Shell and SSH tabs say when Peel's own settings file at `url` can't be read.+ func peelsSettingsUnreadable(at url: URL) -> String {+ said(after: String(localized: "Peel’s settings file couldn’t be read."), about: url)+ }+}++extension FileProblem {+ /// What the Shell and SSH tabs say when Peel's own settings file at `url` couldn't be saved.+ func peelsSettingsNotSaved(at url: URL) -> String {+ said(after: String(localized: "Peel couldn’t save its settings file."), about: url)+ }}extension AppLibrary {diff --git a/Peel/Views/Terminal/SSHTab.swift b/Peel/Views/Terminal/SSHTab.swiftindex 839deac6..66032015 100644--- a/Peel/Views/Terminal/SSHTab.swift+++ b/Peel/Views/Terminal/SSHTab.swift@@ -11,12 +11,15 @@ struct SSHTab: View {Section {SSHLinesRow(isIncluded: state.isIncluded)} footer: {- if ssh.wasRefused {- StatusLabel(title: Text("macOS refused it"), tint: .accentColor)+ if let why = ssh.whyRefused {+ StatusLabel(title: Text(verbatim: why.peelsSettingsNotSaved(at: ssh.file)), tint: .accentColor).font(.caption).foregroundStyle(.secondary)} else if state.settings == nil {- StatusLabel(title: Text("Peel’s settings file couldn’t be read"), tint: .accentColor)+ StatusLabel(+ title: Text(verbatim: state.whyUnreadable.peelsSettingsUnreadable(at: ssh.file)),+ tint: .accentColor+ ).font(.caption).foregroundStyle(.secondary)} else if state.accepted == nil {diff --git a/Peel/Views/Terminal/ShellTab.swift b/Peel/Views/Terminal/ShellTab.swiftindex 4c8f8ce6..5abaccd4 100644--- a/Peel/Views/Terminal/ShellTab.swift+++ b/Peel/Views/Terminal/ShellTab.swift@@ -11,12 +11,17 @@ struct ShellTab: View {Section {ShellLineRow(state: state)} footer: {- if shell.wasRefused {- StatusLabel(title: Text("macOS refused it"), tint: .accentColor)+ if let why = shell.whyRefused {+ StatusLabel(+ title: Text(verbatim: why.peelsSettingsNotSaved(at: shell.file)), tint: .accentColor+ ).font(.caption).foregroundStyle(.secondary)} else if state.startupFile != nil, state.choices == nil {- StatusLabel(title: Text("Peel’s settings file couldn’t be read"), tint: .accentColor)+ StatusLabel(+ title: Text(verbatim: state.whyUnreadable.peelsSettingsUnreadable(at: shell.file)),+ tint: .accentColor+ ).font(.caption).foregroundStyle(.secondary)} else if state.startupFile != nil, state.known == nil {