Dotfiles for my tiling window manager + terminal workflow.
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.

234 lines
11 KiB

5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
  1. # vim: ft=cfg
  2. # info {{{
  3. #
  4. # This is the configuration file of "rifle", ranger's file executor/opener.
  5. # Each line consists of conditions and a command. For each line the conditions
  6. # are checked and if they are met, the respective command is run.
  7. #
  8. # Syntax:
  9. # <condition1> , <condition2> , ... = command
  10. #
  11. # The command can contain these environment variables:
  12. # $1-$9 | The n-th selected file
  13. # $@ | All selected files
  14. #
  15. # If you use the special command "ask", rifle will ask you what program to run.
  16. #
  17. # Prefixing a condition with "!" will negate its result.
  18. # These conditions are currently supported:
  19. # match <regexp> | The regexp matches $1
  20. # ext <regexp> | The regexp matches the extension of $1
  21. # mime <regexp> | The regexp matches the mime type of $1
  22. # name <regexp> | The regexp matches the basename of $1
  23. # path <regexp> | The regexp matches the absolute path of $1
  24. # has <program> | The program is installed (i.e. located in $PATH)
  25. # env <variable> | The environment variable "variable" is non-empty
  26. # file | $1 is a file
  27. # directory | $1 is a directory
  28. # number <n> | change the number of this command to n
  29. # terminal | stdin, stderr and stdout are connected to a terminal
  30. # X | $DISPLAY is not empty (i.e. Xorg runs)
  31. #
  32. # There are also pseudo-conditions which have a "side effect":
  33. # flag <flags> | Change how the program is run. See below.
  34. # label <label> | Assign a label or name to the command so it can
  35. # | be started with :open_with <label> in ranger
  36. # | or `rifle -p <label>` in the standalone executable.
  37. # else | Always true.
  38. #
  39. # Flags are single characters which slightly transform the command:
  40. # f | Fork the program, make it run in the background.
  41. # | New command = setsid $command >& /dev/null &
  42. # r | Execute the command with root permissions
  43. # | New command = sudo $command
  44. # t | Run the program in a new terminal. If $TERMCMD is not defined,
  45. # | rifle will attempt to extract it from $TERM.
  46. # | New command = $TERMCMD -e $command
  47. # Note: The "New command" serves only as an illustration, the exact
  48. # implementation may differ.
  49. # Note: When using rifle in ranger, there is an additional flag "c" for
  50. # only running the current file even if you have marked multiple files.
  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 qutebrowser, X, flag f = qutebrowser -- "$@"
  61. # ext x?html?, has dwb, X, flag f = dwb -- "$@"
  62. # ext x?html?, has jumanji, X, flag f = jumanji -- "$@"
  63. # ext x?html?, has luakit, X, flag f = luakit -- "$@"
  64. # ext x?html?, has uzbl, X, flag f = uzbl -- "$@"
  65. # ext x?html?, has uzbl-tabbed, X, flag f = uzbl-tabbed -- "$@"
  66. # ext x?html?, has uzbl-browser, X, flag f = uzbl-browser -- "$@"
  67. # ext x?html?, has uzbl-core, X, flag f = uzbl-core -- "$@"
  68. # ext x?html?, has midori, X, flag f = midori -- "$@"
  69. # ext x?html?, has chromium-browser, X, flag f = chromium-browser -- "$@"
  70. # ext x?html?, has chromium, X, flag f = chromium -- "$@"
  71. # ext x?html?, has google-chrome, X, flag f = google-chrome -- "$@"
  72. # ext x?html?, has opera, X, flag f = opera -- "$@"
  73. # ext x?html?, has firefox, X, flag f = firefox -- "$@"
  74. # ext x?html?, has seamonkey, X, flag f = seamonkey -- "$@"
  75. # ext x?html?, has iceweasel, X, flag f = iceweasel -- "$@"
  76. # ext x?html?, has epiphany, X, flag f = epiphany -- "$@"
  77. # ext x?html?, has konqueror, X, flag f = konqueror -- "$@"
  78. # ext x?html?, has elinks, terminal = elinks "$@"
  79. # ext x?html?, has links2, terminal = links2 "$@"
  80. # ext x?html?, has links, terminal = links "$@"
  81. # ext x?html?, has lynx, terminal = lynx -- "$@"
  82. # ext x?html?, has w3m, terminal = w3m "$@"
  83. # }}}
  84. # text {{{
  85. #-------------------------------------------
  86. # Define the "editor" for text files as first action
  87. # mime ^text, label editor = urxvt -e "${VISUAL:-$EDITOR} -- $@"
  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|js|sh|php|fish|html|yml|scss = ${VISUAL:-$EDITOR} -- "$@"
  91. # !mime ^text, label editor, ext xml|json|csv|tex|py|pl|rb|js|sh|php|fish|html|yml|scss = urxvt -e ${VISUAL:-$EDITOR} -- "$@"
  92. !mime ^text, label pager, ext xml|json|csv|tex|py|pl|rb|js|sh|php|fish|html|yml|scss = "$PAGER" -- "$@"
  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 = wine "$1"
  98. name ^[mM]akefile$ = make
  99. # }}}
  100. #--------------------------------------------
  101. # Code
  102. #-------------------------------------------
  103. ext py = python -- "$1"
  104. ext pl = perl -- "$1"
  105. ext rb = ruby -- "$1"
  106. ext js = node -- "$1"
  107. ext sh = sh -- "$1"
  108. ext php = php -- "$1"
  109. #--------------------------------------------
  110. # Audio without X
  111. #-------------------------------------------
  112. mime ^audio|ogg$, terminal, has mpv = mpv -- "$@"
  113. mime ^audio|ogg$, terminal, has mplayer2 = mplayer2 -- "$@"
  114. mime ^audio|ogg$, terminal, has mplayer = mplayer -- "$@"
  115. ext midi?, terminal, has wildmidi = wildmidi -- "$@"
  116. #--------------------------------------------
  117. # Video/Audio with a GUI
  118. #-------------------------------------------
  119. mime ^video|audio, has gmplayer, X, flag f = gmplayer -- "$@"
  120. mime ^video|audio, has smplayer, X, flag f = smplayer "$@"
  121. mime ^video, has mpv, X, flag f = mpv -- "$@"
  122. mime ^video, has mpv, X, flag f = mpv --fs -- "$@"
  123. mime ^video, has mplayer2, X, flag f = mplayer2 -- "$@"
  124. mime ^video, has mplayer2, X, flag f = mplayer2 -fs -- "$@"
  125. mime ^video, has mplayer, X, flag f = mplayer -- "$@"
  126. mime ^video, has mplayer, X, flag f = mplayer -fs -- "$@"
  127. mime ^video|audio, has vlc, X, flag f = vlc -- "$@"
  128. mime ^video|audio, has totem, X, flag f = totem -- "$@"
  129. mime ^video|audio, has totem, X, flag f = totem --fullscreen -- "$@"
  130. #--------------------------------------------
  131. # Video without X:
  132. #-------------------------------------------
  133. mime ^video, terminal, !X, has mpv = mpv -- "$@"
  134. mime ^video, terminal, !X, has mplayer2 = mplayer2 -- "$@"
  135. mime ^video, terminal, !X, has mplayer = mplayer -- "$@"
  136. #-------------------------------------------
  137. # Documents
  138. #-------------------------------------------
  139. # ext pdf = ask
  140. ext pdf, has zathura, X, flag f = zathura -- "$@"
  141. ext pdf, has evince, X, flag f = evince -- "$@"
  142. ext pdf, has llpp, X, flag f = llpp "$@"
  143. ext pdf, has mupdf, X, flag f = mupdf "$@"
  144. ext pdf, has mupdf-x11,X, flag f = mupdf-x11 "$@"
  145. ext pdf, has apvlv, X, flag f = apvlv -- "$@"
  146. ext pdf, has xpdf, X, flag f = xpdf -- "$@"
  147. ext pdf, has atril, X, flag f = atril -- "$@"
  148. ext pdf, has okular, X, flag f = okular -- "$@"
  149. ext pdf, has epdfview, X, flag f = epdfview -- "$@"
  150. ext pdf, has qpdfview, X, flag f = qpdfview "$@"
  151. ext pdf, has open, X, flat f = open "$@"
  152. ext docx?, has catdoc, terminal = catdoc -- "$@" | "$PAGER"
  153. ext sxc|xlsx?|xlt|xlw|gnm|gnumeric, has gnumeric, X, flag f = gnumeric -- "$@"
  154. ext sxc|xlsx?|xlt|xlw|gnm|gnumeric, has kspread, X, flag f = kspread -- "$@"
  155. ext pptx?|od[dfgpst]|docx?|sxc|xlsx?|xlt|xlw|gnm|gnumeric, has libreoffice, X, flag f = libreoffice "$@"
  156. ext pptx?|od[dfgpst]|docx?|sxc|xlsx?|xlt|xlw|gnm|gnumeric, has soffice, X, flag f = soffice "$@"
  157. ext pptx?|od[dfgpst]|docx?|sxc|xlsx?|xlt|xlw|gnm|gnumeric, has ooffice, X, flag f = ooffice "$@"
  158. ext djvu, has zathura,X, flag f = zathura -- "$@"
  159. ext djvu, has evince, X, flag f = evince -- "$@"
  160. ext djvu, has atril, X, flag f = atril -- "$@"
  161. ext epub, has ebook-viewer, X, flag f = ebook-viewer -- "$@"
  162. ext mobi, has ebook-viewer, X, flag f = ebook-viewer -- "$@"
  163. #-------------------------------------------
  164. # Image Viewing:
  165. #-------------------------------------------
  166. mime ^image/svg, has inkscape, X, flag f = inkscape -- "$@"
  167. mime ^image/svg, has display, X, flag f = display -- "$@"
  168. mime ^image, has pqiv, X, flag f = pqiv -- "$@"
  169. mime ^image, has sxiv, X, flag f = sxiv -- "$@"
  170. mime ^image, has feh, X, flag f = feh -- "$@"
  171. mime ^image, has mirage, X, flag f = mirage -- "$@"
  172. mime ^image, has ristretto, X, flag f = ristretto "$@"
  173. mime ^image, has eog, X, flag f = eog -- "$@"
  174. mime ^image, has eom, X, flag f = eom -- "$@"
  175. mime ^image, has nomacs, X, flag f = nomacs -- "$@"
  176. mime ^image, has geeqie, X, flag f = geeqie -- "$@"
  177. mime ^image, has gimp, X, flag f = gimp -- "$@"
  178. ext xcf, X, flag f = gimp -- "$@"
  179. #-------------------------------------------
  180. # Archives
  181. #-------------------------------------------
  182. # avoid password prompt by providing empty password
  183. ext 7z, has 7z = 7z -p l "$@" | "$PAGER"
  184. # This requires atool
  185. ext ace|ar|arc|bz2?|cab|cpio|cpt|deb|dgc|dmg|gz, has atool = atool --list --each -- "$@" | "$PAGER"
  186. ext iso|jar|msi|pkg|rar|shar|tar|tgz|xar|xpi|xz|zip, has atool = atool --list --each -- "$@" | "$PAGER"
  187. ext 7z|ace|ar|arc|bz2?|cab|cpio|cpt|deb|dgc|dmg|gz, has atool = atool --extract --each -- "$@"
  188. ext iso|jar|msi|pkg|rar|shar|tar|tgz|xar|xpi|xz|zip, has atool = atool --extract --each -- "$@"
  189. # Listing and extracting archives without atool:
  190. ext tar|gz|bz2|xz, has tar = tar vvtf "$1" | "$PAGER"
  191. ext tar|gz|bz2|xz, has tar = for file in "$@"; do tar vvxf "$file"; done
  192. ext bz2, has bzip2 = for file in "$@"; do bzip2 -dk "$file"; done
  193. ext zip, has unzip = unzip -l "$1" | less
  194. ext zip, has unzip = for file in "$@"; do unzip -d "${file%.*}" "$file"; done
  195. ext ace, has unace = unace l "$1" | less
  196. ext ace, has unace = for file in "$@"; do unace e "$file"; done
  197. ext rar, has unrar = unrar l "$1" | less
  198. ext rar, has unrar = for file in "$@"; do unrar x "$file"; done
  199. #-------------------------------------------
  200. # Misc
  201. #-------------------------------------------
  202. label wallpaper, number 11, mime ^image, has feh, X = feh --bg-scale "$1"
  203. label wallpaper, number 12, mime ^image, has feh, X = feh --bg-tile "$1"
  204. label wallpaper, number 13, mime ^image, has feh, X = feh --bg-center "$1"
  205. label wallpaper, number 14, mime ^image, has feh, X = feh --bg-fill "$1"
  206. # Define the editor for non-text files + pager as last action
  207. !mime ^text, !ext xml|json|csv|tex|py|pl|rb|js|sh|php = ask
  208. label editor, !mime ^text, !ext xml|json|csv|tex|py|pl|rb|js|sh|php = ${VISUAL:-$EDITOR} -- "$@"
  209. label pager, !mime ^text, !ext xml|json|csv|tex|py|pl|rb|js|sh|php = "$PAGER" -- "$@"
  210. # ext gpg = pass edit -- "$1"
  211. # The very last action, so that it's never triggered accidentally, is to execute a program:
  212. mime application/x-executable = "$1"