简体   繁体   English

gnome-terminal命令可从命令行运行,但不能从Cinnamon快捷方式(或脚本)运行

[英]gnome-terminal command works from command line but not from Cinnamon shortcut (or script)

I am using Linux Mint 17 and Google Chrome. 我正在使用Linux Mint 17和Google Chrome。

I often check the weather before going out walking; 我经常在走出去之前先检查一下天气。 to do this I surf to http://www.mwis.org.uk/scottish-forecast/EH/ where I then have to click on the PDF doc to see the isobar weather map. 为此,我浏览到http://www.mwis.org.uk/scottish-forecast/EH/ ,然后单击PDF文档以查看等压线天气图。

I thought to shorten this process so that the current PDF can be displayed with a simple keyboard shortcut; 我认为可以缩短此过程,以便可以使用简单的键盘快捷键显示当前的PDF。 I've assigned windows key + F8 to this task. 我已将Windows键+ F8分配给此任务。 However it's not working using gnome-terminal. 但是,使用gnome-terminal无法正常工作。

I have something wrong with my gnome-terminal syntax, and after some level of googling I'm not really sure what it is. 我的gnome-terminal语法有问题,经过某种程度的谷歌搜索后,我不确定它是什么。

So, the following does not work, as a shortcut, or when called from a script. 因此,以下内容不能用作快捷方式或从脚本中调用时。

gnome-terminal -x bash -c myvar=$(curl http://www.mwis.org.uk/scottish-forecast/EH | grep EH-MWI | grep -o -P '(?<=forecasts/).*(?=" target)'); google-chrome http://www.mwis.org.uk/pdf/weather-forecasts/$myvar

.. but it does work when placed directly in the command line. ..但是当直接放在命令行中时它确实可以工作。

(I started on the command line with (我从命令行开始

myvar=$(curl http://www.mwis.org.uk/scottish-forecast/EH | grep EH-MWI | grep -o -P '(?<=forecasts/).*(?=" target)')
google-chrome http://www.mwis.org.uk/pdf/weather-forecasts/$myvar

which does exactly what it is supposed to.) 完全符合预期。)

Can anyone suggest the correct shortcut gnome-terminal command for Cinnamon? 谁能为Cinnamon建议正确的快捷方式gnome-terminal命令?

The argument to bash -c needs to be a single quoted string ("single" as in "one unit", not necessarily specifically within single quotes). bash -c的参数必须是一个单引号字符串(如“一个单位”中的“单引号”,不一定特别是在单引号中)。

bash -c 'google-chrome http://www.mwis.org.uk/pdf/weather-forecasts/"$(curl http://www.mwis.org.uk/scottish-forecast/EH | grep EH-MWI | grep -o -P "(?<=forecasts/).*(?=\" target)")"'

I had to change some single quotes to double, as the whole quoted argument obviously cannot contain single quotes (though you could pass it double-quoted instead, or individually backslash-escape each shell metacharacter). 我必须将某些单引号更改为双引号,因为整个引号的参数显然不能包含单引号(尽管您可以将其改为双引号,或单独反斜杠转义每个shell元字符)。

I also factored out the variable. 我还考虑了变量。

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

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