Ubuntu 上通过命令行打开一个文件,类似于 Mac Shell 里的 open

文章目录

    在 Ubuntu 上调试一个图片合成的逻辑,比较麻烦的是,每次改完都要手动打开图片确认效果。

    搜索了一下 Linux 上是否存在同 Mac shell 中 open 同样功能的命令。

    果然有

    xdg-open /tmp/白夜追凶.png
    

    居然还能打开 URL,非常不错。

    NAME
           xdg-open - opens a file or URL in the user's preferred application
    
    SYNOPSIS
           xdg-open {file | URL}
    
    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 is for use inside a desktop session only. It is not recommended to use xdg-open as root.
    

    命令好难记

    Xdg 是 X Desktop Group 的缩写, 官网是 freedesktop.org, 该组织为 Linux/Unix 桌面系统,例如 GNOME, KDE, LXDE 等制定 GUI 标准。

    关于作者 🌱

    我是来自山东烟台的一名开发者,有感兴趣的话题,或者软件开发需求,欢迎加微信 zhongwei 聊聊,或者关注我的个人公众号“大象工具”, 查看更多联系方式