rifle.conf 15 KB

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