不幸的是,没有提供通过命令行的名称来调用应用程序的方法。提供此功能将意味着对已安装的应用程序进行不可靠的额外解析,并且有些人会认为这是安全缺陷。但是,您可以使用脚本来自行解析,该脚本会搜索并提取每个扩展/应用程序的名称,直到找到您要搜索的名称:
/usr/local/bin/chrome-app-by-name:
#!/bin/zsh
emulate -R zsh -o extendedglob -o nullglob
setopt rematchpcre ;# recommended, I'm so used to PCRE, I sometimes forget what doesn't work in Regex
Chrome_Profile=Default  ;# or "Profile 1" ...
cd ${XDG_CONFIG_HOME:-$HOME/.config}/google-chrome/${Chrome_Profile}/Extensions
foreach app in */*
   # We have just called the path to each version of each extension/app.
   # Next we enclose in braces - slightly unnecessary - to ensure that
   #  whatever version of Zsh, "manifest.json" is completely read and 
   #  closed before we use the variable.
   {
      App_Manifest="$(cat <$app/manifest.json)"
   }
   if [[ $App_Manifest =~ '^\s*"name"\s*:\s*"([a-zA-Z 0-9_.-]+)"' ]]
   then
      app_name="$match[1]" ;# capture the sub-expression match for "name"
      if [[ $app_name == $1 ]]
      then
         # For my system this is actually exec google-chrome-stable ...
         exec google-chrome --app-id="${app%%/*}" $argv[2,-1]
      fi
   fi
end
echo "App name not found.  Please use Exact, case-sensitive spelling."
有些应用程序在脚本中设置了更深的名称-我不知道为什么!您可能需要重新编写或添加到这样的脚本中,才能在“ .desktop”文件中搜索~/.local/share/applications与上面相同的“ ^ NAME = ...”,然后在此处获取执行命令。
我尚未测试此脚本-我只是即时编写了该脚本来回答您的问题。我希望以此为例对您有用,但是如果您的想法不太正确,我们可以对其进行一些调整。与其他一些sh兼容的shell相比,Zsh是简单的,海峡转发的语法。我已尝试忽略除PCRE之外需要新版本或模块的所有功能。PCRE非常容易用于精确的模式匹配,因此我经常需要忽略大多数正则表达式。更长的Perl脚本可以工作,大多数语法也可以在中不修改地运行/bin/bash。foreach ... end,$match[1]样式数组setopt rematchpcreBash Regex的确切systax emulate是主要例外。
               
              
.desktop文件~/.local/share/applications(在打开的gedit窗口中将其拖动),则可能会在该Exec=行中看到正确的命令。