Skip to main content
added 89 characters in body
Source Link
Drew
  • 79.1k
  • 10
  • 123
  • 257

Customize option dired-guess-shell-alist-user, then use ! (dired-do-shell-command) to act on a file or directory in a Dired listing. The default action will do what you want, according to your dired-guess-shell-alist-user settings. (You need to load standard libraries dired-aux.el and dired-x.el for this feature.)

C-h v tells you:

dired-guess-shell-alist-user is a variable defined in dired-x.el.

Its value is nil

Documentation:

User-defined alist of rules for suggested commands.

These rules take precedence over the predefined rules in the variable dired-guess-shell-alist-default (to which they are prepended).

Each element of this list looks like

(REGEXP COMMAND...)

where each COMMAND can either be a string or a Lisp expression that evaluates to a string. This expression can access the file name as the variable file.

If several COMMANDs are given, the first one will be the default and the rest will be added temporarily to the history and can be retrieved with M-x previous-history-element (M-) .

The variable dired-guess-shell-case-fold-search controls whether REGEXP is matched case-sensitively.

You can set this variable in your ~/.emacs. For example, to add rules for .foo and .bar files, write

(setq dired-guess-shell-alist-user
    '(("\\.foo\\'" "FOO-COMMAND")
      ("\\.bar\\'"
       (if condition
          "BAR-COMMAND-1"
        "BAR-COMMAND-2"))))

You can customize this variable.

Customize option dired-guess-shell-alist-user, then use ! (dired-do-shell-command) to act on a file or directory in a Dired listing. The default action will do what you want, according to your dired-guess-shell-alist-user settings.

C-h v tells you:

dired-guess-shell-alist-user is a variable defined in dired-x.el.

Its value is nil

Documentation:

User-defined alist of rules for suggested commands.

These rules take precedence over the predefined rules in the variable dired-guess-shell-alist-default (to which they are prepended).

Each element of this list looks like

(REGEXP COMMAND...)

where each COMMAND can either be a string or a Lisp expression that evaluates to a string. This expression can access the file name as the variable file.

If several COMMANDs are given, the first one will be the default and the rest will be added temporarily to the history and can be retrieved with M-x previous-history-element (M-) .

The variable dired-guess-shell-case-fold-search controls whether REGEXP is matched case-sensitively.

You can set this variable in your ~/.emacs. For example, to add rules for .foo and .bar files, write

(setq dired-guess-shell-alist-user
    '(("\\.foo\\'" "FOO-COMMAND")
      ("\\.bar\\'"
       (if condition
          "BAR-COMMAND-1"
        "BAR-COMMAND-2"))))

You can customize this variable.

Customize option dired-guess-shell-alist-user, then use ! (dired-do-shell-command) to act on a file or directory in a Dired listing. The default action will do what you want, according to your dired-guess-shell-alist-user settings. (You need to load standard libraries dired-aux.el and dired-x.el for this feature.)

C-h v tells you:

dired-guess-shell-alist-user is a variable defined in dired-x.el.

Its value is nil

Documentation:

User-defined alist of rules for suggested commands.

These rules take precedence over the predefined rules in the variable dired-guess-shell-alist-default (to which they are prepended).

Each element of this list looks like

(REGEXP COMMAND...)

where each COMMAND can either be a string or a Lisp expression that evaluates to a string. This expression can access the file name as the variable file.

If several COMMANDs are given, the first one will be the default and the rest will be added temporarily to the history and can be retrieved with M-x previous-history-element (M-) .

The variable dired-guess-shell-case-fold-search controls whether REGEXP is matched case-sensitively.

You can set this variable in your ~/.emacs. For example, to add rules for .foo and .bar files, write

(setq dired-guess-shell-alist-user
    '(("\\.foo\\'" "FOO-COMMAND")
      ("\\.bar\\'"
       (if condition
          "BAR-COMMAND-1"
        "BAR-COMMAND-2"))))

You can customize this variable.

Source Link
Drew
  • 79.1k
  • 10
  • 123
  • 257

Customize option dired-guess-shell-alist-user, then use ! (dired-do-shell-command) to act on a file or directory in a Dired listing. The default action will do what you want, according to your dired-guess-shell-alist-user settings.

C-h v tells you:

dired-guess-shell-alist-user is a variable defined in dired-x.el.

Its value is nil

Documentation:

User-defined alist of rules for suggested commands.

These rules take precedence over the predefined rules in the variable dired-guess-shell-alist-default (to which they are prepended).

Each element of this list looks like

(REGEXP COMMAND...)

where each COMMAND can either be a string or a Lisp expression that evaluates to a string. This expression can access the file name as the variable file.

If several COMMANDs are given, the first one will be the default and the rest will be added temporarily to the history and can be retrieved with M-x previous-history-element (M-) .

The variable dired-guess-shell-case-fold-search controls whether REGEXP is matched case-sensitively.

You can set this variable in your ~/.emacs. For example, to add rules for .foo and .bar files, write

(setq dired-guess-shell-alist-user
    '(("\\.foo\\'" "FOO-COMMAND")
      ("\\.bar\\'"
       (if condition
          "BAR-COMMAND-1"
        "BAR-COMMAND-2"))))

You can customize this variable.