【shell命令】关于mac的open命令

简介: mac下的命令小工具。
+关注继续查看

加班中,在调研函数计算,使用nodejs做一个demo的时候,在比较深的路径下下载了一张图片。

不想用finder逐层文件夹寻找,而是希望直接打开,顺手敲了一下open 1.png命令,果然打开了。

which open看一下位置,果然是mac系统自带,位于/usr/bin/open。

open -h查看提示:

demo $ open -h
Warning: Xcode platforms folder not found at "/Library/Developer/CommandLineTools". You may have invalid DEVELOPER_DIR or stale xcode-select setting.
Usage: open [-e] [-t] [-f] [-W] [-R] [-n] [-g] [-h] [-s <partial SDK name>][-b <bundle identifier>] [-a <application>] [filenames] [--args arguments]
Help: Open opens files from a shell.
      By default, opens each file using the default application for that file.  
      If the file is in the form of a URL, the file will be opened as a URL.
Options: 
      -a                Opens with the specified application.
      -b                Opens with the specified application bundle identifier.
      -e                Opens with TextEdit.
      -t                Opens with default text editor.
      -f                Reads input from standard input and opens with TextEdit.
      -F  --fresh       Launches the app fresh, that is, without restoring windows. Saved persistent state is lost, excluding Untitled documents.
      -R, --reveal      Selects in the Finder instead of opening.
      -W, --wait-apps   Blocks until the used applications are closed (even if they were already running).
          --args        All remaining arguments are passed in argv to the application's main() function instead of opened.
      -n, --new         Open a new instance of the application even if one is already running.
      -j, --hide        Launches the app hidden.
      -g, --background  Does not bring the application to the foreground.
      -h, --header      Searches header file locations for headers matching the given filenames, and opens them.
      -s                For -h, the SDK to use; if supplied, only SDKs whose names contain the argument value are searched.
                        Otherwise the highest versioned SDK in each platform is used.

根据提示内容,可知open就是从命令行执行打开。包括本地文件和远程文件(浏览器打开)。

关于使用参数和一些常用的应用、网站等打开方式:

1、 open -a

open -a qq

2、打开网页

open https://www.zhihu.com/

3、open -f

从标准输入中读取输入内容,并通过文本编辑器打开。

示例: ls |open -f

image

相关文章
|
25天前
|
数据可视化 应用服务中间件 nginx
Mac使用命令可视化编辑文件(open命令)
Mac使用命令可视化编辑文件(open命令)
11 0
|
3月前
|
移动开发 Unix Linux
sed命令在Mac和Linux下的不同
sed命令在Mac和Linux下的不同
26 0
|
3月前
|
Linux iOS开发 MacOS
Mac用户注意了,你的sed命令...
Mac用户注意了,你的sed命令...
|
10月前
mac 安装软件后重启终端,刚才安装的命令都提示找不到
mac 安装软件后重启终端,刚才安装的命令都提示找不到
|
10月前
|
固态存储 网络安全
两台 mac 通过 scp 命令快速传输数据
两台 mac 通过 scp 命令快速传输数据
两台 mac 通过 scp 命令快速传输数据
|
11月前
MAC查看系统版本的命令
MAC查看系统版本的命令
74 0
|
11月前
MAC使用find命令的正确办法
MAC使用find命令的正确办法
266 0
|
11月前
|
Shell TensorFlow 算法框架/工具
Mac切换普通conda和miniforge conda命令
Mac切换普通conda和miniforge conda命令
Mac切换普通conda和miniforge conda命令
|
11月前
|
Java Shell Maven
mac安装maven后mvn命令可用,一段时间后又遇到zsh: command not found: mvn的问题
mac安装maven后mvn命令可用,一段时间后又遇到zsh: command not found: mvn的问题
559 0
mac安装maven后mvn命令可用,一段时间后又遇到zsh: command not found: mvn的问题
|
开发工具 git
mac终端git命令中英文切换
mac终端git命令中英文切换
491 0
相关产品
云迁移中心
推荐文章
更多