Skip to content
team-miraePublic

About

CLI text editor designed for EN/KO/JA.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

9 Commits

Folders and files

Repository files navigation

zencode · 젠코드 · ゼンコード

A nano-style terminal text editor that handles 全角 (zenkaku / full-width) text properly: 한글, 日本語 and other wide characters take up two columns, and the cursor, scrolling and line clipping all account for that.

Runs on Linux, macOS and Windows. Rendering goes through crossterm.

Install

On Linux or macOS, including over ssh:

curl -fsSL https://raw.githubusercontent.com/team-mirae/zencode/main/install.sh | sh

This installs the latest release into ~/.local/bin, with no sudo needed, and verifies its SHA-256 checksum. To pin a release or pick the directory, set the variables on the sh side of the pipe:

curl -fsSL https://raw.githubusercontent.com/team-mirae/zencode/main/install.sh | ZENCODE_VERSION=v0.1.0 ZENCODE_INSTALL_DIR=/usr/local/bin sh

Windows builds are on the releases page.

From source:

cargo install --git https://github.com/team-mirae/zencode

Usage

zencode path/to/file.txt      # created if it doesn't exist
zencode -s secrets.env        # sandboxed clipboard

For development:

cargo run --release -- path/to/file.txt      # created if it doesn't exist
cargo run --release -- -s secrets.env        # sandboxed clipboard

Running zencode with no file prints the version, since zencode never picks a file name for you.

zencode --help lists every option. The command line follows nano's, so zencode works as $EDITOR / $VISUAL for git, crontab -e, Claude Code (⌃G) and anything else that starts an editor:

zencode +12 notes.txt          # start on line 12
zencode +12,5 notes.txt        # line 12, column 5
zencode +-1 notes.txt          # last line (negatives count from the end)
zencode +/TODO notes.txt       # first match of TODO; +?TODO for the last
zencode +c/Todo notes.txt      # the same, case-sensitive (exact) search
zencode -g notes.txt:12:5      # VS Code's form; notes.txt:12 alone works
                               # too when notes.txt exists
zencode a.txt b.txt            # edit one after the other; ⌃X moves on
some-command | zencode -       # edit text from standard input
zencode -- -odd-name           # everything after -- is a file name

Columns count characters, so 한 is one column here even though it takes two cells on screen. With -g (or nano's -@) a trailing :LINE[:COL] is always read as a position unless a file with the literal name exists. Text read from standard input asks for a file name when you save it.

nano's behaviour options are supported where zencode has the feature:

Option Effect
-v, --view View only; the buffer can't be changed
-t, --saveonexit ⌃X saves changes without asking
-T N, --tabsize=N Tab stops every N columns (default 4)
-E, --tabstospaces Tab inserts spaces up to the next stop
-i, --autoindent Enter keeps the current line's indentation
-L, --nonewlines Don't add a line break at the end of the file
-u, --unix Save with LF line endings
-k, --cutfromcursor ⌃B with no selection cuts to the end of the line
-B, --backup Keep the original as FILE~ on the first save
-C DIR, --backupdir Keep that backup in DIR instead, named after the full path (implies -B)
-n, --noread Start empty and only write the file (named pipes)
-R, --restricted No export (⌃O) and no backups
--nosoftwrap Start with word wrap off (⌃L turns it back on)
-x, --nohelp Hide the shortcut bar
--nomouse Leave the mouse to the terminal

Other nano options are accepted and ignored, together with their arguments, and so are -w / --wait, which some tools add for GUI editors. Two short options differ from nano: -s is --sandboxed (nano's -s sets a spell checker), and -g is VS Code's --goto (nano's is --showcursor). Unknown options print a one-line error to stderr and exit with status 1; a normal exit with ⌃X is always status 0.

On exit zencode puts bracketed paste and cursor visibility back the way it found them (XTSAVE / XTRESTORE), so a program that handed over its terminal, like Claude Code, gets them back. In terminals without XTRESTORE both end up off and visible, as with most editors.

Keys

The full spec is in KEYBINDS.md. Every major key is also shown in the shortcut bar at the bottom of the screen.

Key Action
⌃X / ⌃⇧X Exit / exit without warning
⌃Q or ⌥Q Exit, the same as ⌃X
⌃S / ⌃O Save / export to a new file
⌃C / ⌃B / ⌃V Copy / extract (cut) / paste
⌃A Select all
⌃E or ⌥E Undo
⌃R or ⌥R Redo
⇧ + movement Extend the selection
⌃←→ or ⌥←→ Move by letterblock
⌃⌫ or ⌥⌫ Delete letterblock left
⌃⌦ or ⌥⌦ Delete letterblock right
⌃↑↓ or ⌥↑↓ Move line up / down
⌃F / ⌃G Find / find exactly
⌃L or ⌥Z Word wrap on / off
Tab / ⇧Tab Next / previous match
⌃/ or F1 Help

With nothing selected, ⌃C and ⌃B act on the whole line.

Undo works in steps. A run of typing, backspacing or line moves at one spot is one step, like an insert-mode run in vim. Enter, paste and extract are steps of their own, and moving the cursor starts a new one.

Word wrap

Long lines wrap onto the rows below instead of running off the right edge. This only changes how the text is shown: no line breaks are added to the file. Rows break between words, so English and 한국어 words stay whole, while 日本語, which has no spaces, breaks between any two characters except before closing punctuation like 。 and 」. A word too long for a row is split wherever it reaches the edge.

↑↓ and PgUp / PgDn move by screen row, and the line number is shown only on a line's first row. ⌃L (or ⌥Z, as in VS Code) turns wrapping off to scroll long lines sideways instead, and --nosoftwrap starts that way.

Letterblocks

A letterblock is a block of text with its own meaning: a word in English, a run of one script in Japanese (あなたの|ギター|になりたい|!), and in Korean a stem with its particle or ending split off (학교|에서는, 먹|었습니다). ⌃/⌥ + ←→ moves by letterblock (add ⇧ to select), and ⌃/⌥ + ⌫⌦ deletes one.

The Korean split uses a short list of common particles and endings, checked against the syllable before them (가을 and 사과 stay whole). It has no dictionary, so it still gets some nouns wrong (고양이 → 고양|이).

Terminals often send ⌃⌫ as ⌃H, and iTerm2's "natural text editing" preset sends ⌥⌫ as ⌃W and ⌥⌦ as ⌥D; zencode treats all of these as letterblock deletes.

Mouse

Click to place the cursor, ⇧+click or drag to select, double-click to select a letterblock (the same rules as ⌃/⌥ + ←→), and triple-click to select the line. The wheel scrolls the view without moving the cursor.

Shortcuts in the bar can be clicked too, and highlight when the pointer is over them: Exit, Save, Export, Find, Find Exact, Help, Copy, Extract, Paste, Select All, Undo, Redo and Wrap. Force Exit is deliberately not clickable, and movement keys like Letterblock and Move Line are only hints.

zencode captures the mouse, so for your terminal's own text selection hold ⌥ (iTerm2, Terminal.app) or ⇧ (most Linux terminals) while dragging.

Search

⌃F searches permissively and ⌃G searches exactly. Matches highlight as you type, Tab and ⇧Tab step through them, Enter keeps the current one selected, and Esc goes back to where you were.

A permissive search:

  • ignores case, and matches full-width ABC to ABC
  • matches 초성: ㅎㄱ finds 한국, and 한구 already finds 한국 while you type
  • matches ひらがな and カタカナ to each other, and turns a kana query into kanji: しんじゅく finds 新宿

Kana-to-kanji uses the dictionary in inputx-nihongo (MIT OR Apache-2.0, about 27,000 compounds). It looks up whole words only, not verb endings. 초성 matching needs no dictionary.

Clipboard

Copies go to the system clipboard through the terminal (OSC 52). This works over ssh in terminals that support it, such as iTerm2, WezTerm, kitty, Ghostty, foot and Windows Terminal. ⌃V pastes what you copied in zencode; to paste from other apps, use your terminal's own paste (⌘V or ⌃⇧V).

-s / --sandboxed turns both directions off: nothing is sent to the system clipboard, and pastes from the terminal are refused.

⌃⇧X

Most terminals send ⌃⇧X exactly like ⌃X. zencode can only tell them apart in terminals that support the kitty keyboard protocol (kitty, WezTerm, Ghostty, foot, Alacritty, recent iTerm2). Elsewhere ⌃⇧X behaves like ⌃X and still asks before discarding changes.

Colors

zencode picks the richest color mode the terminal supports: 24-bit truecolor, then 256 colors, then 16, then none. Every color is defined once in RGB and mapped down to the closest match for the mode in use.

Variable Effect
ZENCODE_COLOR Force truecolor, 256, 16 or none
ZENCODE_AMBIGUOUS_WIDE=1 Treat East Asian ambiguous-width characters as 2 cols
NO_COLOR Disable colors

Fonts

A terminal program can't pick its own font. The terminal emulator draws every glyph, so to see Korean and Japanese text you need to configure a font that covers both scripts in the terminal itself. Good choices:

  • Sarasa Mono K / J: monospaced, with CJK glyphs exactly two columns wide.
  • Pretendard JP: covers Latin, Hangul and Japanese, but it isn't monospaced. Use it as a fallback font behind a monospaced Latin font.

About

CLI text editor designed for EN/KO/JA.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages