70

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?

| |
93

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.
| |
13

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.

| |
4

You can use fg to bring the foreground activity back

OR

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

| |
0

In linux you could use reptyr PID_number.

If for example you had been running vim in your terminal then
first get the terminal PID_number with something like
ps -ax | grep vim

then
sudo reptyr PID_number

Scroll through open applications and you should see your terminal as it was.

HTH

| |
  • zsh: command not found: reptyr Not installed by default on all OSes. – jnovack Sep 25 at 20:24
  • Yes, this package you will have to install, but it works – Kes Oct 15 at 17:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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