aboutsummaryrefslogtreecommitdiffstats
path: root/util
diff options
context:
space:
mode:
authorGravatar shikamiya <46595896+shikamiya@users.noreply.github.com>2020-01-01 19:07:54 +0900
committerGravatar fauxpark <fauxpark@gmail.com>2020-01-01 21:07:54 +1100
commit59b017381c96ce5fd200d4db590accf8cbea9313 (patch)
treebe4d0da8f3b88d0e26827e6277a1880ce9f2f41d /util
parent680ebef0869b7860017a80bd601faac61227cd28 (diff)
downloadqmk_firmware-59b017381c96ce5fd200d4db590accf8cbea9313.tar.gz
Add creation of new keyboard in child directory (#6018)
* Add creation of new chlid keyboard * Add creation of new keyboard's parent directories * Remove redundant message and if statement * Divide creating new keyboard directory from copying template files * Fix variables of year placeholder * Fix filename of keyboard.[ch]
Diffstat (limited to 'util')
-rwxr-xr-xutil/new_keyboard.sh21
1 files changed, 12 insertions, 9 deletions
diff --git a/util/new_keyboard.sh b/util/new_keyboard.sh
index 11c6497e2..1f08790ad 100755
--- a/util/new_keyboard.sh
+++ b/util/new_keyboard.sh
@@ -32,8 +32,10 @@ set_git_username() {
# Copy the template files to the new keyboard directory.
copy_templates() {
+ mkdir -p "$keyboard_dir"
+
echo -n "Copying base template files..."
- cp -r "quantum/template/base" "${keyboard_dir}"
+ cp -r "quantum/template/base/." "${keyboard_dir}"
echo " done"
echo -n "Copying $keyboard_type template files..."
@@ -41,8 +43,8 @@ copy_templates() {
echo " done"
echo -n "Renaming keyboard files..."
- mv "${keyboard_dir}/keyboard.c" "${keyboard_dir}/${keyboard_name}.c"
- mv "${keyboard_dir}/keyboard.h" "${keyboard_dir}/${keyboard_name}.h"
+ mv "${keyboard_dir}/keyboard.c" "${keyboard_dir}/${keyboard_base_name}.c"
+ mv "${keyboard_dir}/keyboard.h" "${keyboard_dir}/${keyboard_base_name}.h"
echo " done"
}
@@ -74,8 +76,8 @@ replace_placeholders() {
replace_year_placeholders() {
local replace_year_filenames=(
"${keyboard_dir}/config.h"
- "${keyboard_dir}/${keyboard_name}.c"
- "${keyboard_dir}/${keyboard_name}.h"
+ "${keyboard_dir}/${keyboard_base_name}.c"
+ "${keyboard_dir}/${keyboard_base_name}.h"
"${keyboard_dir}/keymaps/default/config.h"
"${keyboard_dir}/keymaps/default/keymap.c"
)
@@ -88,10 +90,10 @@ replace_keyboard_placeholders() {
"${keyboard_dir}/config.h"
"${keyboard_dir}/info.json"
"${keyboard_dir}/readme.md"
- "${keyboard_dir}/${keyboard_name}.c"
+ "${keyboard_dir}/${keyboard_base_name}.c"
"${keyboard_dir}/keymaps/default/readme.md"
)
- replace_placeholders "%KEYBOARD%" "$keyboard_name" "${replace_keyboard_filenames[@]}"
+ replace_placeholders "%KEYBOARD%" "$keyboard_base_name" "${replace_keyboard_filenames[@]}"
}
# Replace %YOUR_NAME% with the username.
@@ -100,8 +102,8 @@ replace_name_placeholders() {
"${keyboard_dir}/config.h"
"${keyboard_dir}/info.json"
"${keyboard_dir}/readme.md"
- "${keyboard_dir}/${keyboard_name}.c"
- "${keyboard_dir}/${keyboard_name}.h"
+ "${keyboard_dir}/${keyboard_base_name}.c"
+ "${keyboard_dir}/${keyboard_base_name}.h"
"${keyboard_dir}/keymaps/default/config.h"
"${keyboard_dir}/keymaps/default/keymap.c"
)
@@ -136,6 +138,7 @@ echo
while [ -z "$keyboard_name" ]; do
prompt "Keyboard Name" ""
keyboard_name=$prompt_return
+ keyboard_base_name=$(basename $keyboard_name)
done
keyboard_dir="keyboards/$keyboard_name"