You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

643 lines
16 KiB

  1. # QMK CLI Commands
  2. # User Commands
  3. ## `qmk compile`
  4. This command allows you to compile firmware from any directory. You can compile JSON exports from <https://config.qmk.fm>, compile keymaps in the repo, or compile the keyboard in the current working directory.
  5. This command is directory aware. It will automatically fill in KEYBOARD and/or KEYMAP if you are in a keyboard or keymap directory.
  6. **Usage for Configurator Exports**:
  7. ```
  8. qmk compile [-c] <configuratorExport.json>
  9. ```
  10. **Usage for Keymaps**:
  11. ```
  12. qmk compile [-c] [-e <var>=<value>] [-j <num_jobs>] -kb <keyboard_name> -km <keymap_name>
  13. ```
  14. **Usage in Keyboard Directory**:
  15. Must be in keyboard directory with a default keymap, or in keymap directory for keyboard, or supply one with `--keymap <keymap_name>`
  16. ```
  17. qmk compile
  18. ```
  19. **Usage for building all keyboards that support a specific keymap**:
  20. ```
  21. qmk compile -kb all -km <keymap_name>
  22. ```
  23. **Example**:
  24. ```
  25. $ qmk config compile.keymap=default
  26. $ cd ~/qmk_firmware/keyboards/planck/rev6
  27. $ qmk compile
  28. Ψ Compiling keymap with make planck/rev6:default
  29. ...
  30. ```
  31. or with optional keymap argument
  32. ```
  33. $ cd ~/qmk_firmware/keyboards/clueboard/66/rev4
  34. $ qmk compile -km 66_iso
  35. Ψ Compiling keymap with make clueboard/66/rev4:66_iso
  36. ...
  37. ```
  38. or in keymap directory
  39. ```
  40. $ cd ~/qmk_firmware/keyboards/gh60/satan/keymaps/colemak
  41. $ qmk compile
  42. Ψ Compiling keymap with make gh60/satan:colemak
  43. ...
  44. ```
  45. **Usage in Layout Directory**:
  46. Must be under `qmk_firmware/layouts/`, and in a keymap folder.
  47. ```
  48. qmk compile -kb <keyboard_name>
  49. ```
  50. **Example**:
  51. ```
  52. $ cd ~/qmk_firmware/layouts/community/60_ansi/mechmerlin-ansi
  53. $ qmk compile -kb dz60
  54. Ψ Compiling keymap with make dz60:mechmerlin-ansi
  55. ...
  56. ```
  57. **Parallel Compilation**:
  58. It is possible to speed up compilation by adding the `-j`/`--parallel` flag.
  59. ```
  60. qmk compile -j <num_jobs> -kb <keyboard_name>
  61. ```
  62. The `num_jobs` argument determines the maximum number of jobs that can be used. Setting it to zero will enable parallel compilation without limiting the maximum number of jobs.
  63. ```
  64. qmk compile -j 0 -kb <keyboard_name>
  65. ```
  66. ## `qmk flash`
  67. This command is similar to `qmk compile`, but can also target a bootloader. The bootloader is optional, and is set to `:flash` by default. To specify a different bootloader, use `-bl <bootloader>`. Visit the [Flashing Firmware](flashing.md) guide for more details of the available bootloaders.
  68. This command is directory aware. It will automatically fill in KEYBOARD and/or KEYMAP if you are in a keyboard or keymap directory.
  69. This command can also flash binary firmware files (hex or bin) such as the ones produced by [Configurator](https://config.qmk.fm).
  70. **Usage for Configurator Exports**:
  71. ```
  72. qmk flash [-bl <bootloader>] [-c] [-e <var>=<value>] [-j <num_jobs>] <configuratorExport.json>
  73. ```
  74. **Usage for Keymaps**:
  75. ```
  76. qmk flash -kb <keyboard_name> -km <keymap_name> [-bl <bootloader>] [-c] [-e <var>=<value>] [-j <num_jobs>]
  77. ```
  78. **Usage for pre-compiled firmwares**:
  79. **Note**: The microcontroller needs to be specified (`-m` argument) for keyboards with the following bootloaders:
  80. * HalfKay
  81. * QMK HID
  82. * USBaspLoader
  83. ISP flashing is also supported with the following flashers and require the microcontroller to be specified:
  84. * USBasp
  85. * USBtinyISP
  86. ```
  87. qmk flash [-m <microcontroller>] <compiledFirmware.[bin|hex]>
  88. ```
  89. **Listing the Bootloaders**
  90. ```
  91. qmk flash -b
  92. ```
  93. ## `qmk config`
  94. This command lets you configure the behavior of QMK. For the full `qmk config` documentation see [CLI Configuration](cli_configuration.md).
  95. **Usage**:
  96. ```
  97. qmk config [-ro] [config_token1] [config_token2] [...] [config_tokenN]
  98. ```
  99. ## `qmk cd`
  100. This command opens a new shell in your `qmk_firmware` directory.
  101. Note that if you are already somewhere within `QMK_HOME` (for example, the `keyboards/` folder), nothing will happen.
  102. To exit out into the parent shell, simply type `exit`.
  103. **Usage**:
  104. ```
  105. qmk cd
  106. ```
  107. ## `qmk find`
  108. This command allows for searching through keyboard/keymap targets, filtering by specific criteria. `info.json` and `rules.mk` files contribute to the search data, as well as keymap configurations, and the results can be filtered using "dotty" syntax matching the overall `info.json` file format.
  109. For example, one could search for all keyboards using STM32F411:
  110. ```
  111. qmk find -f 'processor=STM32F411'
  112. ```
  113. ...and one can further constrain the list to keyboards using STM32F411 as well as rgb_matrix support:
  114. ```
  115. qmk find -f 'processor=STM32F411' -f 'features.rgb_matrix=true'
  116. ```
  117. **Usage**:
  118. ```
  119. qmk find [-h] [-km KEYMAP] [-f FILTER]
  120. options:
  121. -km KEYMAP, --keymap KEYMAP
  122. The keymap name to build. Default is 'default'.
  123. -f FILTER, --filter FILTER
  124. Filter the list of keyboards based on the supplied value in rules.mk. Matches info.json structure, and accepts the formats 'features.rgblight=true' or 'exists(matrix_pins.direct)'. May be passed multiple times, all filters need to match. Value may include wildcards such as '*' and '?'.
  125. ```
  126. ## `qmk console`
  127. This command lets you connect to keyboard consoles to get debugging messages. It only works if your keyboard firmware has been compiled with `CONSOLE_ENABLE=yes`.
  128. **Usage**:
  129. ```
  130. qmk console [-d <pid>:<vid>[:<index>]] [-l] [-n] [-t] [-w <seconds>]
  131. ```
  132. **Examples**:
  133. Connect to all available keyboards and show their console messages:
  134. ```
  135. qmk console
  136. ```
  137. List all devices:
  138. ```
  139. qmk console -l
  140. ```
  141. Show only messages from clueboard/66/rev3 keyboards:
  142. ```
  143. qmk console -d C1ED:2370
  144. ```
  145. Show only messages from the second clueboard/66/rev3:
  146. ```
  147. qmk console -d C1ED:2370:2
  148. ```
  149. Show timestamps and VID:PID instead of names:
  150. ```
  151. qmk console -n -t
  152. ```
  153. Disable bootloader messages:
  154. ```
  155. qmk console --no-bootloaders
  156. ```
  157. ## `qmk doctor`
  158. This command examines your environment and alerts you to potential build or flash problems. It can fix many of them if you want it to.
  159. **Usage**:
  160. ```
  161. qmk doctor [-y] [-n]
  162. ```
  163. **Examples**:
  164. Check your environment for problems and prompt to fix them:
  165. qmk doctor
  166. Check your environment and automatically fix any problems found:
  167. qmk doctor -y
  168. Check your environment and report problems only:
  169. qmk doctor -n
  170. ## `qmk format-json`
  171. Formats a JSON file in a (mostly) human-friendly way. Will usually correctly detect the format of the JSON (info.json or keymap.json) but you can override this with `--format` if necessary.
  172. **Usage**:
  173. ```
  174. qmk format-json [-f FORMAT] <json_file>
  175. ```
  176. ## `qmk info`
  177. Displays information about keyboards and keymaps in QMK. You can use this to get information about a keyboard, show the layouts, display the underlying key matrix, or to pretty-print JSON keymaps.
  178. **Usage**:
  179. ```
  180. qmk info [-f FORMAT] [-m] [-l] [-km KEYMAP] [-kb KEYBOARD]
  181. ```
  182. This command is directory aware. It will automatically fill in KEYBOARD and/or KEYMAP if you are in a keyboard or keymap directory.
  183. **Examples**:
  184. Show basic information for a keyboard:
  185. qmk info -kb planck/rev5
  186. Show the matrix for a keyboard:
  187. qmk info -kb ergodox_ez -m
  188. Show a JSON keymap for a keyboard:
  189. qmk info -kb clueboard/california -km default
  190. ## `qmk json2c`
  191. Creates a keymap.c from a QMK Configurator export.
  192. **Usage**:
  193. ```
  194. qmk json2c [-o OUTPUT] filename
  195. ```
  196. ## `qmk c2json`
  197. Creates a keymap.json from a keymap.c.
  198. **Note:** Parsing C source files is not easy, therefore this subcommand may not work with your keymap. In some cases not using the C pre-processor helps.
  199. **Usage**:
  200. ```
  201. qmk c2json -km KEYMAP -kb KEYBOARD [-q] [--no-cpp] [-o OUTPUT] filename
  202. ```
  203. ## `qmk lint`
  204. Checks over a keyboard and/or keymap and highlights common errors, problems, and anti-patterns.
  205. **Usage**:
  206. ```
  207. qmk lint [-km KEYMAP] [-kb KEYBOARD] [--strict]
  208. ```
  209. This command is directory aware. It will automatically fill in KEYBOARD and/or KEYMAP if you are in a keyboard or keymap directory.
  210. **Examples**:
  211. Do a basic lint check:
  212. qmk lint -kb rominronin/katana60/rev2
  213. ## `qmk list-keyboards`
  214. This command lists all the keyboards currently defined in `qmk_firmware`
  215. **Usage**:
  216. ```
  217. qmk list-keyboards
  218. ```
  219. ## `qmk list-keymaps`
  220. This command lists all the keymaps for a specified keyboard (and revision).
  221. This command is directory aware. It will automatically fill in KEYBOARD if you are in a keyboard directory.
  222. **Usage**:
  223. ```
  224. qmk list-keymaps -kb planck/ez
  225. ```
  226. ## `qmk new-keyboard`
  227. This command creates a new keyboard based on available templates.
  228. Any arguments that are not provided will prompt for input. If `-u` is not passed and `user.name` is set in .gitconfig, it will be used as the default username in the prompt.
  229. **Usage**:
  230. ```
  231. qmk new-keyboard [-kb KEYBOARD] [-t {atmega32u4,STM32F303,etc}] [-l {60_ansi,75_iso,etc}] -u USERNAME
  232. ```
  233. ## `qmk new-keymap`
  234. This command creates a new keymap based on a keyboard's existing default keymap.
  235. This command is directory aware. It will automatically fill in KEYBOARD and/or KEYMAP if you are in a keyboard or keymap directory.
  236. **Usage**:
  237. ```
  238. qmk new-keymap [-kb KEYBOARD] [-km KEYMAP]
  239. ```
  240. ## `qmk clean`
  241. This command cleans up the `.build` folder. If `--all` is passed, any .hex or .bin files present in the `qmk_firmware` directory will also be deleted.
  242. **Usage**:
  243. ```
  244. qmk clean [-a]
  245. ```
  246. ## `qmk via2json`
  247. This command an generate a keymap.json from a VIA keymap backup. Both the layers and the macros are converted, enabling users to easily move away from a VIA-enabled firmware without writing any code or reimplementing their keymaps in QMK Configurator.
  248. **Usage**:
  249. ```
  250. qmk via2json -kb KEYBOARD [-l LAYOUT] [-km KEYMAP] [-o OUTPUT] filename
  251. ```
  252. **Example:**
  253. ```
  254. $ qmk via2json -kb ai03/polaris -o polaris_keymap.json polaris_via_backup.json
  255. Ψ Wrote keymap to /home/you/qmk_firmware/polaris_keymap.json
  256. ```
  257. ## `qmk import-keyboard`
  258. This command imports a data-driven `info.json` keyboard into the repo.
  259. **Usage**:
  260. ```
  261. usage: qmk import-keyboard [-h] filename
  262. ```
  263. **Example:**
  264. ```
  265. $ qmk import-keyboard ~/Downloads/forever60.json
  266. Ψ Importing forever60.json.
  267. Ψ Imported a new keyboard named forever60.
  268. Ψ To start working on things, `cd` into keyboards/forever60,
  269. Ψ or open the directory in your preferred text editor.
  270. Ψ And build with qmk compile -kb forever60 -km default.
  271. ```
  272. ## `qmk import-keymap`
  273. This command imports a data-driven `keymap.json` keymap into the repo.
  274. **Usage**:
  275. ```
  276. usage: qmk import-keymap [-h] filename
  277. ```
  278. **Example:**
  279. ```
  280. qmk import-keymap ~/Downloads/asdf2.json
  281. Ψ Importing asdf2.json.
  282. Ψ Imported a new keymap named asdf2.
  283. Ψ To start working on things, `cd` into keyboards/takashicompany/dogtag/keymaps/asdf2,
  284. Ψ or open the directory in your preferred text editor.
  285. Ψ And build with qmk compile -kb takashicompany/dogtag -km asdf2.
  286. ```
  287. ## `qmk import-kbfirmware`
  288. This command creates a new keyboard based on a [Keyboard Firmware Builder](https://kbfirmware.com/) export.
  289. **Usage**:
  290. ```
  291. usage: qmk import-kbfirmware [-h] filename
  292. ```
  293. **Example:**
  294. ```
  295. $ qmk import-kbfirmware ~/Downloads/gh62.json
  296. Ψ Importing gh62.json.
  297. ⚠ Support here is basic - Consider using 'qmk new-keyboard' instead
  298. Ψ Imported a new keyboard named gh62.
  299. Ψ To start working on things, `cd` into keyboards/gh62,
  300. Ψ or open the directory in your preferred text editor.
  301. Ψ And build with qmk compile -kb gh62 -km default.
  302. ```
  303. ---
  304. # Developer Commands
  305. ## `qmk format-text`
  306. This command formats text files to have proper line endings.
  307. Every text file in the repository needs to have Unix (LF) line ending.
  308. If you are working on **Windows**, you must ensure that line endings are corrected in order to get your PRs merged.
  309. ```
  310. qmk format-text
  311. ```
  312. ## `qmk format-c`
  313. This command formats C code using clang-format.
  314. Run it with no arguments to format all core code that has been changed. Default checks `origin/master` with `git diff`, branch can be changed using `-b <branch_name>`
  315. Run it with `-a` to format all core code, or pass filenames on the command line to run it on specific files.
  316. **Usage for specified files**:
  317. ```
  318. qmk format-c [file1] [file2] [...] [fileN]
  319. ```
  320. **Usage for all core files**:
  321. ```
  322. qmk format-c -a
  323. ```
  324. **Usage for only changed files against origin/master**:
  325. ```
  326. qmk format-c
  327. ```
  328. **Usage for only changed files against branch_name**:
  329. ```
  330. qmk format-c -b branch_name
  331. ```
  332. ## `qmk generate-compilation-database`
  333. **Usage**:
  334. ```
  335. qmk generate-compilation-database [-kb KEYBOARD] [-km KEYMAP]
  336. ```
  337. Creates a `compile_commands.json` file.
  338. Does your IDE/editor use a language server but doesn't _quite_ find all the necessary include files? Do you hate red squigglies? Do you wish your editor could figure out `#include QMK_KEYBOARD_H`? You might need a [compilation database](https://clang.llvm.org/docs/JSONCompilationDatabase.html)! The qmk tool can build this for you.
  339. This command needs to know which keyboard and keymap to build. It uses the same configuration options as the `qmk compile` command: arguments, current directory, and config files.
  340. **Example:**
  341. ```
  342. $ cd ~/qmk_firmware/keyboards/gh60/satan/keymaps/colemak
  343. $ qmk generate-compilation-database
  344. Ψ Making clean
  345. Ψ Gathering build instructions from make -n gh60/satan:colemak
  346. Ψ Found 50 compile commands
  347. Ψ Writing build database to /Users/you/src/qmk_firmware/compile_commands.json
  348. ```
  349. Now open your dev environment and live a squiggly-free life.
  350. ## `qmk docs`
  351. This command starts a local HTTP server which you can use for browsing or improving the docs. Default port is 8936.
  352. Use the `-b`/`--browser` flag to automatically open the local webserver in your default browser.
  353. This command runs `docsify serve` if `docsify-cli` is installed (which provides live reload), otherwise Python's builtin HTTP server module will be used.
  354. **Usage**:
  355. ```
  356. qmk docs [-b] [-p PORT]
  357. ```
  358. ## `qmk generate-docs`
  359. This command allows you to generate QMK documentation locally. It can be uses for general browsing or improving the docs. External tools such as [serve](https://www.npmjs.com/package/serve) can be used to browse the generated files.
  360. **Usage**:
  361. ```
  362. qmk generate-docs
  363. ```
  364. ## `qmk generate-rgb-breathe-table`
  365. This command generates a lookup table (LUT) header file for the [RGB Lighting](feature_rgblight.md) feature's breathing animation. Place this file in your keyboard or keymap directory as `rgblight_breathe_table.h` to override the default LUT in `quantum/rgblight/`.
  366. **Usage**:
  367. ```
  368. qmk generate-rgb-breathe-table [-q] [-o OUTPUT] [-m MAX] [-c CENTER]
  369. ```
  370. ## `qmk kle2json`
  371. This command allows you to convert from raw KLE data to QMK Configurator JSON. It accepts either an absolute file path, or a file name in the current directory. By default it will not overwrite `info.json` if it is already present. Use the `-f` or `--force` flag to overwrite.
  372. **Usage**:
  373. ```
  374. qmk kle2json [-f] <filename>
  375. ```
  376. **Examples**:
  377. ```
  378. $ qmk kle2json kle.txt
  379. ☒ File info.json already exists, use -f or --force to overwrite.
  380. ```
  381. ```
  382. $ qmk kle2json -f kle.txt -f
  383. Ψ Wrote out to info.json
  384. ```
  385. ## `qmk format-python`
  386. This command formats python code in `qmk_firmware`.
  387. **Usage**:
  388. ```
  389. qmk format-python
  390. ```
  391. ## `qmk pytest`
  392. This command runs the python test suite. If you make changes to python code you should ensure this runs successfully.
  393. **Usage**:
  394. ```
  395. qmk pytest [-t TEST]
  396. ```
  397. **Examples**:
  398. Run entire test suite:
  399. qmk pytest
  400. Run test group:
  401. qmk pytest -t qmk.tests.test_cli_commands
  402. Run single test:
  403. qmk pytest -t qmk.tests.test_cli_commands.test_c2json
  404. qmk pytest -t qmk.tests.test_qmk_path
  405. ## `qmk painter-convert-graphics`
  406. This command converts images to a format usable by QMK, i.e. the QGF File Format. See the [Quantum Painter](quantum_painter.md?id=quantum-painter-cli) documentation for more information on this command.
  407. ## `qmk painter-make-font-image`
  408. This command converts a TTF font to an intermediate format for editing, before converting to the QFF File Format. See the [Quantum Painter](quantum_painter.md?id=quantum-painter-cli) documentation for more information on this command.
  409. ## `qmk painter-convert-font-image`
  410. This command converts an intermediate font image to the QFF File Format. See the [Quantum Painter](quantum_painter.md?id=quantum-painter-cli) documentation for more information on this command.