1---2title: "SSH 快捷运行 TUI 程序"3date: 2022-10-04T11:22:11+08:004---56我平时有用 weechat 看 IRC 的习惯,使用方式是:71. ssh 到 ( 用 tmux ) 运行着 weechat 的服务器。82. 运行 `tmux -L weechat attach` 命令。910每次都要这么两步,觉得很麻烦,想试试在 ssh config 添加配置来自动执行。1112于是我的 ssh 配置多了这么一条13```14Host irc15 HostName my_weechat_server16 User lindsay17 Port 222221819 # 连接成功后执行的命令,20 # exec 是为了 weechat 退出后自动断开 ssh ,详细请看 man exec(n)21 RemoteCommand exec tmux -L weechat attach2223 # weechat 必须要有 TTY/PTY 才能运行24 RequestTTY yes25```2627其他 TUI 应用也同样适用,比如运行 neomutt28```29Host mail30 HostName localhost31 RemoteCommand exec neomutt32 RequestTTY yes33```34如果不想污染 `~/.ssh/config` 文件,可以将这类配置另外保存一个文件,然后在 ~/.ssh/config 中添加一行 `include <your_ssh_tui_config_path>`