]> git.rmz.io Git - dotfiles.git/blob - ranger/rifle.conf
weechat: add matrix plugin
[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 -- $1
53 match ^https?://www.youtube.com/watch\?, has mpv, X, flag f = mpv --quiet -- $1
54
55 # open web url with BROWSER
56 match ^https?://, X, flag f = $BROWSER -- "$@"
57
58 #-------------------------------------------
59 # Websites
60 #-------------------------------------------
61 # Rarely installed browsers get higher priority; It is assumed that if you
62 # install a rare browser, you probably use it. Firefox/konqueror/w3m on the
63 # other hand are often only installed as fallback browsers.
64 ext x?html?, has qutebrowser, X, flag f = qutebrowser -- "$@"
65 ext x?html?, has dwb, X, flag f = dwb -- "$@"
66 ext x?html?, has chromium, X, flag f = chromium -- "$@"
67 ext x?html?, has elinks, terminal = elinks "$@"
68 ext x?html?, has w3m, terminal = w3m "$@"
69
70 #-------------------------------------------
71 # Misc
72 #-------------------------------------------
73 # Define the "editor" for text files as first action
74 mime ^text, label editor = $EDITOR -- "$@"
75 mime ^text, label pager = "$PAGER" -- "$@"
76 !mime ^text, label editor, ext xml|json|csv|tex|py|pl|rb|js|sh|php = $EDITOR -- "$@"
77 !mime ^text, label pager, ext xml|json|csv|tex|py|pl|rb|js|sh|php = "$PAGER" -- "$@"
78
79 ext 1 = man "$1"
80 ext s[wmf]c, has zsnes, X = zsnes "$1"
81 ext nes, has fceux, X = fceux "$1"
82 ext exe = wine "$1"
83 name ^[mM]akefile$ = make
84
85 #--------------------------------------------
86 # Code
87 #-------------------------------------------
88 ext py = python -- "$1"
89 ext pl = perl -- "$1"
90 ext rb = ruby -- "$1"
91 ext sh = sh -- "$1"
92 ext php = php -- "$1"
93
94 #--------------------------------------------
95 # Audio without X
96 #-------------------------------------------
97 mime ^audio|ogg$, terminal, has mpv = mpv -- "$@"
98
99 #--------------------------------------------
100 # Video/Audio with a GUI
101 #-------------------------------------------
102 mime ^video|audio, has umpv, X, flag f = umpv -- "$@"
103 mime ^video|audio, has mpv, X, flag f = mpv -- "$@"
104
105 #-------------------------------------------
106 # Documents
107 #-------------------------------------------
108 ext pdf, has zathura, X, flag f = zathura -- "$@"
109 ext pdf, has okular, X, flag f = okular -- "$@"
110
111 ext docx?, has catdoc, terminal = catdoc -- "$@" | "$PAGER"
112
113 ext pptx?|od[dfgpst]|docx?|sxc|xlsx?|xlt|xlw|gnm|gnumeric, has libreoffice, X, flag f = libreoffice "$@"
114
115 ext djvu, has evince, X, flag f = evince -- "$@"
116
117 #-------------------------------------------
118 # Image Viewing:
119 #-------------------------------------------
120 mime ^image/svg, has inkscape, X, flag f = inkscape -- "$@"
121
122 mime ^image, has feh, X, flag f = feh -- "$@"
123 mime ^image, has gimp, X, flag f = gimp -- "$@"
124 ext xcf, X, flag f = gimp -- "$@"
125
126 #-------------------------------------------
127 # Archives
128 #-------------------------------------------
129 # This requires atool
130 ext 7z|ace|ar|arc|bz2?|cab|cpio|cpt|deb|dgc|dmg|gz, has als = als -- "$@" | "$PAGER"
131 ext iso|jar|msi|pkg|rar|shar|tar|tgz|xar|xpi|xz|zip, has als = als -- "$@" | "$PAGER"
132 ext 7z|ace|ar|arc|bz2?|cab|cpio|cpt|deb|dgc|dmg|gz, has aunpack = aunpack -- "$@"
133 ext iso|jar|msi|pkg|rar|shar|tar|tgz|xar|xpi|xz|zip, has aunpack = aunpack -- "$@"
134
135 # Fallback:
136 ext tar|gz, has tar = tar vvtf "$@" | "$PAGER"
137 ext tar|gz, has tar = tar vvxf "$@"
138
139 #-------------------------------------------
140 # Misc
141 #-------------------------------------------
142 label wallpaper, number 11, mime ^image, has feh, X = feh --bg-scale "$1"
143 label wallpaper, number 12, mime ^image, has feh, X = feh --bg-tile "$1"
144 label wallpaper, number 13, mime ^image, has feh, X = feh --bg-center "$1"
145 label wallpaper, number 14, mime ^image, has feh, X = feh --bg-fill "$1"
146
147 # Define the editor for non-text files + pager as last action
148 !mime ^text, !ext xml|json|csv|tex|py|pl|rb|js|sh|php = ask
149 label editor, !mime ^text, !ext xml|json|csv|tex|py|pl|rb|js|sh|php = $EDITOR -- "$@"
150 label pager, !mime ^text, !ext xml|json|csv|tex|py|pl|rb|js|sh|php = "$PAGER" -- "$@"
151
152 # The very last action, so that it's never triggered accidentally, is to execute a program:
153 mime application/x-executable = "$1"