After doing grep and passing it to vim and then leaving, why am I experiencing this weird console?

I tried this now:

grep -RlI "id=\"kw\"" * | xargs vim

This gave me 16 results. He discovered the first result in Vim. I did my first editing and clicked :qbecause I did not know the shortcut to go to the next file.

He threw me to the console (I am connected to the SSHed server). Now my console is confused. All that I type, I don’t see, and whenever I press the enter button, it seems that it is processing the command, but the display / view is screwed, so

[meder@linode]displayed on my console at least halfway. resetdoes nothing, because it seems that he ruined my real console.


Can anyone suggest a solution that does not have the same drawback? Or can someone explain why :qmy console was spoiled from the very first file?


Background information . My computer is DebianUbuntu, I SSHed in the RHEL field. The files I opened were ascii phtml / php file / file files, not some weird binaries with crazy characters in them.

Here is a screenshot of what happened

EDIT # 1: I just typed resetagain and it seemed to work. The first one resetdid not work, I think, because somehow the console was inserting some nameless character into it? In any case, I would like to explain this strange behavior.

+1
source share
6

Try:

vim -o `grep -RlI "id=\"kw\"" * `
+3

man xargs:

     Undefined behavior may occur if utility reads from the standard input.

Linux, Mac. , , linux xargs :

   OPTIONS
       --arg-file=file, -a file
              Read items from file instead of standard input.
              If you use this option, stdin remains unchanged
              when commands are run.  Otherwise, stdin is
              redirected from /dev/null.

Vim , , ( ) -. , .

, , , xargs vim . , vim , .

, , , . ssh , ssh "ps", , -, , (1).

+2

:next :n, . vim -o, Vim.

, . , .

+1

stty, bash vim, :

function vim()
{
    STTYOPTS="$(stty --save)"
    vim "$@"
    stty "${STTYOPTS}"
}

, , zsh : ttyctl -f ~/.zshrc, zsh . ttyctl zsh builtin, bash.

+1

, . , , , , Vim xargs , . , , , , , . , .

, . vimgrep , ?

:vimgrep /id="kw"/ *
:copen

id="kw" . :copen . , "Enter", .

enter image description here

.

:help grep
:help :vimgrep
:help :copen
:help quickfix

If you really need a parameter -I, see

:help :grep
:help 'grepprg'

See also: Vim: Warning: non-terminal login

+1
source

Try using ... | xargs sh -c '...'it and then read from the controlling terminal device /dev/tty.

echo ~/.profile ~/.bashrc | xargs sh -c 'vim "$@" </dev/tty' dummy_script_name

# based on a tip by Laszlo Ersek on http://unix.derkeiler.com/Newsgroups/comp.unix.programmer/2010-03/msg00051.html
#find . -maxdepth 1 -type f | xargs sh -c 'rm -i "$@" </dev/tty' dummy_script_name
+1
source

All Articles