rifle.conf (15234B)
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 | A graphical environment is available (darwin, Xorg, or Wayland) 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 #------------------------------------------- 52 # Websites 53 #------------------------------------------- 54 # Rarely installed browsers get higher priority; It is assumed that if you 55 # install a rare browser, you probably use it. Firefox/konqueror/w3m on the 56 # other hand are often only installed as fallback browsers. 57 ext x?html?, has surf, X, flag f = surf -- file://"$1" 58 ext x?html?, has vimprobable, X, flag f = vimprobable -- "$@" 59 ext x?html?, has vimprobable2, X, flag f = vimprobable2 -- "$@" 60 ext x?html?, has lynx, terminal = lynx -- "$@" 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 jumanji, X, flag f = jumanji -- "$@" 64 ext x?html?, has luakit, X, flag f = luakit -- "$@" 65 ext x?html?, has uzbl, X, flag f = uzbl -- "$@" 66 ext x?html?, has uzbl-tabbed, X, flag f = uzbl-tabbed -- "$@" 67 ext x?html?, has uzbl-browser, X, flag f = uzbl-browser -- "$@" 68 ext x?html?, has uzbl-core, X, flag f = uzbl-core -- "$@" 69 ext x?html?, has midori, X, flag f = midori -- "$@" 70 ext x?html?, has opera, X, flag f = opera -- "$@" 71 ext x?html?, has firefox, X, flag f = firefox -- "$@" 72 ext x?html?, has seamonkey, X, flag f = seamonkey -- "$@" 73 ext x?html?, has iceweasel, X, flag f = iceweasel -- "$@" 74 ext x?html?, has chromium-browser, X, flag f = chromium-browser -- "$@" 75 ext x?html?, has chromium, X, flag f = chromium -- "$@" 76 ext x?html?, has google-chrome, X, flag f = google-chrome -- "$@" 77 ext x?html?, has epiphany, X, flag f = epiphany -- "$@" 78 ext x?html?, has konqueror, X, flag f = konqueror -- "$@" 79 ext x?html?, has elinks, terminal = elinks "$@" 80 ext x?html?, has links2, terminal = links2 "$@" 81 ext x?html?, has links, terminal = links "$@" 82 ext x?html?, has w3m, terminal = w3m "$@" 83 84 #------------------------------------------- 85 # Misc 86 #------------------------------------------- 87 # Define the "editor" for text files as first action 88 mime ^text, label editor = ${VISUAL:-$EDITOR} -- "$@" 89 mime ^text, label pager = $PAGER -- "$@" 90 !mime ^text, label editor, ext xml|json|csv|tex|py|pl|rb|rs|js|sh|php|dart|nim = ${VISUAL:-$EDITOR} -- "$@" 91 !mime ^text, label pager, ext xml|json|csv|tex|py|pl|rb|rs|js|sh|php|dart|nim = $PAGER -- "$@" 92 93 ext 1 = man "$1" 94 ext s[wmf]c, has zsnes, X = zsnes "$1" 95 ext s[wmf]c, has snes9x-gtk,X = snes9x-gtk "$1" 96 ext nes, has fceux, X = fceux "$1" 97 ext exe, has wine = wine "$1" 98 ext nim, has nim = nim r -- "$1" 99 name ^[mM]akefile$ = make 100 101 #-------------------------------------------- 102 # Scripts 103 #------------------------------------------- 104 ext py = python -- "$1" 105 ext pl = perl -- "$1" 106 ext rb = ruby -- "$1" 107 ext js = node -- "$1" 108 ext sh = sh -- "$1" 109 ext php = php -- "$1" 110 ext dart = dart run -- "$1" 111 112 #-------------------------------------------- 113 # Audio without X 114 #------------------------------------------- 115 mime ^audio|ogg$, terminal, has mpv, X, flag f = mpv -- "$@" 116 117 #-------------------------------------------- 118 # Video/Audio with a GUI 119 #------------------------------------------- 120 mime ^video|^audio, has gmplayer, X, flag f = gmplayer -- "$@" 121 mime ^video|^audio, has smplayer, X, flag f = smplayer "$@" 122 mime ^video, has iina, X, flag f = iina -- "$@" 123 mime ^video|^audio, has iina, X, flag f = iina --music-mode -- "$@" 124 mime ^video, has mpv, X, flag f = mpv -- "$@" 125 mime ^video, has mpv, X, flag f = mpv --fs -- "$@" 126 mime ^video, has mplayer2, X, flag f = mplayer2 -- "$@" 127 mime ^video, has mplayer2, X, flag f = mplayer2 -fs -- "$@" 128 mime ^video, has mplayer, X, flag f = mplayer -- "$@" 129 mime ^video, has mplayer, X, flag f = mplayer -fs -- "$@" 130 mime ^video|^audio, has vlc, X, flag f = vlc -- "$@" 131 mime ^video|^audio, has totem, X, flag f = totem -- "$@" 132 mime ^video|^audio, has totem, X, flag f = totem --fullscreen -- "$@" 133 mime ^audio, has audacity, X, flag f = audacity -- "$@" 134 ext aup, has audacity, X, flag f = audacity -- "$@" 135 136 #-------------------------------------------- 137 # Video without X 138 #------------------------------------------- 139 mime ^video, terminal, !X, has mpv = mpv -- "$@" 140 mime ^video, terminal, !X, has mplayer2 = mplayer2 -- "$@" 141 mime ^video, terminal, !X, has mplayer = mplayer -- "$@" 142 143 #------------------------------------------- 144 # Documents 145 #------------------------------------------- 146 ext pdf, has llpp, X, flag f = llpp "$@" 147 ext pdf, has zathura, X, flag f = zathura -- "$@" 148 ext pdf, has mupdf, X, flag f = mupdf "$@" 149 ext pdf, has mupdf-x11,X, flag f = mupdf-x11 "$@" 150 ext pdf, has apvlv, X, flag f = apvlv -- "$@" 151 ext pdf, has xpdf, X, flag f = xpdf -- "$@" 152 ext pdf, has evince, X, flag f = evince -- "$@" 153 ext pdf, has atril, X, flag f = atril -- "$@" 154 ext pdf, has okular, X, flag f = okular -- "$@" 155 ext pdf, has epdfview, X, flag f = epdfview -- "$@" 156 ext pdf, has qpdfview, X, flag f = qpdfview "$@" 157 ext pdf, has open, X, flag f = open "$@" 158 159 ext sc, has sc, = sc -- "$@" 160 ext docx?, has catdoc, terminal = catdoc -- "$@" | $PAGER 161 162 ext sxc|xlsx?|xlt|xlw|gnm|gnumeric, has gnumeric, X, flag f = gnumeric -- "$@" 163 ext sxc|xlsx?|xlt|xlw|gnm|gnumeric, has kspread, X, flag f = kspread -- "$@" 164 ext pptx?|od[dfgpst]|docx?|sxc|xlsx?|xlt|xlw|gnm|gnumeric, has libreoffice, X, flag f = libreoffice "$@" 165 ext pptx?|od[dfgpst]|docx?|sxc|xlsx?|xlt|xlw|gnm|gnumeric, has soffice, X, flag f = soffice "$@" 166 ext pptx?|od[dfgpst]|docx?|sxc|xlsx?|xlt|xlw|gnm|gnumeric, has ooffice, X, flag f = ooffice "$@" 167 168 ext djvu, has zathura,X, flag f = zathura -- "$@" 169 ext djvu, has evince, X, flag f = evince -- "$@" 170 ext djvu, has atril, X, flag f = atril -- "$@" 171 ext djvu, has djview, X, flag f = djview -- "$@" 172 173 ext epub, has ebook-viewer, X, flag f = ebook-viewer -- "$@" 174 ext epub, has zathura, X, flag f = zathura -- "$@" 175 ext epub, has mupdf, X, flag f = mupdf -- "$@" 176 ext mobi, has ebook-viewer, X, flag f = ebook-viewer -- "$@" 177 178 ext cb[rz], has qcomicbook, X, flag f = qcomicbook "$@" 179 ext cb[rz], has mcomix, X, flag f = mcomix -- "$@" 180 ext cb[rz], has zathura, X, flag f = zathura -- "$@" 181 ext cb[rz], has atril, X, flag f = atril -- "$@" 182 183 ext sla, has scribus, X, flag f = scribus -- "$@" 184 185 #------------------------------------------- 186 # Images 187 #------------------------------------------- 188 mime ^image, has viewnior, X, flag f = viewnior -- "$@" 189 190 mime ^image/svg, has inkscape, X, flag f = inkscape -- "$@" 191 mime ^image/svg, has display, X, flag f = display -- "$@" 192 193 mime ^image, has imv, X, flag f = imv -- "$@" 194 mime ^image, has pqiv, X, flag f = pqiv -- "$@" 195 mime ^image, has sxiv, X, flag f = sxiv -- "$@" 196 mime ^image, has feh, X, flag f, !ext gif = feh -- "$@" 197 mime ^image, has mirage, X, flag f = mirage -- "$@" 198 mime ^image, has ristretto, X, flag f = ristretto "$@" 199 mime ^image, has eog, X, flag f = eog -- "$@" 200 mime ^image, has eom, X, flag f = eom -- "$@" 201 mime ^image, has nomacs, X, flag f = nomacs -- "$@" 202 mime ^image, has geeqie, X, flag f = geeqie -- "$@" 203 mime ^image, has gpicview, X, flag f = gpicview -- "$@" 204 mime ^image, has gwenview, X, flag f = gwenview -- "$@" 205 mime ^image, has xviewer, X, flag f = xviewer -- "$@" 206 mime ^image, has mcomix, X, flag f = mcomix -- "$@" 207 mime ^image, has gimp, X, flag f = gimp -- "$@" 208 mime ^image, has krita, X, flag f = krita -- "$@" 209 ext kra, has krita, X, flag f = krita -- "$@" 210 ext xcf, X, flag f = gimp -- "$@" 211 212 #------------------------------------------- 213 # Archives 214 #------------------------------------------- 215 216 # avoid password prompt by providing empty password 217 ext 7z, has 7z = 7z -p l "$@" | $PAGER 218 # This requires atool 219 ext ace|ar|arc|bz2?|cab|cpio|cpt|deb|dgc|dmg|gz, has atool = atool --list --each -- "$@" | $PAGER 220 ext iso|jar|msi|pkg|rar|shar|tar|tgz|xar|xpi|xz|zip, has atool = atool --list --each -- "$@" | $PAGER 221 ext 7z|ace|ar|arc|bz2?|cab|cpio|cpt|deb|dgc|dmg|gz, has atool = atool --extract --each -- "$@" 222 ext iso|jar|msi|pkg|rar|shar|tar|tgz|xar|xpi|xz|zip, has atool = atool --extract --each -- "$@" 223 224 # Listing and extracting archives without atool: 225 ext tar|gz|bz2|xz, has tar = tar vvtf "$1" | $PAGER 226 ext tar|gz|bz2|xz, has tar = for file in "$@"; do tar vvxf "$file"; done 227 ext bz2, has bzip2 = for file in "$@"; do bzip2 -dk "$file"; done 228 ext zip, has unzip = unzip -l "$1" | less 229 ext zip, has unzip = for file in "$@"; do unzip -d "${file%.*}" "$file"; done 230 ext ace, has unace = unace l "$1" | less 231 ext ace, has unace = for file in "$@"; do unace e "$file"; done 232 ext rar, has unrar = unrar l "$1" | less 233 ext rar, has unrar = for file in "$@"; do unrar x "$file"; done 234 ext rar|zip, has qcomicbook, X, flag f = qcomicbook "$@" 235 ext rar|zip, has mcomix, X, flag f = mcomix -- "$@" 236 ext rar|zip, has zathura, X, flag f = zathura -- "$@" 237 238 #------------------------------------------- 239 # Fonts 240 #------------------------------------------- 241 mime ^font, has fontforge, X, flag f = fontforge "$@" 242 243 #------------------------------------------- 244 # Flag t fallback terminals 245 #------------------------------------------- 246 # Rarely installed terminal emulators get higher priority; It is assumed that 247 # if you install a rare terminal emulator, you probably use it. 248 # gnome-terminal/konsole/xterm on the other hand are often installed as part of 249 # a desktop environment or as fallback terminal emulators. 250 mime ^ranger/x-terminal-emulator, has terminology = terminology -e "$@" 251 mime ^ranger/x-terminal-emulator, has kitty = kitty -- "$@" 252 mime ^ranger/x-terminal-emulator, has alacritty = alacritty -e "$@" 253 mime ^ranger/x-terminal-emulator, has sakura = sakura -e "$@" 254 mime ^ranger/x-terminal-emulator, has lilyterm = lilyterm -e "$@" 255 #mime ^ranger/x-terminal-emulator, has cool-retro-term = cool-retro-term -e "$@" 256 mime ^ranger/x-terminal-emulator, has termite = termite -x '"$@"' 257 #mime ^ranger/x-terminal-emulator, has yakuake = yakuake -e "$@" 258 mime ^ranger/x-terminal-emulator, has guake = guake -ne "$@" 259 mime ^ranger/x-terminal-emulator, has tilda = tilda -c "$@" 260 mime ^ranger/x-terminal-emulator, has st = st -e "$@" 261 mime ^ranger/x-terminal-emulator, has terminator = terminator -x "$@" 262 mime ^ranger/x-terminal-emulator, has urxvt = urxvt -e "$@" 263 mime ^ranger/x-terminal-emulator, has pantheon-terminal = pantheon-terminal -e "$@" 264 mime ^ranger/x-terminal-emulator, has lxterminal = lxterminal -e "$@" 265 mime ^ranger/x-terminal-emulator, has mate-terminal = mate-terminal -x "$@" 266 mime ^ranger/x-terminal-emulator, has xfce4-terminal = xfce4-terminal -x "$@" 267 mime ^ranger/x-terminal-emulator, has konsole = konsole -e "$@" 268 mime ^ranger/x-terminal-emulator, has gnome-terminal = gnome-terminal -- "$@" 269 mime ^ranger/x-terminal-emulator, has xterm = xterm -e "$@" 270 271 #------------------------------------------- 272 # Misc 273 #------------------------------------------- 274 label wallpaper, number 11, mime ^image, has feh, X = feh --bg-scale "$1" 275 label wallpaper, number 12, mime ^image, has feh, X = feh --bg-tile "$1" 276 label wallpaper, number 13, mime ^image, has feh, X = feh --bg-center "$1" 277 label wallpaper, number 14, mime ^image, has feh, X = feh --bg-fill "$1" 278 279 #------------------------------------------- 280 # Generic file openers 281 #------------------------------------------- 282 label open, has xdg-open = xdg-open "$@" 283 label open, has open = open -- "$@" 284 285 # this allows for us to play a playlist using mpv by pressing 'r' and then selecting 286 # the playlist. This is better then using a shell because it runs in a new process 287 label open, has mpv, X, flag f = mpv -- "$@" 288 label open, has mpv, X, flag f = mpv --shuffle -- "$@" 289 290 # Define the editor for non-text files + pager as last action 291 !mime ^text, !ext xml|json|csv|tex|py|pl|rb|rs|js|sh|php|dart|nim = ask 292 label editor, !mime ^text, !ext xml|json|csv|tex|py|pl|rb|rs|js|sh|php|dart|nim = ${VISUAL:-$EDITOR} -- "$@" 293 label pager, !mime ^text, !ext xml|json|csv|tex|py|pl|rb|rs|js|sh|php|dart|nim = $PAGER -- "$@" 294 295 296 ###################################################################### 297 # The actions below are left so low down in this file on purpose, so # 298 # they are never triggered accidentally. # 299 ###################################################################### 300 301 # Execute a file as program/script. 302 mime application/x-executable = "$1" 303 304 # Move the file to trash using trash-cli. 305 label trash, has trash-put = trash-put -- "$@" 306 label trash = mkdir -p -- "${XDG_DATA_HOME:-$HOME/.local/share}/ranger/trash"; mv -- "$@" "${XDG_DATA_HOME:-$HOME/.local/share}/ranger/trash"