Re-enter interactive mode after Ctrl-z

64

10

In interactive mode (in Octave, gnuplot, R, etc.) I occasionally press Control + z by mistake. This pauses the program and kicks me back to the terminal.

Is it possible to re-enter the original interactive mode (with all the stored variables)?

To reproduce:

~> octave
octave:1> a = [1:10];
octave:2> ^Z
[1]+  Stopped                 octave
~> 

How can I recover my session with the variable a defined?

Tom

Posted 2011-06-14T11:58:55.460

Reputation: 967

Answers

86

type fg and hit enter in terminal.

   fg [jobspec]
          Resume jobspec in the foreground, and make
          it  the  current  job.   If jobspec is not
          present, the shell’s notion of the current
          job  is used.  The return value is that of
          the command placed into the foreground, or
          failure  if  run  when job control is dis-
          abled  or,  when  run  with  job   control
          enabled,  if  jobspec  does  not specify a
          valid job or jobspec specifies a job  that
          was started without job control.

Prince John Wesley

Posted 2011-06-14T11:58:55.460

Reputation: 2 139

12

Type the following to pull the job to the foreground again:

fg

This is because you suspended the job, meaning it's doing nothing while you can't see it. You can actually let a job run in the background too (by entering bg). See Job Control for more info.

slhck

Posted 2011-06-14T11:58:55.460

Reputation: 182 472

4

You can use fg to bring the foreground activity back

OR

You can use bg to move the current activity to background.

Prateek

Posted 2011-06-14T11:58:55.460

Reputation: 201