简体   繁体   English

Bash / 打开一个终端,运行命令作为参数传递

[英]Bash / open a terminal with a command to run passed as an argument

I created a script that starts all the apps I need for my day and assign them to the workspaces I want.我创建了一个脚本,用于启动我一天所需的所有应用程序,并将它们分配到我想要的工作区。

I'd like to know is there was a way to pass an argument to the terminal I open.我想知道是否有办法将参数传递给我打开的终端。 The argument would be an alias that runs a massive source update of all the projects I'm working on.该参数将是一个别名,它运行我正在处理的所有项目的大量源代码更新。

I'd like to do something like this:我想做这样的事情:

gnome-terminal start_rolls

Unfortunately, this only opens the terminal and the command is simply not run.不幸的是,这只会打开终端,而命令根本没有运行。

Any ideas ?有什么想法吗? Thanks in advance !提前致谢!

Rolf罗尔夫

PS: the -e option does not work with aliases, it seems... PS:-e 选项不适用于别名,似乎...

gnome-terminal --help-terminal-options says: gnome-terminal --help-terminal-options说:

-e, --command Execute the argument to this option inside the terminal -e, --command 在终端内执行此选项的参数

-e ”、“ bash -c ”、“ bash -i ”和您的别名的某种组合可能会有所帮助

-e is going to be deprecated in future releases you should use something like this: -e 将在未来的版本中被弃用,你应该使用这样的东西:

gnome-terminal -- bash -c "vim Main.java" gnome-terminal -- bash -c "vim Main.java"

you can replace "vim Main.java" for whatever you want您可以根据需要替换“vim Main.java”

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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