How to suppress "Input is not from a terminal" message?

360 views
Skip to first unread message

Igor

unread,
Sep 24, 2021, 3:36:50 AM9/24/21
to vim_use
Hi,
I would like to embed vim code inside bash script.

I have simple text file text_file.txt with content:
aaa

Content sample.sh file:
#!/bin/bash
echo "Start running vim commands inside bash program."
vim +"so dummy.vim" << EOF
   :e text_file.txt
   :s/a/b/
   :x
EOF
echo "End of running run vim commands inside bash program."


Above code opens text_file.txt, replaces letter a with b and saves the file.
When I run sample.sh file from shell: ./sample.sh
The output on terminal is:
Start running vim commands inside bash program.
Vim: Warning: Input is not from a terminal
End of running run vim commands inside bash program.

and script does get executed, so file text_file.txt correctly gets changed to baa
The only little bit annoying thing is the Vim: Warning: Input is not from a terminal message in terminal. How to suppress this message?
Thanks.

Andreas Perstinger

unread,
Sep 24, 2021, 8:58:51 AM9/24/21
to vim...@googlegroups.com
On 24.09.21 09:36, Igor wrote:
> Content sample.sh file:
> #!/bin/bash
> echo "Start running vim commands inside bash program."
> vim +"so dummy.vim" << EOF
> :e text_file.txt
> :s/a/b/
> :x
> EOF
> echo "End of running run vim commands inside bash program."
...
> The only little bit annoying thing is the *Vim: Warning: Input is not from
> a terminal* message in terminal. How to suppress this message?

Start vim in Ex-mode?

vim +"so dummy.vim" -e << EOF

Bye, Andreas

aro...@vex.net

unread,
Sep 24, 2021, 10:21:44 AM9/24/21
to vim...@googlegroups.com
>
> I would like to embed vim code inside bash script.
>

Have you considered using sed, which was designed for this sort of job.
rather than twisting vim inside out?


Tony Mechelynck

unread,
Sep 25, 2021, 9:30:42 AM9/25/21
to vim_use
See :help --not-a-term

Best regards,
Tony.

Igor

unread,
Sep 26, 2021, 1:16:53 PM9/26/21
to vim_use
Thank you very much for your answers.

I changed line from:
vim +"so dummy.vim" << EOF
to line
vim +"so dummy.vim" -e << EOF
and "annoying" message is suppressed, like I wanted.

Just additional question.
Does -e switch has some negative side effect, like some commands not working or working differently like in standard vim?
I am reading about about "Ex mode" (-e switch) and "Improved Ed mode" (-E switch).
Reply all
Reply to author
Forward
0 new messages