My dotfiles for my Linux rice managed with stow and make
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

rifle.conf 10KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220
  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. # 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 surf, X, flag f = surf -- file://"$1"
  57. ext x?html?, has vimprobable, X, flag f = vimprobable -- "$@"
  58. ext x?html?, has vimprobable2, X, flag f = vimprobable2 -- "$@"
  59. ext x?html?, has qutebrowser, X, flag f = qutebrowser -- "$@"
  60. ext x?html?, has dwb, X, flag f = dwb -- "$@"
  61. ext x?html?, has jumanji, X, flag f = jumanji -- "$@"
  62. ext x?html?, has luakit, X, flag f = luakit -- "$@"
  63. ext x?html?, has uzbl, X, flag f = uzbl -- "$@"
  64. ext x?html?, has uzbl-tabbed, X, flag f = uzbl-tabbed -- "$@"
  65. ext x?html?, has uzbl-browser, X, flag f = uzbl-browser -- "$@"
  66. ext x?html?, has uzbl-core, X, flag f = uzbl-core -- "$@"
  67. ext x?html?, has midori, X, flag f = midori -- "$@"
  68. ext x?html?, has chromium, X, flag f = chromium -- "$@"
  69. ext x?html?, has opera, X, flag f = opera -- "$@"
  70. ext x?html?, has firefox, X, flag f = firefox -- "$@"
  71. ext x?html?, has seamonkey, X, flag f = seamonkey -- "$@"
  72. ext x?html?, has iceweasel, X, flag f = iceweasel -- "$@"
  73. ext x?html?, has epiphany, X, flag f = epiphany -- "$@"
  74. ext x?html?, has konqueror, X, flag f = konqueror -- "$@"
  75. ext x?html?, has elinks, terminal = elinks "$@"
  76. ext x?html?, has links2, terminal = links2 "$@"
  77. ext x?html?, has links, terminal = links "$@"
  78. ext x?html?, has lynx, terminal = lynx -- "$@"
  79. ext x?html?, has w3m, terminal = w3m "$@"
  80. #-------------------------------------------
  81. # Misc
  82. #-------------------------------------------
  83. ext sc = scim -- "$1"
  84. # Define the "editor" for text files as first action
  85. mime ^text, label editor = $EDITOR -- "$@"
  86. mime ^text, label pager = "$PAGER" -- "$@"
  87. !mime ^text, label editor, ext xml|json|csv|tex|py|pl|rb|js|sh|php = $EDITOR -- "$@"
  88. !mime ^text, label pager, ext xml|json|csv|tex|py|pl|rb|js|sh|php = "$PAGER" -- "$@"
  89. ext 1 = man "$1"
  90. ext s[wmf]c, has zsnes, X = zsnes "$1"
  91. ext s[wmf]c, has snes9x-gtk,X = snes9x-gtk "$1"
  92. ext nes, has fceux, X = fceux "$1"
  93. ext exe = wine "$1"
  94. name ^[mM]akefile$ = make
  95. #--------------------------------------------
  96. # Code
  97. #-------------------------------------------
  98. ext py = python -- "$1"
  99. ext pl = perl -- "$1"
  100. ext rb = ruby -- "$1"
  101. ext js = node -- "$1"
  102. ext sh = sh -- "$1"
  103. ext php = php -- "$1"
  104. #--------------------------------------------
  105. # Audio without X
  106. #-------------------------------------------
  107. mime ^audio|ogg$, terminal, has mpv = mpv --no-video -- "$@"
  108. mime ^audio|ogg$, terminal, has mplayer2 = mplayer2 -- "$@"
  109. mime ^audio|ogg$, terminal, has mplayer = mplayer -- "$@"
  110. ext midi?, terminal, has wildmidi = wildmidi -- "$@"
  111. #--------------------------------------------
  112. # Video/Audio with a GUI
  113. #-------------------------------------------
  114. mime ^video|audio, has gmplayer, X, flag f = gmplayer -- "$@"
  115. mime ^video|audio, has smplayer, X, flag f = smplayer "$@"
  116. mime ^video, has mpv, X, flag f = mpv -- "$@"
  117. mime ^video, has mpv, X, flag f = mpv --fs -- "$@"
  118. mime ^video, has mplayer2, X, flag f = mplayer2 -- "$@"
  119. mime ^video, has mplayer2, X, flag f = mplayer2 -fs -- "$@"
  120. mime ^video, has mplayer, X, flag f = mplayer -- "$@"
  121. mime ^video, has mplayer, X, flag f = mplayer -fs -- "$@"
  122. mime ^video|audio, has vlc, X, flag f = vlc -- "$@"
  123. mime ^video|audio, has totem, X, flag f = totem -- "$@"
  124. mime ^video|audio, has totem, X, flag f = totem --fullscreen -- "$@"
  125. #--------------------------------------------
  126. # Video without X:
  127. #-------------------------------------------
  128. mime ^video, terminal, !X, has mpv = mpv -- "$@"
  129. mime ^video, terminal, !X, has mplayer2 = mplayer2 -- "$@"
  130. mime ^video, terminal, !X, has mplayer = mplayer -- "$@"
  131. #-------------------------------------------
  132. # Documents
  133. #-------------------------------------------
  134. ext pdf, has llpp, X, flag f = llpp "$@"
  135. ext pdf, has zathura, X, flag f = zathura -- "$@"
  136. ext pdf, has mupdf, X, flag f = mupdf "$@"
  137. ext pdf, has mupdf-x11,X, flag f = mupdf-x11 "$@"
  138. ext pdf, has xreader, X, flag f = xreader -- "$@"
  139. ext pdf, has apvlv, X, flag f = apvlv -- "$@"
  140. ext pdf, has xpdf, X, flag f = xpdf -- "$@"
  141. ext pdf, has evince, X, flag f = evince -- "$@"
  142. ext pdf, has atril, X, flag f = atril -- "$@"
  143. ext pdf, has okular, X, flag f = okular -- "$@"
  144. ext pdf, has epdfview, X, flag f = epdfview -- "$@"
  145. ext pdf, has qpdfview, X, flag f = qpdfview "$@"
  146. ext docx?, has catdoc, terminal = catdoc -- "$@" | "$PAGER"
  147. ext sxc|xlsx?|xlt|xlw|gnm|gnumeric, has gnumeric, X, flag f = gnumeric -- "$@"
  148. ext sxc|xlsx?|xlt|xlw|gnm|gnumeric, has kspread, X, flag f = kspread -- "$@"
  149. ext pptx?|od[dfgpst]|docx?|sxc|xlsx?|xlt|xlw|gnm|gnumeric, has libreoffice, X, flag f = libreoffice "$@"
  150. ext pptx?|od[dfgpst]|docx?|sxc|xlsx?|xlt|xlw|gnm|gnumeric, has soffice, X, flag f = soffice "$@"
  151. ext pptx?|od[dfgpst]|docx?|sxc|xlsx?|xlt|xlw|gnm|gnumeric, has ooffice, X, flag f = ooffice "$@"
  152. ext djvu, has zathura,X, flag f = zathura -- "$@"
  153. ext djvu, has evince, X, flag f = evince -- "$@"
  154. ext djvu, has atril, X, flag f = atril -- "$@"
  155. #-------------------------------------------
  156. # Image Viewing:
  157. #-------------------------------------------
  158. mime ^image/svg, has inkscape, X, flag f = inkscape -- "$@"
  159. mime ^image/svg, has display, X, flag f = display -- "$@"
  160. mime ^image/gif, has mpv, X, flag f = mpv --loop -- "$@"
  161. mime ^image, has pqiv, X, flag f = pqiv -- "$@"
  162. mime ^image, has sxiv, X, flag f = sxiv -- "$@"
  163. mime ^image, has feh, X, flag f = feh -- "$@"
  164. mime ^image, has mirage, X, flag f = mirage -- "$@"
  165. mime ^image, has ristretto, X, flag f = ristretto "$@"
  166. mime ^image, has eog, X, flag f = eog -- "$@"
  167. mime ^image, has eom, X, flag f = eom -- "$@"
  168. mime ^image, has xviewer, X, flag f = xviewer "$@"
  169. mime ^image, has gimp, X, flag f = gimp -- "$@"
  170. ext xcf, X, flag f = gimp -- "$@"
  171. #-------------------------------------------
  172. # Archives
  173. #-------------------------------------------
  174. ext jar = java -jar "$@"
  175. # avoid password prompt by providing empty password
  176. ext 7z, has 7z = 7z -p l "$@" | "$PAGER"
  177. # This requires atool
  178. ext ace|ar|arc|bz2?|cab|cpio|cpt|deb|dgc|dmg|gz, has als = als -- "$@" | "$PAGER"
  179. ext iso|jar|msi|pkg|rar|shar|tar|tgz|xar|xpi|xz|zip, has als = als -- "$@" | "$PAGER"
  180. ext 7z|ace|ar|arc|bz2?|cab|cpio|cpt|deb|dgc|dmg|gz, has aunpack = aunpack -- "$@"
  181. ext iso|jar|msi|pkg|rar|shar|tar|tgz|xar|xpi|xz|zip, has aunpack = aunpack -- "$@"
  182. # Fallback:
  183. ext tar|gz, has tar = tar vvtf "$@" | "$PAGER"
  184. ext tar|gz, has tar = tar vvxf "$@"
  185. #-------------------------------------------
  186. # Misc
  187. #-------------------------------------------
  188. label wallpaper, number 11, mime ^image, has feh, X = feh --bg-scale "$1"
  189. label wallpaper, number 12, mime ^image, has feh, X = feh --bg-tile "$1"
  190. label wallpaper, number 13, mime ^image, has feh, X = feh --bg-center "$1"
  191. label wallpaper, number 14, mime ^image, has feh, X = feh --bg-fill "$1"
  192. # Define the editor for non-text files + pager as last action
  193. !mime ^text, !ext xml|json|csv|tex|py|pl|rb|js|sh|php = ask
  194. label editor, !mime ^text, !ext xml|json|csv|tex|py|pl|rb|js|sh|php = $EDITOR -- "$@"
  195. label pager, !mime ^text, !ext xml|json|csv|tex|py|pl|rb|js|sh|php = "$PAGER" -- "$@"
  196. # The very last action, so that it's never triggered accidentally, is to execute a program:
  197. mime application/x-executable = "$1"