TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

ANSI Escape Codes

132 pointsby grafelicalmost 4 years ago

19 comments

rasculalmost 4 years ago
Linux console_codes man page, section 4<p><a href="https:&#x2F;&#x2F;man7.org&#x2F;linux&#x2F;man-pages&#x2F;man4&#x2F;console_codes.4.html" rel="nofollow">https:&#x2F;&#x2F;man7.org&#x2F;linux&#x2F;man-pages&#x2F;man4&#x2F;console_codes.4.html</a>
评论 #28149005 未加载
grilledcheezalmost 4 years ago
My first paid programming job was making a client for a remote monitoring solution for the water industry. I must have been 14 or 15. One of my father&#x27;s acquaintances knew I had been messing around with programming, and he needed a shiny Windows 95 application for his customers.<p>It would dial the plant via modem, and I remember being given a list of &quot;escape codes&quot; that determined how the stream of bytes should be rendered on the screen. My program parsed (some of) these codes and displayed the text accordingly, I specifically remember implementing the &quot;move cursor&quot; and &quot;reverse mode&quot; codes...<p>Not until years after did I realise I had basically built a shitty terminal emulator using Visual Basic text fields.
blueflowalmost 4 years ago
Take this gist with a grain of salt, many of the things listed there are NOT standardized by ansi, and some are specific to 16-bit real mode terminal emulators on the IBM PC or compatibles. I suspect this gist actually refers to the ANSI.SYS terminal implementation of MS-DOS.<p>If you want to have reliable and accurate information on how to control your terminal, consult the documentation on your terminal emulator or the ncurses database. The ncurses database is vast but does not include most of the exotic features of specific terminals.<p>[tl;dr] dont rely on secondary sources like this, please consult primary documentation instead
评论 #28146706 未加载
评论 #28147487 未加载
评论 #28146215 未加载
评论 #28151513 未加载
allenualmost 4 years ago
Playing around with BBSes as a teen, I&#x27;m super familiar with ANSI codes. I remember being fascinated by how they worked after opening up a .ANS file to see their contents.<p>One of my earliest programming projects was creating my own diary app which used ANSI codes to let you format the text. It also kept track of your cursor movements and encoded them so that you could do neat things like write text anywhere on the screen or overwrite existing text.
评论 #28145887 未加载
评论 #28148791 未加载
评论 #28150615 未加载
评论 #28146361 未加载
michaelsbradleyalmost 4 years ago
For those interested in learning more about terminal emulators and character graphics, checkout Nick Black&#x27;s book <i>Hacking the Planet (with Notcurses): A Guide to TUIs and Character Graphics</i>[1].<p>While the overall focus of the book is on programming with Notcurses[2], the author shares a wealth of related info and history throughout its pages.<p>[1] <a href="https:&#x2F;&#x2F;nick-black.com&#x2F;htp-notcurses.pdf" rel="nofollow">https:&#x2F;&#x2F;nick-black.com&#x2F;htp-notcurses.pdf</a><p>[2] <a href="https:&#x2F;&#x2F;github.com&#x2F;dankamongmen&#x2F;notcurses#readme" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;dankamongmen&#x2F;notcurses#readme</a>
fanf2almost 4 years ago
I generally use xterm&#x27;s ctlseqs.ms as a reference - <a href="https:&#x2F;&#x2F;www.invisible-island.net&#x2F;xterm&#x2F;ctlseqs&#x2F;ctlseqs.html" rel="nofollow">https:&#x2F;&#x2F;www.invisible-island.net&#x2F;xterm&#x2F;ctlseqs&#x2F;ctlseqs.html</a><p>There&#x27;s also Ben Harris&#x27;s concordance of escape sequences <a href="https:&#x2F;&#x2F;bjh21.me.uk&#x2F;all-escapes&#x2F;all-escapes.xhtml" rel="nofollow">https:&#x2F;&#x2F;bjh21.me.uk&#x2F;all-escapes&#x2F;all-escapes.xhtml</a> (Ben is a member of the PuTTY team)
MisterKeefealmost 4 years ago
I&#x27;ve always liked these. It&#x27;s fun to use them directly to jazz up quick CLI scripts without bothering with dependencies etc.<p>A few months ago I put together a kind of interactive cheatsheet for working with them quickly: <a href="http:&#x2F;&#x2F;ansi-escape-artist.surge.sh&#x2F;" rel="nofollow">http:&#x2F;&#x2F;ansi-escape-artist.surge.sh&#x2F;</a>
lsllcalmost 4 years ago
Related: See also this page documenting escape sequences supported by xterm:<p><a href="https:&#x2F;&#x2F;invisible-island.net&#x2F;xterm&#x2F;ctlseqs&#x2F;ctlseqs.html" rel="nofollow">https:&#x2F;&#x2F;invisible-island.net&#x2F;xterm&#x2F;ctlseqs&#x2F;ctlseqs.html</a><p>EDIT: This is actually linked at the bottom of the article.
wombatpmalmost 4 years ago
Ahh the joy of sending a file with a 10k ^G to the line printer. Used to annoy the poor slobs who had the crapy terminals
sillysaurusxalmost 4 years ago
If someone wants to do this in Python, I made a lib for it: pip3 install ansi-escapes<p>It’s a port of sindresorhus’s ansi-escapes library. I find it way more convenient than looking up codes.<p><a href="https:&#x2F;&#x2F;github.com&#x2F;shawwn&#x2F;ansi-escapes-python" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;shawwn&#x2F;ansi-escapes-python</a><p>It has some basic iTerm2 support too, so you can print out annotations in the console. Think of it like sticky notes.<p>See also ansi-styles, the lib that Chalk is based on. (Colors! You like colors? Are you a curmudgeony salt like me that refuses to use Rich for some reason? Use that.)<p>As with ansi-escapes, you can just pip install ansi-styles.<p><a href="https:&#x2F;&#x2F;github.com&#x2F;shawwn&#x2F;ansi-styles-python" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;shawwn&#x2F;ansi-styles-python</a>
评论 #28148445 未加载
评论 #28153460 未加载
omoikanealmost 4 years ago
The 256 color palette was the most useful bit for me: not every terminal supports true color, and many terminals allow users to select color themes for the first 16 colors (e.g. &quot;xterm -reverse&quot;). So the upper 240 of the 256 color palette were the most reliable colors.
评论 #28146973 未加载
oneweekwonderalmost 4 years ago
Something i do way to much is `watch telnet &lt;static-ip&gt; 22` because it will print a Terminal bell and then i know a embedded device with a short ssh&#x2F;dhcp window is up.<p>This is for dropbear ssh have not tested it on openssh, yet.
cyberge99almost 4 years ago
If you use ‘vi’, in insert mode, it’s CTRL-V then tap escape button. Followed by [31m or whatever code.
评论 #28146597 未加载
ChrisArchitectalmost 4 years ago
Related from a few months back:<p>ANSI Escape Artist – webapp for generating terminal escape codes<p><a href="https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=26609452" rel="nofollow">https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=26609452</a>
booleanbetrayalalmost 4 years ago
Back in the day, during the dorm wars, we would all have syslogd writing to terms to keep track on our nefarious neighbors in realtime. Echoing ANSI escape codes strategically was a good way to erase those tracks.
GartzenDeHaesalmost 4 years ago
XTERM docs cover most common terminal codes, including DEC.<p><a href="https:&#x2F;&#x2F;www.xfree86.org&#x2F;current&#x2F;ctlseqs.html" rel="nofollow">https:&#x2F;&#x2F;www.xfree86.org&#x2F;current&#x2F;ctlseqs.html</a>
评论 #28152082 未加载
jacquesmalmost 4 years ago
Does anybody remember ANSI art demos? Some of those were really amazing and ran for minutes.
评论 #28152027 未加载
bruce343434almost 4 years ago
What did the vertical tab use to look like?
评论 #28146507 未加载
评论 #28146163 未加载
评论 #28146149 未加载
ChrisArchitectalmost 4 years ago
this was posted why? considering comments here saying it&#x27;s not reliable information and the number of comments on the gist itself from when it was initially posted months ago saying it needed forks to fix problems and clarify......
评论 #28151061 未加载