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.

Read the Mac's name without a deprecated call

Țugui Dragoșc5a85c50940c
diff --git a/Packages/PeelCore/Sources/PeelCore/Terminal/PromptStyle.swift b/Packages/PeelCore/Sources/PeelCore/Terminal/PromptStyle.swift
index 51b58c8a..2bc4751f 100644
--- a/Packages/PeelCore/Sources/PeelCore/Terminal/PromptStyle.swift
+++ b/Packages/PeelCore/Sources/PeelCore/Terminal/PromptStyle.swift
@@ -58,6 +58,7 @@ public enum PromptStyle: CaseIterable, Sendable {
public static func hostName() -> String {
var name = [CChar](repeating: 0, count: Int(MAXHOSTNAMELEN) + 1)
guard gethostname(&name, name.count - 1) == 0 else { return "" }
- return String(String(cString: name).prefix { $0 != "." })
+ let bytes = name.prefix { $0 != 0 }.map { UInt8(bitPattern: $0) }
+ return String(decoding: bytes.prefix { $0 != UInt8(ascii: ".") }, as: UTF8.self)
}
}