Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

To put the foreground job, in the background, I press cltr+Z and then bg [job-number]. Is there a way to do this in one step instead of two, with some cltr+[key] command?

And I don't mean the &. I want to put a process that I already started and am interacting with into the background.

share|improve this question

1 Answer 1

up vote 2 down vote accepted

You can skip the job id number: if you ommit it it will take the last suspended job from the current environment. So cltr+Z and bg is shorter.

If you add this to your .profile or .bashrc

bind '"\ek"':"\"bg\C-m\""

alt+w should put bg on your screen and execute it so it ends up into background.

Example:

rinzwind@discworld:~$ smplayer 
This is SMPlayer v. 0.6.9 (SVN r3447) running on Linux
^Z
[1]+  Stopped                 smplayer
rinzwind@discworld:~$ bind '"\ek"':"\"bg\C-m\""
[1]+ smplayer &

I have not been able to add a cltr+Z into the command though. Probably because of the signal being ignored:

Ctrl+Z The suspend signal, sends a SIGTSTP to a running program, thus stopping it and returning control to the shell.

12.1.1.2. Signals to your Bash shell

In the absence of any traps, an interactive Bash shell ignores SIGTERM and SIGQUIT. SIGINT is caught and handled, and if job control is active, SIGTTIN, SIGTTOU and SIGTSTP are also ignored. Commands that are run as the result of a command substitution also ignore these signals, when keyboard generated.

SIGHUP by default exits a shell. An interactive shell will send a SIGHUP to all jobs, running or stopped; see the documentation on the disown built-in if you want to disable this default behavior for a particular process. Use the huponexit option for killing all jobs upon receiving a SIGHUP signal, using the shopt built-in.

share|improve this answer

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.