What is a quick way to edit a remote file on Linux?

巧了我就是萌 提交于 2019-12-03 16:27:13

Force Pseudo-TTY Allocation

You can force pseudo-tty allocation with one or more -t flags. The SSH(1) man page says:

 -t      Force pseudo-tty allocation.  This can be used to execute arbi-
         trary screen-based programs on a remote machine, which can be
         very useful, e.g. when implementing menu services.  Multiple -t
         options force tty allocation, even if ssh has no local tty.

Example

Using your own example, slightly modified, the following would work if you have a local TTY or PTY:

ssh -t user1@computer1 'vim /path/laboratory_notebook_1.md'

It works fine for me with OpenSSH_6.2p2. Your mileage (and operating environment) may vary.

If you are using vim. Vim comes with a plugin called netrw which will allow you to do this.

vim scp://hostname/path/to/file

Will copy the file to you local machine and on save reupload it.

Take a look at netrw's documentation :h netrw

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!