1
user@laptop:~$ locate file.ext | xargs vim -p
Vim: Warning: Input is not from a terminal
2 files to edit
user@laptop:~$ 

After finding files and modifying them in vim I want to save them and continue to work in unix console but I can't do that.

After vim close console just halts. No activity on any keypress. The only workaround is to close console tab and create a new one. How can I solve this problem?

5

try to run it different way:

vim -p `locate file.ext`

or you can try to run reset command after your vim session, to reset terminal options to defaults:

locate file.ext | xargs vim -p; reset
2
  • please accept an answer by putting a checkmark sign under it if it helped you. thank you – zed_0xff Jun 18 '10 at 10:07
  • 1
    Don't use the second one, it's a hack; the first command is the idiomatic and correct way to do it. – msw Jun 18 '10 at 12:21
1

This is what I do, after exiting vim from a piped command on Cygwin.

stty sane {enter}

Of course, you won't see that get typed, but after you hit enter, the tty will come back to life. It's a pain, but works.

I don't like the other solution here because often I am running a much more complex lookup than a file lookup. I might do something like this:

egrep -ri [pattern] * | sed -e 's:\:.*::g' | grep -v ^Binary | sort | uniq | xargs vim

In my work (10 year old fast moving codebase), this kind of search is so common that I have the first five commands in a single shell script that I pipe to vim.

1
  • Couldn't you do vim $(callToBashScript)? – Niels Bom Aug 7 '12 at 14:44
0
Vim: Warning: Input is not from a terminal

A pipe is not a terminal as such, but have you tried fg?

5
  • fg what? there is no background job here – unbeli Jun 18 '10 at 10:01
  • Tried the exact same line in my terminal and got a running Vim process accesible via fg. – matiasf Jun 18 '10 at 10:10
  • Matias, can you please share your command? I haven't heard of fg before. How can I use it? – Anonymous Jun 18 '10 at 10:23
  • "fg" means foreground, swapping a paused process from background to foreground in your terminal. Try "man bash", then pause it by Ctrl-Z. Then issue "fg". – matiasf Jun 18 '10 at 11:04
  • It isn't running in the background, its standard input is attached to the pipe from locate, thus "Input is not from a terminal" is accurate. – msw Jun 18 '10 at 12:20

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.