Standard escape codes are prefixed with Escape:
- Ctrl-Key: ^[
- Octal: \033
- Unicode: \u001b
- Hexadecimal: \x1B
- Decimal: 27
| #!/bin/sh | |
| # Download script written by Wowfunhappy. Last updated 2025/06/15. | |
| # Thank you to Krackers, Jazzzny, and others for helping analyze Apple's download process and debug this script. | |
| # Thank you to dosdude1 for donating identifiers from a broken Mac. | |
| # Any mistakes are mine alone. | |
| # Helper functions | 
| // This playground shows you a few different ways to get device info via IOKit. | |
| // If you want to explore IOKit and look for interesting data I would download | |
| // the Additional Developer Tools from Apple and use the IORegistryExplorer app. | |
| // It makes it super easy to poke around in the IOKit planes. | |
| import IOKit | |
| import Foundation | |
| // For convient access we can make a computed getter for the PlatformExpert. | |
| // Traditionally this has been where you go to find all sorts of data about the | 
| import UIKit | |
| extension UIResponder { | |
| private weak static var _currentFirstResponder: UIResponder? = nil | |
| public static var current: UIResponder? { | |
| UIResponder._currentFirstResponder = nil | |
| UIApplication.shared.sendAction(#selector(findFirstResponder(sender:)), to: nil, from: nil, for: nil) | |
| return UIResponder._currentFirstResponder | |
| } | 
| /// Wait for async operation to return value and call callback with the value | |
| /// This class is intended to workaround/simplify async/await + actors isolation | |
| /// https://twitter.com/krzyzanowskim/status/1523233140914876416 | |
| private class AsyncWaiter<T> { | |
| var didReceiveValue: Bool = false | |
| let value: (T) -> Void | |
| let operation: () async throws -> T | |
| init(_ value: @escaping (T) -> Void, operation: @escaping () async throws -> T) { | |
| self.value = value | 
| /// MIT License | |
| /// | |
| /// Copyright (c) 2021 Lukas Kubanek, Structured Path GmbH | |
| /// | |
| /// Permission is hereby granted, free of charge, to any person obtaining a copy | |
| /// of this software and associated documentation files (the "Software"), to deal | |
| /// in the Software without restriction, including without limitation the rights | |
| /// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | |
| /// copies of the Software, and to permit persons to whom the Software is | |
| /// furnished to do so, subject to the following conditions: | 
| require "formula" | |
| require_relative "lib/private_strategy" | |
| class Hoge < Formula | |
| homepage "https://github.com/yourcompany/hoge" | |
| url "https://github.com/yourcompany/hoge/releases/download/v0.1.0/hoge_v0.1.0_darwin_amd64.tar.gz", :using => GitHubPrivateRepositoryReleaseDownloadStrategy | |
| sha256 "6de411ff3e4b1658a413dd6181fcXXXXXXXXXXXXXXXXXXXX" | |
| head "https://github.com/yourcompany/hoge.git" | |
| version "0.1.0" | 
| // Requirements: a NSLocationWhenInUseUsageDescription entry in Info.plist | |
| // Usage: @State var locator = CLLocationManager.publishLocation() | |
| // and | |
| // .onReceive(locator) { location in | |
| // Improvements needed: Move requestWhenInUseAuthorization into its own publisher and perhaps have a combineLatest pipeline for both authorized and valid location. | |
| // A configuration param to init(), e.g. so each manager can have the same distanceFilter. | |
| import Foundation | |
| import Combine | |
| import CoreLocation | 
| // Copyright (c) 2019–25 Adam Sharp and thoughtbot, inc. | |
| // | |
| // Permission is hereby granted, free of charge, to any person obtaining a copy | |
| // of this software and associated documentation files (the "Software"), to deal | |
| // in the Software without restriction, including without limitation the rights | |
| // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | |
| // copies of the Software, and to permit persons to whom the Software is | |
| // furnished to do so, subject to the following conditions: | |
| // | |
| // The above copyright notice and this permission notice shall be included in | 
| /* | |
| ====================================================== | |
| THIS CODE IS FOR EDUCATIONAL PURPOSES ONLY. | |
| I'M NOT RESPONSIBLE IF YOU SHIP THIS AND IT BLOWS UP IN YOUR FACE. | |
| IF IT DOES AND YOU COMPLAIN TO ME I WILL LAUGH AT YOU. |