From 170de1273cde78d93b3f955aca133a4d690742b2 Mon Sep 17 00:00:00 2001 From: MechMerlin <30334081+mechmerlin@users.noreply.github.com> Date: Thu, 13 Sep 2018 11:22:05 -0700 Subject: Add an easy way to create new keymaps for your favorite keyboard (#3868) * initial commit of keymap creation script * create default keymap * pass shellcheck * provide a better usage message * change printf string to more accurately reflect the path * make it more easily understood * found another typo * add documentation regarding the new_keymap script * enforce lowercase for userinputs --- util/new_keymap.sh | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100755 util/new_keymap.sh (limited to 'util/new_keymap.sh') diff --git a/util/new_keymap.sh b/util/new_keymap.sh new file mode 100755 index 000000000..b09f3dd0c --- /dev/null +++ b/util/new_keymap.sh @@ -0,0 +1,40 @@ +#!/bin/sh +# Script to make a new keymap for a keyboard of your choosing +# This script automates the copying of the default keymap into +# your own keymap + +KB_PATH=$(echo "$1" | tr 'A-Z' 'a-z') +USERNAME=$(echo "$2" | tr 'A-Z' 'a-z') + +if [ -z "$KB_PATH" ]; then + printf "Usage: %s \n" "$0" + printf "Example: %s 1upkeyboards/1up60hse yourname\n" "$0" + exit 1 +fi + +if [ -z "$USERNAME" ]; then + printf "Usage: %s \n" "$0" + printf "Example: %s 1upkeyboards/1up60hse yourname\n" "$0" + exit 1 +fi + +cd .. + +if [ ! -d "keyboards/$KB_PATH" ]; then + printf "Error! keyboards/%s does not exist!\n" "$KB_PATH" + exit 1 +fi + +if [ -d "keyboards/$KB_PATH/keymaps/$USERNAME" ]; then + printf "Error! keyboards/%s/keymaps/%s already exists!\n" "$KB_PATH" "$USERNAME" + exit 1 +fi + +# Recursively copy the chosen keyboard's default keymap +cp -r keyboards/"$KB_PATH"/keymaps/default keyboards/"$KB_PATH"/keymaps/"$USERNAME" + +printf "%s keymap directory created in: qmk_firmware/keyboards/%s/keymaps/\n\n" "$USERNAME" "$KB_PATH" + +printf "Compile a firmware file with your new keymap by typing: \n" +printf " make %s:%s\n" "$KB_PATH" "$USERNAME" +printf "from the qmk_firmware directory\n" \ No newline at end of file -- cgit v1.2.3-24-g4f1b From bef554d18bcb14492e2513b0759407e4b4581c9c Mon Sep 17 00:00:00 2001 From: MechMerlin <30334081+mechmerlin@users.noreply.github.com> Date: Wed, 24 Oct 2018 08:57:08 -0700 Subject: Bug: Users had to be in the /util directory to run the script (#4228) --- util/new_keymap.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'util/new_keymap.sh') diff --git a/util/new_keymap.sh b/util/new_keymap.sh index b09f3dd0c..73cc9e8cc 100755 --- a/util/new_keymap.sh +++ b/util/new_keymap.sh @@ -18,7 +18,7 @@ if [ -z "$USERNAME" ]; then exit 1 fi -cd .. +cd "$(dirname "$0")/.." if [ ! -d "keyboards/$KB_PATH" ]; then printf "Error! keyboards/%s does not exist!\n" "$KB_PATH" -- cgit v1.2.3-24-g4f1b