在Nautilus中,当您双击一个文件时,它将使用与该文件的扩展名关联的默认应用程序将其打开。例如,.html文件将在网络浏览器中打开,.pdf将用Document Viewer打开。有没有办法从命令行(即open path/filename
)内重现相同的行为?我之所以问是因为我喜欢从命令行浏览我的文件系统,但有时不记得是哪个应用程序。打开什么。
我认为这xdg-open
是您正在寻找的命令。
NAME
xdg-open - opens a file or URL in the user's preferred application
SYNOPSIS
xdg-open {file | URL}
xdg-open {--help | --manual | --version}
DESCRIPTION
xdg-open opens a file or URL in the user's preferred application. If a
URL is provided the URL will be opened in the user's preferred web
browser. If a file is provided the file will be opened in the preferred
application for files of that type. xdg-open supports file, ftp, http
and https URLs.
例如: xdg-open index.php
这将在gedit中打开index.php(如果您使用的是gnome)。
如果要在浏览器中打开网址
xdg-open http://google.com
这将在您的默认浏览器中打开google.com。
xdg-open
是一个包装脚本-它将使用桌面环境的工具(gio open
,gvfs-open
,kde-open
,gnome-open
,dde-open
,exo-open
,和其他此类工具的主机)。它也被默认安装的,并且很可能在过去,现在和未来版本的工作(在另一方面,gvfs-open
并且gnome-open
已被弃用,并且可能在以后的版本中不可用)。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句