2017-07-13 51 views
0

我想在以用戶身份登錄到bash後運行Emacs。 但我也希望能夠跳回bash提示符,如果我按CTRL-Z。在沒有XServer的系統上啓動時運行Emacs

我已經嘗試了幾個的.bashrc和.profile文件的設置:

emacs 

eval 'emacs' 

bash -c emacs 

exec emacs -nw 

的問題是,所有這一切都變做CTRL-Z落我不是來砸提示,但空標準輸入,像bash提示符尚未加載。 任何想法?謝謝。

+0

我不能幫你解決你的問題。但你不應該那樣做。混淆登錄過程的結果(例如使用ksh而不是bash或類似的東西)會導致問題。我學了幾次。 :-)但是有人在shell上默認使用emacs讓我回到人類的信心 – mbieren

+0

感謝您的回答。你應該看到我用它的設備(我稱之爲「pocket emacs」和「pocket debugger」)。它的索尼Vaio VGN-P31ZRK。大多數「特殊按鈕」用於綁定) https://pp.userapi.com/c626117/v626117672/31b16/slek7sMxMbk.jpg –

+0

相關:[詢問一個正在運行的bash(交互式)從外部運行命令](https://stackoverflow.com/questions/7370538/ask-a-running-bash-interactive-to-run-a-command-from-outside)和[無法使用termios.TIOCSTI僞造終端輸入](https ://stackoverflow.com/questions/29614264/unable-to-fake-terminal-input-with-termios-tiocsti)。在'.profile'的最後,你可以有一個perl或者python或者c程序發送'emacs \ r'到你的tty,這將使你的shell運行它,就像你輸入它一樣。 –

回答

0

感謝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 -o my_ioctl.c my_ioctl

.profile文件的盡頭:

~/my_ioctl $(tty) emacs rr 

(我的C程序不關心什麼第三個參數的實際是)。

相關問題