Skip to main content

hanfix

ci License: MIT

Typed a command with the Korean keyboard layout still on? Type hf and hanfix re-runs it in QWERTY.

한국어

Quick install

1. Install the latest release

Windows (PowerShell)

irm https://github.com/NaNIsaac/hanfix/releases/latest/download/install.ps1 | iex

Linux / macOS

curl -fsSL https://github.com/NaNIsaac/hanfix/releases/latest/download/install.sh | sh

2. Enable hf in your shell

hf is a shell function, because only the shell knows the previous command, so it needs one line in your shell's start-up file. Run this once.

PowerShell

New-Item -ItemType Directory -Force (Split-Path $PROFILE) | Out-Null; Add-Content $PROFILE 'Invoke-Expression (hanfix --init powershell | Out-String)'

bash

echo 'eval "$(hanfix --init bash)"' >> ~/.bashrc

For zsh (the macOS default) and fish, see Shell setup.

3. Open a new terminal and check that hf exists

Get-Command hf
bash -ic 'type hf'

Try the conversion on its own. It only prints:

$ hanfix ㅣㄴ -ㅁ
ls -a
$ hanfix dkssudgktpdy
안녕하세요

The scripts download a release binary and verify its SHA-256 checksum. You can inspect the installers before running remote code. For Cargo or manual downloads, see Install.

$ ㅣㄴ -ㅁ
bash: ㅣㄴ: command not found
$ ㅗㄹ
ls -a  [Enter / Ctrl+C]
.  ..  .git  README.md	src
$ 햣 촏차ㅐㅕㅅ -ㅠ 럍-쇼ㅔㅐ
bash: 햣: command not found
$ ㅗㄹ
git checkout -b fix-typo  [Enter / Ctrl+C]
Switched to a new branch 'fix-typo'

ㅗㄹ is what hf becomes when the Korean layout is still on, so both names work and you never have to switch layouts to fix the mistake.

On a Korean keyboard, forgetting to press the 한/영 key turns ls -a into ㅣㄴ -ㅁ. hanfix maps the Hangul back to the keys you pressed (2-set / KS X 5002 layout), shows the fixed command, and runs it when you press Enter. It works on Linux, macOS and Windows, with bash, zsh, fish and PowerShell.

hanfix demo

Install

Linux / macOS

curl -fsSL https://github.com/NaNIsaac/hanfix/releases/latest/download/install.sh | sh

Windows (PowerShell)

irm https://github.com/NaNIsaac/hanfix/releases/latest/download/install.ps1 | iex

The install script:

  1. Downloads the executable for your OS and CPU from Releases.
  2. Checks its SHA-256 checksum.
  3. Puts it in the install folder.
    • Linux/macOS: ~/.local/bin
    • Windows: %LOCALAPPDATA%\Programs\hanfix, which is added to your user PATH.
  4. Prints the line to add to your shell configuration.

Set HANFIX_INSTALL_DIR to change the install folder, and HANFIX_VERSION=v0.2.3 to pick a version.

Termux (aarch64) is tested in CI.

With Rust, you can install from source:

cargo install --git https://github.com/NaNIsaac/hanfix

Update

hanfix --update
  • Re-runs the install script to replace this copy with the latest release, in the folder the running hanfix is in.
  • The checksum is checked as on a first install.
  • Re-running the install command (curl … | sh, irm … | iex) does the same.
  • If you installed with cargo install, use cargo install --git https://github.com/NaNIsaac/hanfix --force.
  • hanfix -V prints the current version.

Shell setup

hf is a shell function, because only the shell knows the previous command. Add one line to your shell's start-up file and open a new terminal.

Shell File Line
bash ~/.bashrc eval "$(hanfix --init bash)"
zsh ~/.zshrc eval "$(hanfix --init zsh)"
fish ~/.config/fish/config.fish hanfix --init fish | source
PowerShell $PROFILE Invoke-Expression (hanfix --init powershell | Out-String)

In PowerShell, run this once:

New-Item -ItemType Directory -Force (Split-Path $PROFILE) | Out-Null; Add-Content $PROFILE 'Invoke-Expression (hanfix --init powershell | Out-String)'

To see the code that gets defined, run e.g. hanfix --init bash.

Usage

Fix the previous command

Command What it does
hf or ㅗㄹ Shows the fixed command and runs it on Enter. Ctrl+C cancels.
hf -y Runs it without asking.

Steps

  1. Takes the previous command from shell history, skipping hf itself.
  2. Maps Hangul jamo back to English keys. If nothing changes, prints nothing to fix and stops.
  3. Shows the fixed command in green and waits for Enter.
  4. Adds the fixed command to shell history and runs it, so the up arrow brings it back. fish does not get the history entry.

With codigest's terminal capture on (bash, zsh, PowerShell), the fixed command still gets the terminal, so an editor or codex opens as usual; codigest captures it by its own rules, as if you had typed it.

--alias renames the function. The Korean-layout name is defined too; for example --alias fk defines fk and 라.

eval "$(hanfix --init bash --alias fk)"

Convert text directly

hanfix ㅣㄴ -ㅁ               ->  ls -a
hanfix 햣 ㄴㅅㅁ션             ->  git status
hanfix dkssudgktpdy          ->  안녕하세요
echo ㅊㅇ .. | hanfix         ->  cd ..          (reads stdin too)
hanfix --to ko git           ->  햣             (forced direction)
hanfix --to en 한글           ->  gksrmf

The direction is automatic. Text with any Hangul goes back to English keys; anything else is composed into Hangul. If the guess is wrong, use --to ko or --to en.

Options

usage: hanfix [-h] [-V] [--to {ko,en}] [--] [TEXT ...]
       hanfix --init {bash,zsh,fish,powershell} [--alias NAME]
       hanfix --update
Option Description
-h, --help Print help.
-V, -v, --version Print the version.
--update Update to the latest release.
--to {ko,en} Force the direction. ko: English keys to Hangul; en: Hangul to English keys.
--init SHELL Print the shell code that defines hf.
--alias NAME Name of the function --init defines. Default hf.
-- End of options. Everything after is text.
  • Options are read only at the start; the rest is text to convert. So the -ㅁ in hanfix ㅣㄴ -ㅁ is text (-a), not an option.
  • To convert English text that starts with -, put -- first: hanfix -- -rk → -가.
  • Exit status: 0 on success, 2 on a usage error.

Fix the line you are typing (optional)

A key binding that fixes the current line in place before you run it. This setup has not been tested.

PowerShell (Ctrl+Alt+h)

Set-PSReadLineKeyHandler -Chord 'Ctrl+Alt+h' -BriefDescription hanfix -ScriptBlock {
    $line = $null; $cursor = $null
    [Microsoft.PowerShell.PSConsoleReadLine]::GetBufferState([ref]$line, [ref]$cursor)
    $enc = [Console]::OutputEncoding; [Console]::OutputEncoding = [Text.Encoding]::UTF8
    try { $fixed = (hanfix -- $line | Out-String).TrimEnd() } finally { [Console]::OutputEncoding = $enc }
    [Microsoft.PowerShell.PSConsoleReadLine]::RevertLine()
    [Microsoft.PowerShell.PSConsoleReadLine]::Insert($fixed)
}

bash (Alt+h)

bind -x '"\eh": READLINE_LINE=$(hanfix -- "$READLINE_LINE"); READLINE_POINT=${#READLINE_LINE}'

How it works

English keys → Hangul uses the same automaton as a real 2-set (KS X 5002) input method.

  • Each key maps to a jamo (r → ㄱ, k → ㅏ). Shift matters only for the double consonants and ㅒ, ㅖ; other capitals are treated as lowercase.
  • Compound vowels (ㅘ, ㅢ, ...) and compound finals (ㄳ, ㄺ, ㅄ, ...) are combined.
  • A final consonant followed by a vowel moves to the next syllable.
    • rkrk → 가가
    • rkqtdl → 값이: only the second consonant of a compound final moves.
  • ㄸ, ㅃ, ㅉ cannot be finals, so they always start a new syllable.
  • Syllables are built with the Unicode formula 0xAC00 + (initial×21 + medial)×28 + final.

Hangul → English keys reverses the formula to get initial, medial and final, splits compound jamo, and maps each to its key.

Characters that are not on the layout (digits, spaces, symbols) are left as they are.

Limitations

  • hf only converts Hangul to English. Commands are in English, so only that direction makes sense.
  • One direction per line. In mixed text like git ㅔㅕ노, the Hangul means everything goes to English keys, including any Hangul word you meant to keep.
  • 2-set only. 3-set (세벌식) and non-QWERTY English layouts (Dvorak etc.) are not supported.

Development

cargo test           # composition cases, round trip of all 11,172 Hangul syllables, shell code
sh tests/shells.sh   # in bash, zsh and fish, hf actually runs the fixed command (uses the installed hanfix)
pwsh tests/shells.ps1

The setup steps under Quick install are tested too. A <!-- test --> comment before a code block marks it, and CI runs the marked blocks in order on clean Linux, macOS and Windows machines with the shared readme workflow.

Uninstall

  • Linux/macOS: rm ~/.local/bin/hanfix
  • Windows: Remove-Item -Recurse "$env:LOCALAPPDATA\Programs\hanfix"

Also remove the line you added to your shell start-up file.

See also: hangeul, a Python library for Hangul text.

License

MIT

Metadata

Release files for hanfix 0.2.6

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for hanfix 0.2.6
File Size Uploaded Provenance Actions
hanfix-0.2.6.tar.gz 211.6 kB With provenance Details for hanfix-0.2.6.tar.gz

Built distributions (wheels)

Table of built distributions (wheels) for hanfix 0.2.6
File Actions
hanfix-0.2.6-py3-none-win_arm64.whl Python 3 none Windows ARM64 Details for hanfix-0.2.6-py3-none-win_arm64.whl
hanfix-0.2.6-py3-none-win_amd64.whl Python 3 none Windows x86-64 Details for hanfix-0.2.6-py3-none-win_amd64.whl
hanfix-0.2.6-py3-none-musllinux_1_2_x86_64.whl Python 3 none Linux musl 1.2+ x86-64 Details for hanfix-0.2.6-py3-none-musllinux_1_2_x86_64.whl
hanfix-0.2.6-py3-none-musllinux_1_2_aarch64.whl Python 3 none Linux musl 1.2+ ARM64 Details for hanfix-0.2.6-py3-none-musllinux_1_2_aarch64.whl
hanfix-0.2.6-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl Python 3 none Linux glibc 2.17+ x86-64 Details for hanfix-0.2.6-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
hanfix-0.2.6-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl Python 3 none Linux glibc 2.17+ ARM64 Details for hanfix-0.2.6-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
hanfix-0.2.6-py3-none-macosx_11_0_arm64.whl Python 3 none macOS 11.0+ ARM64 Details for hanfix-0.2.6-py3-none-macosx_11_0_arm64.whl
hanfix-0.2.6-py3-none-macosx_10_12_x86_64.whl Python 3 none macOS 10.12+ x86-64 Details for hanfix-0.2.6-py3-none-macosx_10_12_x86_64.whl

Total release size: 1.7 MB

Release files / hanfix-0.2.6.tar.gz

Download URL hanfix-0.2.6.tar.gz
Size 211.6 kB
Tags Source
SHA-256 checksum
How to use checksums
f34b84f376b0391d3e5220c740569301ba0e5894e1d0d6689de8898343d7f038
BLAKE2b-256 checksum
How to use checksums
9ed1dfe67a1f9186270067a24424ea07d2580acb050695558dfa4468fc7b0c80
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

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 Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 28, 2026.

Transparency log

Release files / hanfix-0.2.6-py3-none-win_arm64.whl

Download URL hanfix-0.2.6-py3-none-win_arm64.whl
Size 122.9 kB
Tags Python 3 Windows ARM64
SHA-256 checksum
How to use checksums
2d9bb2b0f48c8b0b5ea52c540bd14c2db1f5a789fdb53f0f8702db89e73a656f
BLAKE2b-256 checksum
How to use checksums
a949b3b723ef04ff91f8bc544cdc3fe6aa67a14b9688e3b068621f433eb01e29
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

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 Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 28, 2026.

Transparency log

Release files / hanfix-0.2.6-py3-none-win_amd64.whl

Download URL hanfix-0.2.6-py3-none-win_amd64.whl
Size 129.0 kB
Tags Python 3 Windows x86-64
SHA-256 checksum
How to use checksums
2ae72adf8c7cff16ee95202947c76795bcc06f5f5e50b881e4136e907dc147e5
BLAKE2b-256 checksum
How to use checksums
e4f565b5a197adc6d206c27a5c5cb9e498fd3fc7d9e35767648a33cabce07cdb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

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 Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 28, 2026.

Transparency log

Release files / hanfix-0.2.6-py3-none-musllinux_1_2_x86_64.whl

Download URL hanfix-0.2.6-py3-none-musllinux_1_2_x86_64.whl
Size 241.7 kB
Tags Linux musl 1.2+ x86-64 Python 3
SHA-256 checksum
How to use checksums
2383e3c4fda68e5dedc686b655a801a312eb7fdd0df72d7a1e563a9fc8ac7450
BLAKE2b-256 checksum
How to use checksums
048e5b6a354f6e94c24bcfcb8306d5a2ad06131400a65baaa95d54984c3ad4e0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

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 Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 28, 2026.

Transparency log

Release files / hanfix-0.2.6-py3-none-musllinux_1_2_aarch64.whl

Download URL hanfix-0.2.6-py3-none-musllinux_1_2_aarch64.whl
Size 232.3 kB
Tags Linux musl 1.2+ ARM64 Python 3
SHA-256 checksum
How to use checksums
a8263c5c07d6a1c16ecf4239faddfd5bd2fa1654cbcebc61ddc51ac23c30f14d
BLAKE2b-256 checksum
How to use checksums
073ed089368df9e4271abfee1754221b412ee6ec07c0f2591939dd4fb74776ff
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

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 Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 28, 2026.

Transparency log

Release files / hanfix-0.2.6-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

Download URL hanfix-0.2.6-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Size 192.4 kB
Tags Linux glibc 2.17+ x86-64 Python 3
SHA-256 checksum
How to use checksums
db999a8f52ef1ec37140ee84eefda2d4e97cde7e0d775b21085ef9d8d29299ca
BLAKE2b-256 checksum
How to use checksums
19c8ff8e805f705bb53f618a41dd71dd1e05b03478ece2e24e8f05b2b9604741
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

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 Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 28, 2026.

Transparency log

Release files / hanfix-0.2.6-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl

Download URL hanfix-0.2.6-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Size 185.0 kB
Tags Linux glibc 2.17+ ARM64 Python 3
SHA-256 checksum
How to use checksums
d3c97ebeaaadca3d337c7f3b72460af26290b529ade91b25f7d446750400c5f1
BLAKE2b-256 checksum
How to use checksums
28d45c04c09b83d527e532c392bd5add165308ab1bdaa8b99b7c949fdb813010
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

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 Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 28, 2026.

Transparency log

Release files / hanfix-0.2.6-py3-none-macosx_11_0_arm64.whl

Download URL hanfix-0.2.6-py3-none-macosx_11_0_arm64.whl
Size 173.7 kB
Tags Python 3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
4cc555bf7f1b12acc95a2f0fd640ead24a1e93ffc21c8cc9a9c5c5411158ddda
BLAKE2b-256 checksum
How to use checksums
8c02b283b88573140f98be8287b9732b1301a8de7f3ca9ec24b7262ff54ec371
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

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 Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 28, 2026.

Transparency log

Release files / hanfix-0.2.6-py3-none-macosx_10_12_x86_64.whl

Download URL hanfix-0.2.6-py3-none-macosx_10_12_x86_64.whl
Size 184.3 kB
Tags Python 3 macOS 10.12+ x86-64
SHA-256 checksum
How to use checksums
7e0f4b87d8c8a0e68252b6deb3dd7a833fb01190be00a5a52066f65aa7d29cd6
BLAKE2b-256 checksum
How to use checksums
f38430668b04df49bc53eeebbfca6512ce7bad4edb24120a269f7f89b443d01d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

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 Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 28, 2026.

Transparency log

Security for hanfix 0.2.6

Provenance

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.

Full provenance

All 9 files in this release have been uploaded with provenance metadata.

Select from 9 files

Attestation for hanfix-0.2.6.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 28, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page