Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

In RVM (Ruby Version Manager) you can create .rvmrc files for a per-project basis. This handles basic ruby version and library (gem) management. This script is automatically executed when you cd into an directory. However, it is nothing more than a Bash script. There is one particular part in the script that is as follows:

(
  if ! command -v bundle ; then
    gem install bundler --no-rdoc --no-ri
  fi

  bundle | grep -v 'Using' | grep -v 'complete' | sed '/^$/d'

) &

Since this is executed ever time you cd into a directory, it would be nice if I didn't get the following every time:

[1]+  Done                    ( if ! command -v bundle; then
    gem install bundler --no-rdoc --no-ri;
fi; bundle | grep --color=auto -v 'Using' | grep --color=auto -v 'complete' | sed '/^$/d' )

Is there any way that I can run these set of commands in the background and not be notified when it is completed. Or at least notified in a less obnoxious way such that the message might be like:

[1]+ Bundler is done! :-)

Thanks!

share|improve this question
add comment

2 Answers

up vote 2 down vote accepted

Try using disown, for example:

sleep 1 & disown

From man bash:

disown [-ar] [-h] [jobspec ...]

Without options, each jobspec is removed from the table of active jobs. If jobspec is not present, and neither -a nor -r is supplied, the shell's notion of the current job is used. If the -h option is given, each jobspec is not removed from the table, but is marked so that SIGHUP is not sent to the job if the shell receives a SIGHUP. If no jobspec is present, and neither the -a nor the -r option is supplied, the current job is used. If no jobspec is supplied, the -a option means to remove or mark all jobs; the -r option without a jobspec argument restricts operation to running jobs. The return value is 0 unless a jobspec does not specify a valid job.

share|improve this answer
    
Works great! The only issues is that it shows me the command it is disowning. Not a big deal but, I'd like to hide that too if possible. :-) –  John Jan 12 '12 at 21:17
1  
(sleep 1 & disown) 2>/dev/null –  choroba Jan 12 '12 at 21:45
add comment

You can redirect all output to either a logfile or to /dev/null too. Simply change the last line from

) &

to

) 2>&1 >>/var/log/rvm-log &
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.