首页›Julia Evans›文章

"Rules" that terminal programs follow

Julia Evans · 2024年12月12日

AI 摘要 AI 生成,可能有误

这篇文章描述了一套终端程序倾向于遵循的非成文的、描述性的“规则”,尽管这些行为并没有正式的标准,例如:Ctrl-C 退出非交互式程序、按 q 键退出 TUI、Ctrl-D 退出 REPL、坚持使用 16 种 ANSI 颜色、模仿 readline 的按键绑定(如 Ctrl-W 删除上一个单词)、当输出到管道时禁用颜色,以及使用 '-' 表示 stdin/stdout。作者解释说,这些约定中的很多并非自然法则,而是由每个程序显式实现的,通常是模仿操作系统在熟模式(cooked mode)下的默认行为。学习这些规则花费了多年的潜意识模式识别,而把它们写下来的目的是帮助他人理解对终端程序应当期待什么样的行为,并更容易地对例外情况进行归类。

Recently I’ve been thinking about how everything that happens in the terminal is some combination of:

  • Your operating system’s job
  • Your shell’s job
  • 继续阅读全文

    为了尊重作者,这里只展示开头几段。你可以去原文阅读,或者在 HorizonReader 里读:划线做笔记、让 AI 帮忙。

    更多来自 Julia Evans

    Replacing the old battery on rechargeable bike lights

    AI 摘要The author repaired their decade-old rechargeable bike lights, which only held a charge for about 5 minutes, by replacing the lithium coin cell batteries (identified as LIR2477 with the help of an LLM). Following a desoldering guide and friends' advice, they removed the old batteries at a local queer makerspace, ordered replacements and silicone glue from AliExpress, soldered in the new batteries, and glued the lights back together. The repair succeeded—the lights now work for nighttime biking—and cost about $20 CAD total, which the author found rewarding despite having minimal electronics experience.

    Some more things about Django I've been enjoying

    AI 摘要The author describes learning to build backend-rendered websites with Django in a '2010 style' after years of frontend-heavy approaches, and highlights features they enjoy like query builders, template filters (especially `querystring`), and automatic database migrations. They dislike organizing views with inheritance, preferring function-based code instead, and are still figuring out how to reason about Django performance—notably discovering they had accidentally disabled the cached template loader, whose re-enablement significantly improved the site's request throughput.

    Learning a few things about running SQLite

    AI 摘要The author shares lessons learned from using SQLite as the database for a Django site, including how running ANALYZE dramatically sped up a slow full-text search query and how long-running cleanup DELETEs can cause other workers to time out and crash since SQLite allows only one writer at a time. They also describe their backup approaches using restic and Litestream, along with tricks like splitting tables across multiple database files. Despite these challenges, they find SQLite works well for small sites, though the experience has given them more appreciation for databases like Postgres.

    Moving away from Tailwind, and learning to structure my CSS

    AI 摘要The author describes migrating several of their small sites from Tailwind CSS to semantic HTML with vanilla CSS, explaining how Tailwind had taught them useful systems (resets, color palettes, font scales, utility classes) that they adapted while restructuring their CSS around components, base styles, spacing conventions, flexible grid layouts, and esbuild. They cite reasons for leaving Tailwind, including its growing reliance on build systems, their own improved CSS skills, Tailwind's limitations for unusual designs, and the pain of maintaining mixed codebases. Finally, they reflect on learning to respect CSS as a genuinely hard and powerful technology rather than devaluing it, and mention modern features like @layer, @scope, container queries, and subgrid that they hope to explore.

    Links to CSS colour palettes

    AI 摘要After deciding to stop using Tailwind CSS for new projects, the author missed its convenient color palette and asked on Mastodon for alternatives. This post compiles links to their favorite palettes (such as uchū, flexoki, and reasonable colours) as well as other palettes, color palette generators, and color tools like colorhexa and oklch resources.