1

From this question: bash - automatically capture output of last executed command into a variable I used this command:

PROMPT_COMMAND='LAST="`cat /tmp/x`"; exec >/dev/tty; exec > >(tee /tmp/x)'

It works, but when I use Vim I get this:

# vim
Vim: Warning: Output is not to a terminal

Then Vim opens. But it takes a while. Is there a way to get rid of this message and the slowdown?

Also when I list dir and I echo $LAST it removes the return lines (\n). Is there a way to keep the return lines (\n)?

Community
  • 1
  • 1
jnbdz
  • 4,863
  • 9
  • 51
  • 93

1 Answers1

1

I think what you ask for is hard do achieve. Vim tests if the output is a terminal. The command you've provided redirects the output to the tee command. tee saves its input (which also menans: command's output) to the file and outputs it to the terminal. But vim knows nothing about it. It only knows its output is not a terminal. So it outputs warning. And from the vim's source code:

[...]
if (scriptin[0] == NULL)
    ui_delay(2000L, TRUE);
TIME_MSG("Warning delay");

which means this redirection will always get you 2 seconds delay.

Also, for example, man vim command will not work with such redirections, because terminal output has some attributest (e.g. width and height) which generic file hasn't. So... it won't work.

nsilent22
  • 2,763
  • 10
  • 14