Created
November 17, 2021 18:16
-
-
Save imasimali/f54e5a5ffb7503528ffda3efea92e637 to your computer and use it in GitHub Desktop.
Run your C program in gcc with one line.
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
Add aliases in your .(shell)rc: | |
alias gcb='f(){ gcc "$1" -o "$2"; ./"$2"; unset -f f; }; f' | |
alias gcr='f(){ gcc "$1"; ./a.out; rm -f a.out; unset -f f; }; f' | |
The first modifies the name of the binary and executes it. The second compiles, runs, and delete the binary. | |
Demo gcb: | |
~$ gcb main.c build | |
Hello World | |
~$ ls | |
main.c build | |
Demo gcr: | |
~$ gcr main.c | |
Hello World | |
~$ ls | |
main.c |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment