I want to create an alias or function that when used prints something like this on the command line so I can further modify it before pressing enter myself.
Code:
$ FILE=exercise1; cc -o $FILE $FILE.c && ./$FILE; FILE=
The idea is that I'm studying c and want to change the name of the file once instead of changing it three times for every compilation and run of the program.
Ideally, after the first execution, the up arrow would show the previous command instead of the alias or function so I don't have to reenter the filename every time. Only when I want to change it.
I've tried a bunch of things in aliases and functions but I don't know how to prevent the newline. My attempts always get printed and I'm back at the prompt and an up arrow(history) shows the previous alias or function, not the full command.
So I guess there's really two questions.
Thank-you for your time.
Solution:
I ended up using this:
Code:
function runc {
eval cc -o $1 $1.c && ./$1
}
and then calling at the prompt with this:
Code:
$ runc test1
This is file test1