---
slug: "pi-arabic-rtl"
source_type: "readme"
source_url: "https://cdn.jsdelivr.net/gh/beingmomen/pi-arabic-rtl@main/README.md"
repo: "https://github.com/beingmomen/pi-arabic-rtl"
source_file: "README.md"
branch: "main"
---
# pi-arabic-rtl

Arabic / RTL rendering support for [Pi](https://pi.dev) TUI on terminals that do not fully handle BiDi text.

## What it does

- Arabic paragraphs are rendered right-to-left.
- English words inside Arabic text keep their correct letter order.
- Arabic words inside English text keep their correct letter order.
- Mixed punctuation behaves correctly.

This is implemented as a small patch to the built-in `@earendil-works/pi-tui` output layer.

## Install

```bash
pi install npm:pi-arabic-rtl
```

The extension runs at Pi startup and applies the patch automatically. After the first install, restart Pi once so the patched files are loaded.

## Manual fix

If you want to re-apply the patch without restarting Pi, run:

```bash
npx pi-arabic-rtl
```

or, after a global install:

```bash
pi-arabic-rtl
```

## Why this package exists

Some terminals render Arabic letters correctly but do not reorder RTL / LTR mixed sentences correctly inside terminal UIs. This package applies a small fallback to Pi's TUI output layer so the chat, editor, and chat history remain readable.

The long-term goal is to upstream this behavior to Pi / `@earendil-works/pi-tui` and stop needing this package.

## When the patch needs to be re-applied

The patch is idempotent: re-running it on an already patched file is a no-op. If Pi is updated, the TUI files may be replaced, so the extension will re-apply the patch on the next startup.

## Compatibility

- Pi (current).
- Any terminal that renders Arabic glyphs. Bidirectional shaping is not required.
- Node `>=20`.

## Files

```
.
├── LICENSE
├── README.md
├── package.json
├── extensions
│   └── arabic-rtl.ts
├── bin
│   └── pi-arabic-rtl.cjs
└── lib
    └── patch.cjs
```

## License

MIT.
