Last active
October 6, 2016 06:08
-
-
Save ElectricCoffee/12044eec7c506e7927264f1c1b9ce405 to your computer and use it in GitHub Desktop.
I had to make a bunch of C++ files, and couldn't be bothered to make all the cpp/hpp pairs, so instead I wrote a script that does it for me! It also makes sure not to overwrite any files that already exist
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function touch-cpp { | |
for file in "$@" | |
do | |
cpp="$file.cpp" | |
hpp="$file.hpp" | |
# only actually attempt to write the files if they don't exist. | |
if [ -f $cpp -o -f $hpp ] | |
then | |
echo ">> Either $cpp or $hpp already exist, no action taken." | |
else | |
touch $cpp | |
echo "// The implementation file of $file" > $cpp | |
echo "#include \"$hpp\"" >> $cpp | |
touch $hpp | |
echo "// The header file of $file" > $hpp | |
echo "#ifndef ${file}_hpp" >> $hpp | |
echo "#define ${file}_hpp" >> $hpp | |
echo "// code goes here" >> $hpp | |
echo "#endif" >> $hpp | |
echo ">> Files $cpp and $hpp written to $(pwd)." | |
fi | |
done | |
unset cpp | |
unset hpp | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment