在 Nautilus 中,当您双击一个文件时,它将使用与文件扩展名关联的默认应用程序打开它。例如,.html 文件将在 Web 浏览器中打开,而 .pdf 将使用文档查看器打开。有没有办法从命令行(即open path/filename)中重现相同的行为?我问是因为我喜欢从命令行浏览我的文件系统,但有时不记得哪个应用程序。打开什么。
ane*_*hep 284
我认为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.
Run Code Online (Sandbox Code Playgroud)
例如: xdg-open index.php
这将在 gedit 中打开 index.php(如果您使用的是 gnome)。
如果你想在浏览器中打开一个 url
xdg-open http://google.com
Run Code Online (Sandbox Code Playgroud)
这将在您的默认浏览器中打开 google.com。
xdg-open是一个包装脚本-它将使用桌面环境的工具(gio open,gvfs-open,kde-open,gnome-open,dde-open,exo-open,和其他此类工具的主机)。它也是默认安装的,并且很可能适用于过去、当前和未来的版本(另一方面,gvfs-open它gnome-open已被弃用,可能在未来版本中不可用)。
jes*_*ght 17
如果你想:
open)你可以使用这个.bashrc 函数:
function open () {
xdg-open "$@">/dev/null 2>&1
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
141304 次 |
| 最近记录: |