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 the checks:
make build
make format
make lint
make test
See docs/development.md for setup, the vendored upstream checkout, and the porting loop.
Docs
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
- 6
- 4
- 3 days ago
- February 6, 2026
License
MIT License
Links
Synced at
Tue, 20 Oct 2026 05:02:55 GMT
Languages