简体   繁体   中英

Run Emacs on startup on system with no XServer

I want to run Emacs after logging into bash as user. But also I want to be able to jump back into the bash prompt if I press CTRL-Z.

I have tried a couple of settings of .bashrc and .profile:

emacs

eval 'emacs'

bash -c emacs

exec emacs -nw

The problem is that all of this variants make CTRL-Z drop me not to bash prompt , but to empty stdin, like bash prompt was not loaded yet. Any ideas? Thanks.

Thanks to Mark Plotnick, who answered below in comments. Using ioctl you can write to own tty. c program:

#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;
}

compile: gcc my_ioctl.c -o my_ioctl

very end of .profile:

~/my_ioctl $(tty) emacs rr

(my c program does not care about what 3rd arg's actually is).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM