我想在以用户身份登录 bash 后运行 Emacs。 但我也希望能够在按下 CTRL-Z 时跳回 bash 提示符。
我尝试了一些 .bashrc 和 .profile 的设置:
emacs
eval 'emacs'
bash -c emacs
exec emacs -nw
问题是所有这些变体都使 CTRL-Z 使我不进入 bash 提示符,而是进入空标准输入,就像尚未加载 bash 提示符一样。 有任何想法吗?谢谢。
最佳答案
感谢 Mark Plotnick,他在下面的评论中做出了回答。使用 ioctl,您可以写入自己的 tty。 C程序:
#include "unistd.h"
#include "stdlib.h"
#include "stdio.h"
#include "sys/stat.h"
#include "sys/types.h"
#include "fcntl.h"
#include "termios.h"
#include "sys/ioctl.h"
int main(int argc, char ** argv)
{
if (argc >= 3)
{
int fd = open (argv[1], O_RDWR);
if (fd)
{
char * cmd = argv[2];
while(*cmd)
ioctl(fd, TIOCSTI, cmd++);
if (argc >= 4)
ioctl(fd, TIOCSTI, "\r");
return 0;
}
else
printf("could'n open file\n");
}
else
printf("wrong args\n");
return -1;
}
编译: gcc my_ioctl.c -o my_ioctl
.profile 的末尾:
~/my_ioctl $(tty) emacs rr
(我的 C 程序不关心第三个参数实际上是什么)。
关于linux - 在没有 XServer 的系统上启动时运行 Emacs,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45078129/