The generic way to do this is by suspending the current job, executing the command and resuming the old job.
ls | less
(read text, notice the filename)
Control-z
to suspend the current active command
You should get a line similar to this:[1]+ Stopped ls | less
([1] is the job number.)
rm testfile
fg
or fg %1
(the 1 is the job number)
You can suspend multiple processes at the same time. E.g.
ls | less
Control-z
(output: [1]+ Stopped ls | less
)
man rm
Control-z
(output: [2]+ Stopped man rm
)
rm -i testfile*
fg %1
to resume job 1 (leaving the man page open in the background), or
fg %2
to resume job 2 (man rm)
If you have multiple suspended processes you can list them with jobs
.
man actually changes CWD, so you would need to use the full path. – Rob – 2012-12-19T18:46:21.207
@Rob - What do you mean that
man actually changes CWD
? – PeanutsMonkey – 2012-12-19T18:51:54.037I have tmux set up to show my CWD in my status bar. Doing
man man
(or anything) will change my CWD while man is open. My linux machine isn't available at the moment, and I'm not sure of any other way to check CWD, but to me it seems like that's what it's doing. – Rob – 2012-12-19T19:56:02.860@Rob - So you mean to say that just because you are using tmux, it changes the current working directory when you run the command
man {command}
from say/home/{user}
to a location of the commandman
? – PeanutsMonkey – 2012-12-19T20:54:58.740That would explain the behaviour I saw. Now, why it's changing the CWD, that's another question... – Ash – 2012-12-19T21:24:50.427
@PeanutsMonkey I assume it would change directory anyway, but I can see it with tmux. – Rob – 2012-12-20T16:59:51.817
@Rob - Sorry for being such a n00b Rob but I still don't get, what changes directory and from what to what? – PeanutsMonkey – 2012-12-20T18:24:52.813
@Rob, @PeanutsMonkey: I've updated my answer to try and capture the difference between
man
and usingless
normally. – Ash – 2012-12-21T05:37:15.357