Open gnome terminal programmatically and execute commands after bashrc was executed

后端 未结 5 1071
终归单人心
终归单人心 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 00:59

    Here is a nice trick we worked out at Superuser

    1. Add a eval "$BASH_POST_RC" to the end of your .bashrc

    2. Set the BASH_POST_RC environment variable for each tab to that command you like to execute, e.g.: gnome-terminal --working-directory="/home/zardoz/projects/my_rails_app" --tab -e 'bash -c "export BASH_POST_RC=\"rails server\"; exec bash"' --tab -e 'bash -c "export BASH_POST_RC=\"autotest\"; exec bash"'

    @Gilles: Thanks for that solution!

提交回复
热议问题