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.

442 lines
9.8 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 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. **Usage for Configurator Exports**:
  70. ```
  71. qmk flash [-bl <bootloader>] [-c] [-e <var>=<value>] [-j <num_jobs>] <configuratorExport.json>
  72. ```
  73. **Usage for Keymaps**:
  74. ```
  75. qmk flash -kb <keyboard_name> -km <keymap_name> [-bl <bootloader>] [-c] [-e <var>=<value>] [-j <num_jobs>]
  76. ```
  77. **Listing the Bootloaders**
  78. ```
  79. qmk flash -b
  80. ```
  81. ## `qmk config`
  82. This command lets you configure the behavior of QMK. For the full `qmk config` documentation see [CLI Configuration](cli_configuration.md).
  83. **Usage**:
  84. ```
  85. qmk config [-ro] [config_token1] [config_token2] [...] [config_tokenN]
  86. ```
  87. ## `qmk console`
  88. 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`.
  89. **Usage**:
  90. ```
  91. qmk console [-d <pid>:<vid>[:<index>]] [-l] [-n] [-t] [-w <seconds>]
  92. ```
  93. **Examples**:
  94. Connect to all available keyboards and show their console messages:
  95. ```
  96. qmk console
  97. ```
  98. List all devices:
  99. ```
  100. qmk console -l
  101. ```
  102. Show only messages from clueboard/66/rev3 keyboards:
  103. ```
  104. qmk console -d C1ED:2370
  105. ```
  106. Show only messages from the second clueboard/66/rev3:
  107. ```
  108. qmk console -d C1ED:2370:2
  109. ```
  110. Show timestamps and VID:PID instead of names:
  111. ```
  112. qmk console -n -t
  113. ```
  114. Disable bootloader messages:
  115. ```
  116. qmk console --no-bootloaders
  117. ```
  118. ## `qmk doctor`
  119. 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.
  120. **Usage**:
  121. ```
  122. qmk doctor [-y] [-n]
  123. ```
  124. **Examples**:
  125. Check your environment for problems and prompt to fix them:
  126. qmk doctor
  127. Check your environment and automatically fix any problems found:
  128. qmk doctor -y
  129. Check your environment and report problems only:
  130. qmk doctor -n
  131. ## `qmk format-json`
  132. 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 neccesary.
  133. **Usage**:
  134. ```
  135. qmk format-json [-f FORMAT] <json_file>
  136. ```
  137. ## `qmk info`
  138. 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.
  139. **Usage**:
  140. ```
  141. qmk info [-f FORMAT] [-m] [-l] [-km KEYMAP] [-kb KEYBOARD]
  142. ```
  143. This command is directory aware. It will automatically fill in KEYBOARD and/or KEYMAP if you are in a keyboard or keymap directory.
  144. **Examples**:
  145. Show basic information for a keyboard:
  146. qmk info -kb planck/rev5
  147. Show the matrix for a keyboard:
  148. qmk info -kb ergodox_ez -m
  149. Show a JSON keymap for a keyboard:
  150. qmk info -kb clueboard/california -km default
  151. ## `qmk json2c`
  152. Creates a keymap.c from a QMK Configurator export.
  153. **Usage**:
  154. ```
  155. qmk json2c [-o OUTPUT] filename
  156. ```
  157. ## `qmk c2json`
  158. Creates a keymap.json from a keymap.c.
  159. **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.
  160. **Usage**:
  161. ```
  162. qmk c2json -km KEYMAP -kb KEYBOARD [-q] [--no-cpp] [-o OUTPUT] filename
  163. ```
  164. ## `qmk lint`
  165. Checks over a keyboard and/or keymap and highlights common errors, problems, and anti-patterns.
  166. **Usage**:
  167. ```
  168. qmk lint [-km KEYMAP] [-kb KEYBOARD] [--strict]
  169. ```
  170. This command is directory aware. It will automatically fill in KEYBOARD and/or KEYMAP if you are in a keyboard or keymap directory.
  171. **Examples**:
  172. Do a basic lint check:
  173. qmk lint -kb rominronin/katana60/rev2
  174. ## `qmk list-keyboards`
  175. This command lists all the keyboards currently defined in `qmk_firmware`
  176. **Usage**:
  177. ```
  178. qmk list-keyboards
  179. ```
  180. ## `qmk list-keymaps`
  181. This command lists all the keymaps for a specified keyboard (and revision).
  182. This command is directory aware. It will automatically fill in KEYBOARD if you are in a keyboard directory.
  183. **Usage**:
  184. ```
  185. qmk list-keymaps -kb planck/ez
  186. ```
  187. ## `qmk new-keyboard`
  188. This command creates a new keyboard based on available templates.
  189. 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.
  190. **Usage**:
  191. ```
  192. qmk new-keyboard [-kb KEYBOARD] [-t {avr,ps2avrgb}] -u USERNAME
  193. ```
  194. ## `qmk new-keymap`
  195. This command creates a new keymap based on a keyboard's existing default keymap.
  196. This command is directory aware. It will automatically fill in KEYBOARD and/or KEYMAP if you are in a keyboard or keymap directory.
  197. **Usage**:
  198. ```
  199. qmk new-keymap [-kb KEYBOARD] [-km KEYMAP]
  200. ```
  201. ## `qmk clean`
  202. 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.
  203. **Usage**:
  204. ```
  205. qmk clean [-a]
  206. ```
  207. ---
  208. # Developer Commands
  209. ## `qmk format-text`
  210. This command formats text files to have proper line endings.
  211. Every text file in the repository needs to have Unix (LF) line ending.
  212. If you are working on **Windows**, you must ensure that line endings are corrected in order to get your PRs merged.
  213. ```
  214. qmk format-text
  215. ```
  216. ## `qmk format-c`
  217. This command formats C code using clang-format.
  218. 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>`
  219. Run it with `-a` to format all core code, or pass filenames on the command line to run it on specific files.
  220. **Usage for specified files**:
  221. ```
  222. qmk format-c [file1] [file2] [...] [fileN]
  223. ```
  224. **Usage for all core files**:
  225. ```
  226. qmk format-c -a
  227. ```
  228. **Usage for only changed files against origin/master**:
  229. ```
  230. qmk format-c
  231. ```
  232. **Usage for only changed files against branch_name**:
  233. ```
  234. qmk format-c -b branch_name
  235. ```
  236. ## `qmk docs`
  237. This command starts a local HTTP server which you can use for browsing or improving the docs. Default port is 8936.
  238. Use the `-b`/`--browser` flag to automatically open the local webserver in your default browser.
  239. **Usage**:
  240. ```
  241. qmk docs [-b] [-p PORT]
  242. ```
  243. ## `qmk generate-docs`
  244. 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.
  245. **Usage**:
  246. ```
  247. qmk generate-docs
  248. ```
  249. ## `qmk generate-rgb-breathe-table`
  250. 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/`.
  251. **Usage**:
  252. ```
  253. qmk generate-rgb-breathe-table [-q] [-o OUTPUT] [-m MAX] [-c CENTER]
  254. ```
  255. ## `qmk kle2json`
  256. 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.
  257. **Usage**:
  258. ```
  259. qmk kle2json [-f] <filename>
  260. ```
  261. **Examples**:
  262. ```
  263. $ qmk kle2json kle.txt
  264. ☒ File info.json already exists, use -f or --force to overwrite.
  265. ```
  266. ```
  267. $ qmk kle2json -f kle.txt -f
  268. Ψ Wrote out to info.json
  269. ```
  270. ## `qmk format-python`
  271. This command formats python code in `qmk_firmware`.
  272. **Usage**:
  273. ```
  274. qmk format-python
  275. ```
  276. ## `qmk pytest`
  277. This command runs the python test suite. If you make changes to python code you should ensure this runs successfully.
  278. **Usage**:
  279. ```
  280. qmk pytest
  281. ```