使用http://前缀在终端中别名Chrome

问题描述 投票:-2回答:1

我正在尝试向终端添加别名,该别名将允许我说'chrome github.com'并打开我在chrome中提供的网址。

我想在别名中添加http://,因此我可以在URL前面输入不带http://的URL。

这是我现在所拥有的:

alias chrome =“ open -a \” Google Chrome \“ http://”

目前,如果我只叫Chrome,将会打开一个新标签,并使用url(减去http://)将其返回:

文件/Users/name/github.com不存在。

bash macos terminal scripting alias
1个回答
0
投票

只需使用一个类似于别名的功能,它就更加灵活和易读。

chrome() {
       open -a "Google Chrome" http://"$@"
}

alias在调用后添加一个空格。因此,使用您的别名chrome github.comopen -a "Google Chrome" http:// github.com

© www.soinside.com 2019 - 2024. All rights reserved.