{"id":919,"url":"https://github.com/mtynior/ColorizeSwift","last_synced_at":"2025-07-30T20:30:39.154Z","repository":{"id":54860376,"uuid":"55212293","full_name":"mtynior/ColorizeSwift","owner":"mtynior","description":"Terminal string styling for Swift.","archived":false,"fork":false,"pushed_at":"2024-09-25T05:33:14.000Z","size":541,"stargazers_count":307,"open_issues_count":0,"forks_count":20,"subscribers_count":6,"default_branch":"master","last_synced_at":"2025-07-13T15:31:15.899Z","etag":null,"topics":["ansi","ansi-escape-codes","color","colorization","colorize","console","spm","swift","swiftpackage","swiftpackagemanager","terminal","xcode"],"latest_commit_sha":null,"homepage":"","language":"Swift","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mtynior.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2016-04-01T07:25:09.000Z","updated_at":"2025-07-04T07:42:29.000Z","dependencies_parsed_at":"2024-12-08T17:31:29.170Z","dependency_job_id":null,"html_url":"https://github.com/mtynior/ColorizeSwift","commit_stats":{"total_commits":47,"total_committers":11,"mean_commits":"4.2727272727272725","dds":0.8085106382978724,"last_synced_commit":"50b6a313b6b3aa66813c4a3ebf1d4537035e9e3b"},"previous_names":[],"tags_count":9,"template":false,"template_full_name":null,"purl":"pkg:github/mtynior/ColorizeSwift","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mtynior%2FColorizeSwift","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mtynior%2FColorizeSwift/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mtynior%2FColorizeSwift/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mtynior%2FColorizeSwift/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mtynior","download_url":"https://codeload.github.com/mtynior/ColorizeSwift/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mtynior%2FColorizeSwift/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":267935120,"owners_count":24168265,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-07-30T02:00:09.044Z","response_time":70,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ansi","ansi-escape-codes","color","colorization","colorize","console","spm","swift","swiftpackage","swiftpackagemanager","terminal","xcode"],"created_at":"2024-01-05T20:15:34.645Z","updated_at":"2025-07-30T20:30:38.682Z","avatar_url":"https://github.com/mtynior.png","language":"Swift","funding_links":[],"categories":["Command Line","Swift"],"sub_categories":["Linter","Other free courses"],"readme":"![ColorizeSwift](Assets/logo.png)\n\n[![Swift](https://img.shields.io/badge/language-Swift-orange.svg?style=flat)](https://developer.apple.com/swift/)\n[![License](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/mtynior/ColorizeSwift/blob/master/LICENSE.md) \n\nTerminal string styling for Swift.\n\n## Integration\n\n#### Swift Package Manager (SPM)\nYou can use The [Swift Package Manager](https://swift.org/package-manager/) to install ColorizeSwift by adding it to your Package.swift file:\n\n```swift\n// swift-tools-version:4.0\n// The swift-tools-version declares the minimum version of Swift required to build this package.\n\nimport PackageDescription\n\nlet package = Package(\n    name: \"MyLibrary\",\n    products: [\n        .library(name: \"MyLibrary\", targets: [\"MyLibrary\"]),\n    ],\n    dependencies: [\n         .package(url: \"https://github.com/mtynior/ColorizeSwift.git\", from: \"1.5.0\"),\n    ],\n    targets: [\n        .target(name: \"MyLibrary\", dependencies: [\"ColorizeSwift\"]),\n        .testTarget(name: \"MyLibraryTests\", dependencies: [\"MyLibrary\", \"ColorizeSwift\"]),\n    ]\n)\n```\n\n#### Manually\nYou can also manually add ColorizeSwift to you project:\n\n1. Download `ColorizeSwift.swift` file,\n2. Drag `ColorizeSwift.swift` into you project's tree.\n\n\n#### CocoaPods\n\n#### From version `1.5` CocoaPods is no longer supported!\nPlease use SPM or add `ColorizeSwift.swift` file  manually to your project. \nIf you use CocoaPods, you can still use version `1.2`, but it does not have any updates like support for Swift 6 strict concurrency! \n\nYou can install `ColorizeSwift 1.2` by adding it to your `Podfile`:\n\n```ruby\nplatform :ios, '9.0'\nuse_frameworks!\n\ntarget 'MyApp' do\n\tpod 'ColorizeSwift'\nend\n```\nRun `pods install` to integrate pods with your project.\n\n\n## Example\nYou can run sample application:\n\n1. Open Terminal and go to `Example` folder.\n2. Run `./build.sh` script to build sample application.\n3. Run `./example pacman` to launch sample.\n\nAvailable samples:\n\n1. `styles` - prints available styles \n\n\t![Example - Styles](Assets/styles.png)\n\n2. `f1` - prints F1 cars\n\n\t![Example - F1](Assets/f1.png)\n\t\n3. `pacman` - prints Pacman\n\n\t![Example - Pacman](Assets/pacman.png)\n\n4. `mario` - prints Mario\n\n\t![Example - Mario](Assets/mario.png)\n\n## Usage\n```swift\nprint(\"Normal\")\nprint(\"Bold\".bold())\nprint(\"Dim\".dim())\nprint(\"Italic\".italic())\nprint(\"Underline\".underline())\nprint(\"Blink\".blink())\nprint(\"Reverse\".reverse())\nprint(\"hidden\".hidden())\nprint(\"strikethrough\".strikethrough())\nprint(\"Red\".red())\nprint(\"On yellow\".onYellow())\nprint(\"256 foreground\".foregroundColor(.orange1))\nprint(\"226 background\".backgroundColor(.orange1))\nprint(\"Awful combination\".colorize(.yellow, background: .red))\n    \nlet nested = \"with a blue substring\".blue().underline()\nprint(\"A bold, green line \\(nested) that becomes bold and green again\".green().bold())\n```\n\n## Styles\n\n### Modifiers\n\n- `bold()`\n- `dim()`\n- `italic()` *(not widely supported)*\n- `underline()`\n- `reverse()`\n- `hidden()`\n- `strikethrough()` *(not widely supported)*\n- `reset()`\n\n### Foreground colors\n\n- `black()`\n- `red()`\n- `green()`\n- `yellow()`\n- `blue()`\n- `magenta()`\n- `cyan()`\n- `lightGray()`\n- `darkGray()`\n- `lightRed()`\n- `lightGreen()`\n- `lightYellow()`\n- `lightBlue()`\n- `lightMagenta()`\n- `lightCyan()`\n- `white()`\n\n### Background colors\n\n- `onBlack()`\n- `onRed()`\n- `onGreen()`\n- `onYellow()`\n- `onBlue()`\n- `onMagenta()`\n- `onCyan()`\n- `onLightGray()`\n- `onDarkGray()`\n- `onLightRed()`\n- `onLightGreen()`\n- `onLightYellow()`\n- `onLightBlue()`\n- `onLightMagenta()`\n- `onLightCyan()`\n- `onWhite()`\n\n\n## 256-colors\nYou can also use 256 colors, but keep in mind that not all Terminal clients support them.\n\n- `foregroundColor(color: TerminalColor)`\n- `backgroundColor(color: TerminalColor)`\n- `colorize(foreground: TerminalColor, background: TerminalColor)`\n\n#### Available colors\n\nYou can access 256 colors using `TerminalColor` enumeration.\n\n![256 Colors](Assets/256Colors.png)\n\n## Escape codes\nSometimes you only need the `open code` for a modifier. You can access them using `TerminalStyle` enum:\n\n```swift\nTerminalStyle.bold.open // \"\\u{001B}[1m\"\nTerminalStyle.bold.close  // \"\\u{001B}[22m\"\n```\n\nFor 256 colors use:\n\n```swift\nTerminalColor.red.foregroundStyleCode().open //\"\\u{001B}[38;5;9m\"\nTerminalColor.red.backgroundStyleCode().open //\"\\u{001B}[48;5;9m\"\n```\n\n## Uncolorize\n\nTo get string without any colorization use `uncolorized()` method:\n```swift\nlet styledString = \"Awful combination\".colorize(.yellow, background: .red) // \\u{001B}[48;5;9m\\u{001B}[38;5;11mAwful combination\\u{001B}[0m\\u{001B}[48;5;9m\\u{001B}[0m\nlet withoutStyles = styledString.uncolorized() // \"Awful combination\"\n```\n\n## Disabling colorization\n\nColorization can be disabled globally:\n\n```swift\nString.isColorizationEnabled = false // Default: true\n```\n\nYou can use this to support a command line option (`./example --no-color`):\n```swift\nString.isColorizationEnabled = !CommandLine.arguments.contains(\"--no-color\")\n```\nTo disable colorization when program is running in a pipe (`./example | wc`) or when not writing to `stdout` (`./example \u003e output.txt`):\n```swift\nString.isColorizationEnabled = (isatty(fileno(stdout)) == 1)\n```\n\n\n## Credits\n\n- [Mike Smiley](https://github.com/msmiley)\n- [Theo Lubert](https://github.com/theo-lubert) \n- [Noah Bass](https://github.com/noahbass)\n- [Hristo Staykov](https://github.com/hristost)\n\n## License\n\nColorizeSwift is released under the MIT license. See LICENSE for details.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmtynior%2FColorizeSwift","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmtynior%2FColorizeSwift","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmtynior%2FColorizeSwift/lists"}