Fix Persian/Arabic/Hebrew (RTL) text in the terminal for AI CLIs like Claude Code
Fix Persian / Arabic / Hebrew text in terminal AI tools (Claude Code and friends).
Mixed right-to-left and English text in a terminal often comes out scrambled: words swap places, English terms jump to the wrong side of the sentence. rtl-tty runs your command inside a pseudo-terminal and tells the terminal which rows are right-to-left, so they are laid out right-to-left with English words staying where they belong.
rtl-tty claude Before / after Real screenshots of Claude Code in GNOME Terminal (the two replies are different texts; both are mixed Persian and English).
Without rtl-tty: rows are laid out left-to-right, so words and English terms end up in the wrong order.
With rtl-tty claude: rows are right-to-left, English terms stay where they belong.
pipx install git+https://github.com/komeilsedaghat-dev/rtl-tty (pipx install rtl-tty will work once the package is published on PyPI.) Requires Python 3.9+ on Linux. No dependencies. Optional alias:
alias claude='rtl-tty claude' Compatibility Terminal / tool Status GNOME Terminal 3.52 (VTE 0.76), Claude Code 2.1 works (tested) Other VTE terminals (Tilix, Terminator, ...) expected to work, untested tmux / screen untested; likely to swallow the escape sequence Kitty, Alacritty, WezTerm, iTerm2, Windows Terminal, VS Code terminal not supported (no bidi layout at all in most of them) Gemini CLI, Codex CLI, aider, opencode untested Reports welcome: run bash experiments/scp_demo.sh in your terminal and open a compatibility report.
Findings on GNOME Terminal / VTE 0.76, all reproducible with experiments/scp_demo.sh (right-aligned rows in the screenshot below are the ones where SCP took effect):
rtl-tty therefore buffers each output row until the cursor leaves it, decides once whether the row contains RTL letters, and inserts ESC 7, CR, SCP, ESC 8 (save cursor, go to column 0, set direction, restore cursor) before the row's first text. Nothing else in the stream is changed.
rtl-tty [--mode scp|off] [--log FILE] COMMAND [ARGS...] --mode off passes output through unchanged (handy for before/after comparisons). --log FILE (or RTL_TTY_LOG) records raw and transformed output for debugging. The log contains everything shown on screen.
rtl-tty متن فارسی (و عربی و عبری) را در ابزارهای هوش مصنوعی داخل ترمینال درست نمایش میدهد؛ مثلاً وقتی با Claude Code فارسی و انگلیسی را قاطی مینویسید و کلمهها جابهجا میشوند.
rtl-tty claude روش کار: ترمینال VTE (مثل GNOME Terminal) دستور مخصوص خودش را برای «این سطر راستبهچپ است» دارد (SCP) و کاراکترهای نامرئی جهتدهنده Unicode را نادیده میگیرد. این برنامه قبل از هر سطر فارسی همان دستور را میفرستد. فعلاً فقط روی GNOME Terminal با Claude Code تست شده است.
rtl bidi persian farsi arabic hebrew terminal pty vte
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 24, 2026.




