开发者

Open Vim From PHP CLI

How do you open up vim from a CLI like svn and git do when you drop -m from commit commands?

I'm getting the follow error: Vim: Warning: Output is not to a termin开发者_JAVA技巧al

`echo "Please edit this file" > file.name`;
`vim file.name`;


PHP Doesn't automatically pass thru the STDIN/STDOUT streams, you need to do it manually:

`echo "Please edit this file" > file.name`;
system("vim file.name > `tty`");

(Note: I don't really understand what I'm talking about, I just know the above works.)


Hi this is a example using proc_open in PHP, only runs in systems with /dev/tty (Linux/OSX)

<?php

$descriptors = array(
        array('file', '/dev/tty', 'r'),
        array('file', '/dev/tty', 'w'),
        array('file', '/dev/tty', 'w')
);

$process = proc_open('vim', $descriptors, $pipes);


EDIT:

I just realized it sounds like you already have this set up for svn/git... what are you trying to open it from?


for bash: export SVN_EDITOR=vim although EDITOR will work as well, though this will influence other things as well. IF for some reason vim isnt on your path youll need to use the full path as well. Place this in your .profile or .bash_profile.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜