tramp
文章目录
tramp-mode
- tutorial: https://www.emacswiki.org/emacs/TrampMode#toc18
- Manual: https://www.gnu.org/software/tramp/
- the Emacs info has a Manual.
- 用途: 远程编辑文件
一般编辑文件
用法:
1 2 3C-x C-f /ssh:username@server.net#Port:path/to/file.txt RET eg: /ssh:sawyer@localhost#13039:~/ --> for directories编辑目录 eg: /ssh:sawyer@localhost#13039:~/book.txt --> for files编辑文本
sudo
用法:
1 2C-x C-f /ssh:username@hostname#Port|sudo:hostname:path/to/file.txt RET eg: /ssh:sawyer@localhost#13039|sudo:localhost:~/book.txt格式
- (/sshx:remote-host)|(sudo:remote-host):(/path/to/file) RET
解析
- /sshx:remote-host : 说明要远程到 remote-host 机器
- sudo:remote-host : 说明要在 remote-host 机器上使用 sudo 权限
- 两组操作通过 "|" 连接起来
ssh + sudo 联用
参考: Open file via SSH and Sudo with Emacs - Stack Overflow
通过 "|" 连接多个 tramp 操作
老用法:
| |
emacs >= 27 新用法:
| |
好处: 少写一次 host(主机名)
windows 上
使用 sshx 和 scpx
zsh + tramp
ssh server 端使用 zsh, 会导致 tramp 卡住(stuck)的问题
参考:
- tramp-mode hangs #3: EmacsWiki: Tramp Mode
解决方法:
简单解决方法:
- 使用 /sshx 而不是 /ssh
- 因为 sshx 使用的是 /bin/sh 而不是 /bin/zsh
- 修改 .zshrc
ssh 卡住问题
使用 sshx 协议可以提升速度
文章作者
上次更新 2023-02-01 (9aed3e4)