There are several commands I want to always run in the background. to do so, I added a function to my .bashrc
file that runs a command with its arguments in the background, and created some aliases for the commands I want.
Here's a snippet from my .bashrc
:
alias tkdiff="CMD=tkdiff; run_bg"
alias meld="CMD=meld; run_bg"
# Run command in background
run_bg() {
$CMD $@ &
}
The problem is that when I use these commands, if I run the jobs
command or when one of the processes is done, all I can see is $CMD $@
, and I can't see what's really running or what finished running.
For example:
[ ***** ]$ meld; meld; meld
[1] 117438
[2] 117439
[3] 117440
[ ***** ]$ jobs
[1] Running $CMD $@ &
[2]- Running $CMD $@ &
[3]+ Running $CMD $@ &
[ ***** ]$ jobs
[1] Done $CMD $@
[2]- Done $CMD $@
[3]+ Done $CMD $@
[ ***** ]$
I tried setting this up without a function (alias meld="meld $@ &"
), but then I get missing arguments. I tried creating a string that contains everything in a new var, but then I see the new var's name instead. I tried redirecting it into a file and running it as a script, but then I see the file's name instead. I tried with exec
, but I got the same results. I tried using the function with arguments, but I got lots of errors and no results (I was probably doing something wrong).
I know I can write a function for each command, but that's a bad solution and I still see the arguments as $@
.
Is there a way to see the contents of the variables instead of their names? Is there a better/easier way to make specific commands to always run in the background?
Using Red Hat 6.0 with GNOME 2.28.2. It's my workplace, so I can't switch distros or anything like that.
Thanks!