NOLFXceptMe
NOLFXceptMe

Reputation: 232

zsh function screws up prompt after exit

I use oh-my-zsh for customization and the prompt looks like this

┌─[naveen@bblpt005] - [~] - [Wed Jan 11, 03:16]
└─[$] <> 

I have defined a function in my .zshrc to find files and open them in Vim.

vf() {
     find . -name "$*" | xargs vi;
}

The function works as expected, but when I exit Vim, the prompt is screwed up, and shows up as

┌─[naveen@bblpt005] - [~] - [Wed Jan 11, 03:20]
                                           └─[$] <> 

Ctrl-D and other Ctrl-key combinations stop working as well. I have to fix it using the reset command.

How do I modify the function so that this does not happen?

Upvotes: 2

Views: 530

Answers (1)

Celada
Celada

Reputation: 22261

When you run a command under xargs, its stdin is connected to /dev/null. vi is probably not expecting this. A text editor should normally be run without I/O redirection. Try this and see if it has the same effect on your terminal. I bet it does:

vi somefile </dev/null

You will want to work around this by using something other than xargs. Like this maybe:

vi $(find . -name "$*")

Upvotes: 4

Related Questions