问题描述
我希望我的tcsh脚本启动一个编辑器(例如vi,emacs):
I would like my tcsh script to launch an editor (e.g., vi, emacs):
#!/bin/tcsh
vi my_file
这将以my_file启动vi,但首先显示警告"Vim:警告:输出未到终端",并且我的击键也未出现在屏幕上.杀死vi后,我的终端窗口被弄乱了(没有换行符),需要重置".我尝试了"emacs -nw","xemacs -nw"和pico,结果相似."xemacs"有效,但会启动一个单独的窗口.我想重用相同的终端窗口.
This starts up vi with my_file but first displays a warning "Vim: Warning: Output is not to a terminal" and my keystrokes don't appear on the screen. After I kill vi, my terminal window is messed up (no newlines), requiring a "reset". I tried "emacs -nw", "xemacs -nw", and pico with similar results. "xemacs" works but launches a separate window. I want to reuse the same terminal window.
是否可以通过脚本启动编辑器,以使其重用同一终端窗口?
Is there a way to launch an editor from a script so that it reuses the same terminal window?
推荐答案
我回答了我自己的问题!您必须重定向终端输入和输出:
I answered my own question! You have to redirect terminal input and output:
#!/bin/tcsh
vi my_file < `tty` > `tty`
这篇关于如何从Shell脚本启动编辑器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!