10

在eshell中用cat命令显示图片

 3 years ago
source link: https://www.lujun9972.win/blog/2020/02/15/%E5%9C%A8eshell%E4%B8%AD%E7%94%A8cat%E5%91%BD%E4%BB%A4%E6%98%BE%E7%A4%BA%E5%9B%BE%E7%89%87/index.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

在eshell中用cat命令显示图片

今天偶然发现,在开启了 auto-image-file-mode 后,在eshell中cat 图片文件会直接显示图片,而不是二进制的文件内容。

screenshot-29.png

可惜就是最后缺少了个换行符.

我们也可以自己定义一个自己的icat来专门显示图片:

(defun eshell/icat (&rest args)
    "Display images in ARGS."
    (setq args (eshell-stringify-list (eshell-flatten-list args)))
    (eshell-eval-using-options
     "icat" args
     '((?h "help" nil nil "show this usage screen")
       :external "feh"
       :show-usage
       :usage "IMAGES

    Show IMAGE to standard output.")
     (dolist (image-fpath (mapcar #'expand-file-name args))
       (when (file-exists-p image-fpath)
         (eshell-buffered-print "\n")
         (add-text-properties 0 (length image-fpath)
                              `(display ,(create-image image-fpath)
                                        modification-hooks
                                        (iimage-modification-hook))
                              image-fpath)
         (eshell-buffered-print image-fpath)
         (eshell-flush)))))
eshell/icat


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK