「求助」 shell-command 运行 shell 命令会卡死

  (defun cycoe/create-image-dir (&optional image-dir)
    (interactive)
    (let ((dir (or image-dir (car (split-string (buffer-name (current-buffer)) "\\.")))))
      (if (file-exists-p dir)
          (message "directory ./%s is exists!" dir)
        (make-directory-internal dir))
      dir))

  (add-hook 'org-mode-hook 'cycoe/create-image-dir)

  (defun org-insert-clipboard-image ()
    (interactive)
    (let ((filepath (concat
                     (cycoe/create-image-dir)
                     (make-temp-name
                      (concat "/Screenshot_" (format-time-string "%Y%m%d_%H%M%S_")))
                     ".png")))
      (shell-command (concat "xclip -selection clipboard -t image/png -o > /dev/null && xclip -selection clipboard -t image/png -o > " filepath))
      (when (file-exists-p filepath)
        (insert (concat "[[file:" filepath "]]")))))

如上所示,当剪贴板里没有图片时运行 org-insert-clipboard-image 会卡死,但是在命令行直接运行 xclip -selection clipboard -t image/png -o > /dev/null && xclip -selection clipboard -t image/png -o > test.png 则没问题,有大佬知道怎么解决吗

M-! 运行同样命令会不会卡死?

也是一样的,不过刚刚重启 Emacs 就好了 :rofl: amazing

我碰见过卡死的情况是 zsh和pyenv同时存在造成的,不知道你这儿适不适用?