Created
November 14, 2016 18:15
-
-
Save ragecryx/b704e712a36b562ed24a42bc4538cd3e to your computer and use it in GitHub Desktop.
This file contains 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
#!/bin/bash | |
function FCXXPlay() { | |
clear | |
fgMauve="\e[35m" | |
bgMauve="\e[45m" | |
fgGray="\e[30m" | |
bgRed="\e[41m" | |
colorReset="\e[0m" | |
Cl2EOL="\x1B[K" | |
if [ $# -eq 0 ]; then | |
echo -e "$bgMauve$fgGray CxxPlay - Usage: cxxplay file.cpp$Cl2EOL$colorReset\n\n$fgMauve Details:$colorReset\n*[1] The first line of your code should be something like\n\t// build!g++ -g -Wall -o awesome.bin awesometest.cpp\n*[2] The second line of your code should be something like\n\t// run!./awesome.bin someparam 23" | |
return | |
fi | |
BuildLine=$(head -n 1 $1) | |
RunLine=$(head -n 2 $1) | |
echo -e "$bgMauve$fgGray CxxPlay -> Build & Run $1$Cl2EOL$colorReset" | |
BuildCommand=${BuildLine##*!} | |
RunCommand=${RunLine##*!} | |
eval "$BuildCommand" | |
if [ $? -eq 0 ]; then | |
eval "$RunCommand" | |
else | |
echo "Build failed!" | |
fi | |
} | |
export -f FCXXPlay |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment