代码之家  ›  专栏  ›  技术社区  ›  Logan Bailey

从php cli打开vim

  •  2
  • Logan Bailey  · 技术社区  · 14 年前

    当您从commit命令中除去-m时,如何从类似svn和git的cli中打开vim?

    我得到以下错误:vim:警告:输出不到终端

    `echo "Please edit this file" > file.name`;
    `vim file.name`;
    
    3 回复  |  直到 11 年前
        1
  •  4
  •   too much php    14 年前

    php不会自动传递stdin/stdout流,您需要手动传递:

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

    (注:我不太明白我在说什么,我只知道上面的工作。)

        2
  •  0
  •   prodigitalson    14 年前

    编辑 :

    我刚意识到你好像已经为svn/git设置了这个…你想从哪里打开它?


    巴什: export SVN_EDITOR=vim 虽然 EDITOR 也会起作用,尽管这也会影响到其他事情。如果因为某种原因Vim不在你的路径上,你也需要使用完整的路径。把这个放在你的 .profile .bash_profile .

        3
  •  0
  •   mcuadros    11 年前

    嗨,这是一个在PHP中使用proc_open的示例,仅在具有/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);