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