A command line program to help set up ZMK Firmware
Project description
ZMK CLI
A command line program to help set up ZMK Firmware.
ZMK CLI walks you through installing ZMK and setting up a GitHub repository to store and build custom firmware. It also automates some common tasks such as adding new keyboards to your repository.
The instructions below contain commands that need to be run in a terminal program. On Windows, use the Windows Terminal or PowerShell. On other operating systems, the terminal program is usually just named "Terminal".
Installation
This readme will provide brief instructions for installing ZMK CLI. For instructions in more detail, see the ZMK Documentation.
Install Git
Install Git from https://git-scm.com/downloads or your OS's package manager.
You will also need a GitHub account.
Install uv
Install uv from https://docs.astral.sh/uv/getting-started/installation/.
Install ZMK CLI
Run the following command to install ZMK CLI:
uv tool install zmk
If you have already installed ZMK CLI, you can update to the latest version with the following command:
uv tool upgrade zmk
Usage
All ZMK CLI commands start with zmk. Run zmk --help for general usage instructions. For help with a specific subcommand, add --help after the subcommand, e.g. zmk init --help.
Initialize a Repository
⚠️ If you have already created a repo and cloned it to your computer, you do not need to run this command. Set the user.home setting to point to the existing repo instead.
The zmk init command walks you through creating a GitHub repository, then clones it to your computer so you can edit it.
Open a terminal and use the cd command to move to a directory where you'd like to place the ZMK files, then run zmk init. For example:
cd ~/Documents
zmk init
Follow the instructions it gives you. If you already have a ZMK config repo, select "Clone an existing repo" and enter the repo's URL, for example:
Repository URL: https://github.com/myusername/zmk-config
Otherwise, select "Create a new ZMK config repo" and it will walk you through creating a new repo.
Once you finish following all the instructions, you will have a copy of the repo stored on your computer. All zmk commands will run on this repo (unless the working directory is inside a different repo). If you ever forget where the repo is located, you can run zmk cd to find it.
Now that you have a repo created, see Customizing ZMK for documentation on how to customize it, and see the instructions below for how ZMK CLI can automate some common tasks.
Keyboard Management
Add a Keyboard
To start building firmware for a new keyboard, run zmk keyboard add. Follow the instructions to select a keyboard (and controller board if necessary), and it will add it to the list of firmware to build and copy a default keymap into your repo.
You can then run zmk code <keyboard> to open the keymap in a text editor.
This command reads from a local copy of ZMK to determine the supported keyboards. If the keyboard you want to use isn't listed, try running zmk update to update the local copy to the latest version of ZMK. If it still isn't listed, you may be able to find a Zephyr module that provides it, or you may need to create it yourself.
Remove a keyboard
To remove a keyboard from the build, run zmk keyboard remove and select the item to remove. For a split keyboard, you will need to run this twice and remove the left and right sides.
This simply removes a keyboard from the build.yaml file. It does not delete any .keymap or .conf files.
List Supported Keyboards
Run zmk keyboard list to print a list of supported keyboard hardware.
Create a New Keyboard
If ZMK doesn't support your keyboard yet, you can run zmk keyboard new to create a new keyboard from a template.
Note that this will generate most of the boilerplate for you, but you will still need to manually edit the files to match your keyboard. See the New Keyboard Shield guide for how to finish writing the keyboard files.
Module Management
Zephyr modules can add support for new keyboards, behaviors, and other features to ZMK. Use the zmk module command to install modules into your repo:
zmk module add # Add a module
zmk module remove # Remove an installed module
zmk module list # List the installed modules
zmk update # Update the local copies of ZMK and modules to their latest versions
Edit Keymap and Config Files
The zmk code command will open ZMK files in a text editor:
zmk code # Open the repo directory in an editor
zmk code <keyboard> # Open <keyboard>.keymap in an editor
zmk code --conf <keyboard> # Open <keyboard>.conf in an editor
zmk code --build # Open build.yaml in an editor
The first time you run this command, it will ask you which editor you want to use. If you want to change this choice later or use an editor that wasn't listed, see the core.editor and code.explorer settings.
Push Changes to GitHub
Run zmk cd to go to the repo directory. From here, you can run git commands manage the repo.
For example, after adding a keyboard to your repo and editing its keymap, you can run the following commands to push your changes to GitHub and trigger a firmware build:
git add .
git commit
git push
You will need to authenticate with GitHub before the git push command will work. The easiest way to do this is to install the GitHub CLI and run
gh auth login
but you can also use a personal access token. If using an access token, make sure you create it with the "workflow" scope option selected.
Download Firmware from GitHub
After pushing changes, GitHub will automatically build the firmware for you. Run zmk download (or zmk dl for short) to open the GitHub actions page in your browser.
From this page, you can click on a build (the latest is at the top) to view its status. If the build succeeded, you can download the firmware from the "Artifacts" section at the bottom of the build summary page.
ZMK Version Management
The zmk version command manages the version of ZMK you are using:
zmk version # Print the current ZMK version
zmk version --list # List the available versions
zmk version <revision> # Switch to the version given by <revision>
You can set the revision to any Git tag, branch, or commit:
zmk version v0.3 # Switch to tag "v0.3"
zmk version main # Switch to branch "main"
zmk version 1958217 # Switch to commit "1958217"
Note that zmk version --list will only list tagged versions.
Configuration
The zmk config command manages settings for ZMK CLI:
zmk config # List all settings
zmk config <name> # Print the value of the setting <name>
zmk config <name> <value> # Set <name> to <value>
zmk config --unset <name> # Remove the setting <name>
By default, these settings are stored in a file in your user profile directory. Run zmk config --path to get the location of this file. You can change where the settings file is stored by setting a ZMK_CLI_CONFIG environment variable to the new path to use, or by adding a --config-file=<path> argument when running zmk.
Other commands use the following settings:
core.editor
Command line for a text editor to use with the zmk code command.
For example, to set Visual Studio Code as the editor and make it always open a new window, run:
zmk config core.editor "code --new-window"
core.explorer
Command line for a file explorer to use with the zmk code command when opening a directory.
If this setting is not set, the core.editor tool will be run instead. Set this setting when using a text editor that does not support opening directories.
user.home
The path to the repository to use whenever zmk is run and the working directory is not inside a ZMK config repository.
For example, to point ZMK CLI to an existing repo at ~/Documents/zmk-config, run:
zmk config user.home ~/Documents/zmk-config
Development
If you would like to help improve ZMK CLI, you can clone this repo and install it into a virtual environment where you can modify it. First, open a terminal to the root directory of the repository. Then, create a virtual environment and install the project's dependencies:
# Create virtual environment and install dependencies
uv sync
# Install pre-commit hooks
uv run prek install
To run the development version of the program, either prefix commands with uv run...
uv run zmk <args...>
...or activate the virtual environment first, and then you can use just zmk.
If you want zmk to run the development version even when you are not inside the virtual environment, you can install it globally in editable mode:
uv tool install -e .
Linting
After running uv run prek install, linting and code formatting will be run automatically when you make a commit. You can also run these tools manually:
# lint codebase
uv run ruff check
# format files
uv run ruff format
Type checking is slower and difficult to configure to run as a Git commit hook, so this needs to be run manually.
uv run pyright .
GitHub will also run these checks and report any errors when you make a pull request.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file zmk-0.4.1.tar.gz.
File metadata
- Download URL: zmk-0.4.1.tar.gz
- Upload date:
- Size: 87.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
bd1a7334f5b88fa83537d64a541105e9eece8706f1ffe1eba48e06a721435738
|
|
| MD5 |
d53b99cce6ebdff0193b10d39104decd
|
|
| BLAKE2b-256 |
4b4b9a90f9c75441d5eb7468f3a164a0acbc8390b856db082d0d31d6908d148d
|
Provenance
The following attestation bundles were made for zmk-0.4.1.tar.gz:
Publisher:
release.yml on zmkfirmware/zmk-cli
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
zmk-0.4.1.tar.gz -
Subject digest:
bd1a7334f5b88fa83537d64a541105e9eece8706f1ffe1eba48e06a721435738 - Sigstore transparency entry: 1058985250
- Sigstore integration time:
-
Permalink:
zmkfirmware/zmk-cli@0372f310f6939d5e978cc7f4a0d4691689a150ea -
Branch / Tag:
refs/tags/v0.4.1 - Owner: https://github.com/zmkfirmware
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@0372f310f6939d5e978cc7f4a0d4691689a150ea -
Trigger Event:
push
-
Statement type:
File details
Details for the file zmk-0.4.1-py3-none-any.whl.
File metadata
- Download URL: zmk-0.4.1-py3-none-any.whl
- Upload date:
- Size: 90.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f1880d51660c291df133f7a906d0cc82a365e212c84da7eea019d3b92592bbec
|
|
| MD5 |
7c1d7cd2d59c60d4d1e48a58a427c95f
|
|
| BLAKE2b-256 |
ee779527da4bbf5cccb56413a99fbb2d8cc54a696b592cde59b327585ffe2805
|
Provenance
The following attestation bundles were made for zmk-0.4.1-py3-none-any.whl:
Publisher:
release.yml on zmkfirmware/zmk-cli
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
zmk-0.4.1-py3-none-any.whl -
Subject digest:
f1880d51660c291df133f7a906d0cc82a365e212c84da7eea019d3b92592bbec - Sigstore transparency entry: 1058985262
- Sigstore integration time:
-
Permalink:
zmkfirmware/zmk-cli@0372f310f6939d5e978cc7f4a0d4691689a150ea -
Branch / Tag:
refs/tags/v0.4.1 - Owner: https://github.com/zmkfirmware
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@0372f310f6939d5e978cc7f4a0d4691689a150ea -
Trigger Event:
push
-
Statement type: