linux - 在没有 XServer 的系统上启动时运行 Emacs

标签 linux bash shell unix emacs

我想在以用户身份登录 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/

相关文章:

c++ - 在应用程序中使用 Rsync 和增量传输算法

linux - 为 MJPEG uvc 负载 header 生成 PTS/SCR 值

bash 脚本在获取时产生不同的结果

file - 如何在 Linux 上通过脚本找到文件的编码?

linux - 在 debian wheezy 上运行 autoreconf 和配置所需的软件包

linux - 多个for循环中的sed命令用法

bash - 如何在 Mac Catalina 上对终端输出进行着色

.net - .NET 4.0 的 shell 扩展

bash - 获取给定日期后的下一个星期日 (bash)

python - Python 中程序实例的队列?