keychron_qmk_firmware/util/new_project.sh

32 lines
1.0 KiB
Bash
Raw Normal View History

2015-10-28 00:33:18 +06:00
#!/bin/sh
# Script to make a new quantum project
# Jack Humbert 2015
2016-04-08 04:09:53 +06:00
if [ -z "$1" ]; then
echo "Usage: $0 <keyboard_name>"
2016-04-08 04:09:53 +06:00
exit 1
fi
if [ -e "keyboards/$1" ]; then
echo "Error! keyboards/$1 already exists!"
exit 1
fi
cd "$(dirname "$0")/.."
2015-10-28 00:33:18 +06:00
KEYBOARD=$1
KEYBOARD_UPPERCASE=$(echo $1 | awk '{print toupper($0)}')
KEYBOARD_NAME=$(basename $1)
KEYBOARD_NAME_UPPERCASE=$(echo $KEYBOARD_NAME | awk '{print toupper($0)}')
2015-10-28 00:33:18 +06:00
2018-01-22 02:32:19 +06:00
cp -r quantum/template keyboards/$KEYBOARD
mv keyboards/${KEYBOARD}/template.c keyboards/${KEYBOARD}/${KEYBOARD_NAME}.c
mv keyboards/${KEYBOARD}/template.h keyboards/${KEYBOARD}/${KEYBOARD_NAME}.h
find keyboards/${KEYBOARD} -type f -exec sed -i '' -e "s;%KEYBOARD%;${KEYBOARD_NAME};g" {} \;
find keyboards/${KEYBOARD} -type f -exec sed -i '' -e "s;%KEYBOARD_UPPERCASE%;${KEYBOARD_NAME_UPPERCASE};g" {} \;
2015-10-28 00:33:18 +06:00
echo "######################################################"
echo "# /keyboards/$KEYBOARD project created. To start"
echo "# working on things, cd into keyboards/$KEYBOARD"
2016-03-04 21:15:21 +06:00
echo "######################################################"