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.

Write the tools' Homebrew paths with one slash between names

Țugui Dragoș6cee24bd6d80
diff --git a/Packages/PeelCore/Sources/PeelCore/Terminal/TerminalTool.swift b/Packages/PeelCore/Sources/PeelCore/Terminal/TerminalTool.swift
index 51bd06cc..0a0aa5f7 100644
--- a/Packages/PeelCore/Sources/PeelCore/Terminal/TerminalTool.swift
+++ b/Packages/PeelCore/Sources/PeelCore/Terminal/TerminalTool.swift
@@ -102,16 +102,16 @@ public enum TerminalTool: CaseIterable, Sendable {
}
public func setup(prefix: URL) -> [Setup] {
- let prefix = prefix.path(percentEncoded: false)
+ let path = { (below: String) in prefix.appending(path: below).path(percentEncoded: false) }
return switch self {
- case .zshCompletions: [Setup(place: .zshrc, lines: ["FPATH=\"\(prefix)/share/zsh-completions:$FPATH\"", "autoload -Uz compinit && compinit"])]
- case .fzfTab: [Setup(place: .zshrc, lines: ["source \"\(prefix)/opt/fzf-tab/share/fzf-tab/fzf-tab.zsh\"", "zstyle ':completion:*' menu no"])]
+ case .zshCompletions: [Setup(place: .zshrc, lines: ["FPATH=\"\(path("share/zsh-completions")):$FPATH\"", "autoload -Uz compinit && compinit"])]
+ case .fzfTab: [Setup(place: .zshrc, lines: ["source \"\(path("opt/fzf-tab/share/fzf-tab/fzf-tab.zsh"))\"", "zstyle ':completion:*' menu no"])]
case .zoxide: [Setup(place: .zshrc, lines: ["eval \"$(zoxide init zsh)\""])]
case .fzf: [Setup(place: .zshrc, lines: ["source <(fzf --zsh)", "export FZF_DEFAULT_OPTS=\"$FZF_DEFAULT_OPTS --color=16\""])]
case .direnv: [Setup(place: .zshrc, lines: ["eval \"$(direnv hook zsh)\""])]
- case .zshAutosuggestions: [Setup(place: .zshrc, lines: ["source \"\(prefix)/share/zsh-autosuggestions/zsh-autosuggestions.zsh\""])]
+ case .zshAutosuggestions: [Setup(place: .zshrc, lines: ["source \"\(path("share/zsh-autosuggestions/zsh-autosuggestions.zsh"))\""])]
case .zshSyntaxHighlighting:
- [Setup(place: .lastLineOfZshrc, lines: ["source \"\(prefix)/share/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh\""])]
+ [Setup(place: .lastLineOfZshrc, lines: ["source \"\(path("share/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh"))\""])]
case .delta:
[Setup(place: .terminal, lines: [
"git config --global core.pager delta",
diff --git a/Packages/PeelCore/Tests/PeelCoreTests/TerminalToolTests.swift b/Packages/PeelCore/Tests/PeelCoreTests/TerminalToolTests.swift
index 41ff0811..2f55bfb0 100644
--- a/Packages/PeelCore/Tests/PeelCoreTests/TerminalToolTests.swift
+++ b/Packages/PeelCore/Tests/PeelCoreTests/TerminalToolTests.swift
@@ -6,6 +6,15 @@ import Testing
struct TerminalToolTests {
static let prefix = URL(filePath: "/opt/homebrew", directoryHint: .isDirectory)
+ @Test func aPrefixEndingInASlashGivesPathsWithOneSlashBetweenNames() {
+ let prefix = URL(filePath: "/opt/homebrew/", directoryHint: .isDirectory)
+ let lines = TerminalTool.allCases.flatMap { $0.setup(prefix: prefix) }.flatMap(\.lines)
+ #expect(lines.contains { $0.contains("/opt/homebrew/share/zsh-completions") })
+ for line in lines {
+ #expect(!line.replacing("://", with: "").contains("//"), "\(line)")
+ }
+ }
+
@Test func everyLineForZshrcIsZshThatParses() async throws {
for tool in TerminalTool.allCases {
for setup in tool.setup(prefix: Self.prefix) where setup.place != .terminal {