ansi
ansi
ansi is a Crystal library for generating and parsing ANSI terminal escape sequences. It is a Crystal port of x/ansi (Go) and includes helpers for colors, styles, cursor control, modes, mouse/keyboard protocols, images (Kitty, iTerm2, Sixel), and sequence parsing/decoding utilities.
Installation
-
Add the dependency to your
shard.yml:dependencies: ansi: github: dsisnero/ansi -
Run
shards install
Usage
require "ansi"
Examples:
# Colors and styles
puts Ansi.sgr(Ansi::AttrBold, Ansi::AttrBlueForegroundColor) + "Hello" + Ansi::ResetStyle
# Cursor movement
print Ansi.cursor_up(2)
print Ansi.cursor_forward(10)
# Clipboard
print Ansi.set_system_clipboard("hello")
# Kitty graphics
payload = "...".to_slice
print Ansi.kitty_graphics(payload)
Development
Run specs:
crystal spec
Contributing
- Fork it (https://github.com/dsisnero/ansi/fork)
- Create your feature branch (
git checkout -b my-new-feature) - Commit your changes (
git commit -am 'Add some feature') - Push to the branch (
git push origin my-new-feature) - Create a new Pull Request
Contributors
- your-name-here - creator and maintainer
Repository
ansi
Owner
Statistic
- 0
- 0
- 0
- 5
- 4
- 9 days ago
- February 6, 2026
License
MIT License
Links
Synced at
Mon, 23 Feb 2026 07:18:51 GMT
Languages