Open gnome terminal programmatically and execute commands after bashrc was executed

后端 未结 5 1049
终归单人心
终归单人心 2020-12-29 00:21

I try to build a little script to start my development environment. For that task I try to open a gnome terminal with several tabs where automatically the rails server and a

5条回答
  •  借酒劲吻你
    2020-12-29 01:07

    Stab in the dark: create shell scripts for each command you want to run in a tab, make them executable, and invoke them by absolute path, e.g. put this in /home/zardoz/bin/railsstart

    #! /bin/sh
    exec rails server
    

    chmod +x it, and then do

    gnome-terminal --tab -e /home/zardoz/bin/railsstart --tab --tab ...
    

    If that doesn't work, the next thing I would try is sticking strace -f -o /tmp/trace.log on the beginning of the command, letting it fail, and then digging through trace.log to find out which system call actually failed and why (there'll be a tremendous amount of junk in there - read from the end backward and look for all-capitalized code phrases starting with E, like "ENOEXEC", "ENOENT", "EPERM", sort of thing.)

    EDIT: Here's how you pull in all the .bashrc settings in one of these scripts:

    #! /bin/bash
    . ~/.bashrc
    exec rails server
    

    Caution: you may need to adjust your .bashrc so that it doesn't do certain things that only work in a "real" interactive shell session. Don't worry about this unless you get strange errors before rails starts.

提交回复
热议问题