2011-07-27 2 views

답변

19

예. dired에서 파일에 쉘 명령을 실행하려면 !을 사용하십시오.

evince의 경우 &을 사용하는 것이 더 효율적입니다.이 명령은 비동기 적으로 명령을 실행하므로 PDF를 열어 두어도 이맥스를 사용할 수 있습니다.

3

!을 사용하여 파일을 열고 명령을 지정할 수 있습니다.

+4

해당 명령을 비동기 적으로 실행하려면'! '대신'&'를 사용하십시오. – Thomas

14

더 많은 방법이 있습니다. 나는 OpenWith 도서관을 제안한다. 귀하의 경우에 대한 설정처럼 보일 수 있습니다 :

(add-to-list 'load-path "/path/to/downloaded/openwith.el") 
(require 'openwith) 
(setq openwith-associations '(("\\.pdf\\'" "evince" (file)))) 
(openwith-mode t) 

그것은 diredfind-file 모두에서 작동합니다 파일 핸들러를 설정합니다.

+3

적어도 Mac OSX에서는'evince'를'open'으로 바꾼 다음 기본 소프트웨어 (제 경우에는 "Skim")를 사용합니다. – Dror

+3

이 경우 쉘 명령을 실행하기 위해'!'또는'&'를 사용하는 대신 dired에서 파일 이름에 대해'RET'을 누르십시오.또한 openwith-associations에서 setq를 사용하여 모든 내장 된 연결을 잃게됩니다. .mp3, .jpg, ...에 대한 연관성을 유지하면서 pdf 연관 만 변경하는 더 좋은 방법이 있을지도 모릅니다. –

+0

예, 다른 사람들을 잃지 않고 pdf 연결을 변경하는 쉬운 방법이 있습니다. M-x customize-group RET open with RET – Jorge

8

시도해보십시오. 당신이 dired에 하나의 파일에 nohup [위키 백과]를 사용하여 이맥스를 종료 한 후 살아 과정을 유지, 그래서 포인트를 넣을 수 있습니다

(defun dired-open-file() 
    "In dired, open the file named on this line." 
    (interactive) 
    (let* ((file (dired-get-filename nil t))) 
    (message "Opening %s..." file) 
    (call-process "gnome-open" nil 0 nil file) 
    (message "Opening %s done" file))) 
+3

이것은 훌륭하게 작동했습니다. KDE와 같은 다른 GUI에서 사용하는 경우'gnome-open'을'xdg-open'으로 대체합니다. –

0

OSX 상자의 dired-mode에서 외부 응용 프로그램을 열고 사용자가 외부 응용 프로그램에서 열려고하는 파일이있는 줄에 커서가있을 때 C-c o의 키보드 바로 가기를 사용합니다. 두 번째 dired 버퍼는 /Applications 폴더로 열리고 enter 키는 외부 응용 프로그램을 선택합니다. [여러 파일을 선택하는 것은이 답변의 범위를 벗어납니다. 그러나 관심이있는 경우를 대비하여 dired-get-marked-files에 대한 정의를 포함 시켰습니다. Finder.app 또는 Dock.app 또는 Spotlight와 같은 것을 사용하는 대안으로 외부 응용 프로그램을 여는 옵션도 포함되어 있습니다 - /Applications 폴더에서 dired에있는 RET 키는 사용자에게 응용 프로그램은 외부 또는 패키지 응용 프로그램 폴더에 입력]

두 번째 방법은 조건을 설정하는 (equal (file-name-extension input-filename) ".pdf")) 같은 것을 사용하여 선택한 파일을 열 수있는 특정 외부 프로그램을 활성화 start-process . . .을 사용하는 것입니다 -., (start-process "pdf-with-skim" nil "open" "-a" "/Applications/Skim.app/Contents/MacOS/Skim" input-filename)는 예를. 이는 하위 선택 사항 (예 : Adobe, Skim 또는 Preview)을 사용하여 매우 정교하게 만들 수 있으며 string-match 함수 또는 다양한 파일 확장자를 사용할 수도 있습니다. 이 두 번째 접근법은 설치된 특정 프로그램을 기반으로 사용자의 개인 취향에 맞게 조정되지만 첫 번째 옵션 (아래)은 설치된 외부 응용 프로그램에 액세스하는 데 사용할 수 있습니다.

(require 'dired) 

(defun dired-read-file-name (&optional directory) 
    (if directory 
     (dired directory) 
    (dired nil)) 
    (let (output-filename) 
     (recursive-edit) 
     output-filename)) 

;; Open with external application. 
(defvar open-with-variable nil) 
(define-key dired-mode-map (kbd "C-c o") (lambda() (interactive) 
    (setq open-with-variable t) 
    (let* (
     (lawlist-filename (dired-get-file-for-visit)) 
     (application (dired-read-file-name "/Applications"))) 
    (start-process "external" nil "open" "-a" application lawlist-filename) 
    (setq open-with-variable nil)))) 

;; select file or directory. 
(define-key dired-mode-map (kbd "<return>") (lambda() (interactive) 
    (let* (
    (input-filename 
     (if (or (re-search-backward "^*" nil t) 
      (re-search-forward "^*" nil t)) 
     (dired-get-marked-files) 
     (dired-get-file-for-visit))) 
    (dired-buffer-name (buffer-name))) 
    (cond 
    ;; open file 
    ((and (not (file-directory-p input-filename)) 
     (file-exists-p input-filename) 
     (not (equal input-filename (concat (file-name-directory input-filename) "."))) 
     (not open-with-variable)) 
     (kill-buffer dired-buffer-name) 
     (find-file input-filename)) 
    ;; open with external application 
    ((and (file-directory-p input-filename) 
     (not (equal input-filename (concat (file-name-directory input-filename) "."))) 
     open-with-variable 
     (equal (file-name-extension input-filename) "app")) 
     (setq output-filename input-filename) 
     (kill-buffer dired-buffer-name) 
     (throw 'exit nil)) 
    ;; Enter the directory; or, open an application 
    ((and (file-directory-p input-filename) 
     (not (equal input-filename (concat (file-name-directory input-filename) ".")))) 
     (if (equal (file-name-extension input-filename) "app") 
     (progn 
      (message "[o]pen %s" (file-name-nondirectory input-filename)) 
      (let* ((open-or-enter (read-char-exclusive))) 
      (cond 
       ((eq open-or-enter ?o) 
       (start-process "application" nil "open" "-a" input-filename) 
       (kill-buffer dired-buffer-name)) 
       (t 
       (dired-find-file) 
       (goto-char (point-min)) 
       (re-search-forward " \\.\\.$" nil t) 
       (kill-buffer dired-buffer-name))))) 
     (dired-find-file) 
     (goto-char (point-min)) 
     (re-search-forward " \\.\\.$" nil t) 
     (kill-buffer dired-buffer-name))))))) 
1

Windows에서 나는 사용하지 않습니다! PDF/Word/Excel을 열려면 "explorer"명령을 사용하십시오 ...

+0

"시작"도 효과가 있어야하며 짧다고 생각합니다. –