]> git.rmz.io Git - dotfiles.git/blob - ranger/rifle.conf
f3476958f33eb3ba9229d581fcf34e1cc49a98c3
[dotfiles.git] / ranger / rifle.conf
1 # vim: ft=cfg
2 #
3 # This is the configuration file of "rifle", ranger's file executor/opener.
4 # Each line consists of conditions and a command. For each line the conditions
5 # are checked and if they are met, the respective command is run.
6 #
7 # Syntax:
8 # <condition1> , <condition2> , ... = command
9 #
10 # The command can contain these environment variables:
11 # $1-$9 | The n-th selected file
12 # $@ | All selected files
13 #
14 # If you use the special command "ask", rifle will ask you what program to run.
15 #
16 # Prefixing a condition with "!" will negate its result.
17 # These conditions are currently supported:
18 # match <regexp> | The regexp matches $1
19 # ext <regexp> | The regexp matches the extension of $1
20 # mime <regexp> | The regexp matches the mime type of $1
21 # name <regexp> | The regexp matches the basename of $1
22 # path <regexp> | The regexp matches the absolute path of $1
23 # has <program> | The program is installed (i.e. located in $PATH)
24 # env <variable> | The environment variable "variable" is non-empty
25 # file | $1 is a file
26 # directory | $1 is a directory
27 # number <n> | change the number of this command to n
28 # terminal | stdin, stderr and stdout are connected to a terminal
29 # X | $DISPLAY is not empty (i.e. Xorg runs)
30 #
31 # There are also pseudo-conditions which have a "side effect":
32 # flag <flags> | Change how the program is run. See below.
33 # label <label> | Assign a label or name to the command so it can
34 # | be started with :open_with <label> in ranger
35 # | or `rifle -p <label>` in the standalone executable.
36 # else | Always true.
37 #
38 # Flags are single characters which slightly transform the command:
39 # f | Fork the program, make it run in the background.
40 # | New command = setsid $command >& /dev/null &
41 # r | Execute the command with root permissions
42 # | New command = sudo $command
43 # t | Run the program in a new terminal. If $TERMCMD is not defined,
44 # | rifle will attempt to extract it from $TERM.
45 # | New command = $TERMCMD -e $command
46 # Note: The "New command" serves only as an illustration, the exact
47 # implementation may differ.
48 # Note: When using rifle in ranger, there is an additional flag "c" for
49 # only running the current file even if you have marked multiple files.
50
51 # Play videos with mpv
52 match ^https?://www.youtube.com/watch\?, has mpv, X, terminal = mpv --profile=mimeo -- $1
53 match ^https?://www.youtube.com/watch\?, has mpv, X, flag f = mpv --profile=mimeo -- $1
54
55 #-------------------------------------------
56 # Websites
57 #-------------------------------------------
58 # Rarely installed browsers get higher priority; It is assumed that if you
59 # install a rare browser, you probably use it. Firefox/konqueror/w3m on the
60 # other hand are often only installed as fallback browsers.
61 ext x?html?, has qutebrowser, X, flag f = qutebrowser -- "$@"
62 ext x?html?, has dwb, X, flag f = dwb -- "$@"
63 ext x?html?, has chromium, X, flag f = chromium -- "$@"
64 ext x?html?, has elinks, terminal = elinks "$@"
65 ext x?html?, has w3m, terminal = w3m "$@"
66
67 #-------------------------------------------
68 # Misc
69 #-------------------------------------------
70 # Define the "editor" for text files as first action
71 mime ^text, label editor = $EDITOR -- "$@"
72 mime ^text, label pager = "$PAGER" -- "$@"
73 !mime ^text, label editor, ext xml|json|csv|tex|py|pl|rb|js|sh|php = $EDITOR -- "$@"
74 !mime ^text, label pager, ext xml|json|csv|tex|py|pl|rb|js|sh|php = "$PAGER" -- "$@"
75
76 ext 1 = man "$1"
77 ext s[wmf]c, has zsnes, X = zsnes "$1"
78 ext nes, has fceux, X = fceux "$1"
79 ext exe = wine "$1"
80 name ^[mM]akefile$ = make
81
82 #--------------------------------------------
83 # Code
84 #-------------------------------------------
85 ext py = python -- "$1"
86 ext pl = perl -- "$1"
87 ext rb = ruby -- "$1"
88 ext sh = sh -- "$1"
89 ext php = php -- "$1"
90
91 #--------------------------------------------
92 # Audio without X
93 #-------------------------------------------
94 mime ^audio|ogg$, terminal, has mpv = mpv -- "$@"
95
96 #--------------------------------------------
97 # Video/Audio with a GUI
98 #-------------------------------------------
99 mime ^video|audio, has umpv, X, flag f = umpv -- "$@"
100 mime ^video|audio, has mpv, X, flag f = mpv -- "$@"
101
102 #-------------------------------------------
103 # Documents
104 #-------------------------------------------
105 ext pdf, has zathura, X, flag f = zathura -- "$@"
106 ext pdf, has okular, X, flag f = okular -- "$@"
107
108 ext docx?, has catdoc, terminal = catdoc -- "$@" | "$PAGER"
109
110 ext pptx?|od[dfgpst]|docx?|sxc|xlsx?|xlt|xlw|gnm|gnumeric, has libreoffice, X, flag f = libreoffice "$@"
111
112 ext djvu, has evince, X, flag f = evince -- "$@"
113
114 #-------------------------------------------
115 # Image Viewing:
116 #-------------------------------------------
117 mime ^image/svg, has inkscape, X, flag f = inkscape -- "$@"
118
119 mime ^image, has feh, X, flag f = feh -- "$@"
120 mime ^image, has gimp, X, flag f = gimp -- "$@"
121 ext xcf, X, flag f = gimp -- "$@"
122
123 #-------------------------------------------
124 # Archives
125 #-------------------------------------------
126 # This requires atool
127 ext 7z|ace|ar|arc|bz2?|cab|cpio|cpt|deb|dgc|dmg|gz, has als = als -- "$@" | "$PAGER"
128 ext iso|jar|msi|pkg|rar|shar|tar|tgz|xar|xpi|xz|zip, has als = als -- "$@" | "$PAGER"
129 ext 7z|ace|ar|arc|bz2?|cab|cpio|cpt|deb|dgc|dmg|gz, has aunpack = aunpack -- "$@"
130 ext iso|jar|msi|pkg|rar|shar|tar|tgz|xar|xpi|xz|zip, has aunpack = aunpack -- "$@"
131
132 # Fallback:
133 ext tar|gz, has tar = tar vvtf "$@" | "$PAGER"
134 ext tar|gz, has tar = tar vvxf "$@"
135
136 #-------------------------------------------
137 # Misc
138 #-------------------------------------------
139 label wallpaper, number 11, mime ^image, has feh, X = feh --bg-scale "$1"
140 label wallpaper, number 12, mime ^image, has feh, X = feh --bg-tile "$1"
141 label wallpaper, number 13, mime ^image, has feh, X = feh --bg-center "$1"
142 label wallpaper, number 14, mime ^image, has feh, X = feh --bg-fill "$1"
143
144 # Define the editor for non-text files + pager as last action
145 !mime ^text, !ext xml|json|csv|tex|py|pl|rb|js|sh|php = ask
146 label editor, !mime ^text, !ext xml|json|csv|tex|py|pl|rb|js|sh|php = $EDITOR -- "$@"
147 label pager, !mime ^text, !ext xml|json|csv|tex|py|pl|rb|js|sh|php = "$PAGER" -- "$@"
148
149 # The very last action, so that it's never triggered accidentally, is to execute a program:
150 mime application/x-executable = "$1"