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 7.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  1. # Syntax:
  2. # <condition1> , <condition2> , ... = command
  3. #
  4. # The command can contain these environment variables:
  5. # $1-$9 | The n-th selected file
  6. # $@ | All selected files
  7. #
  8. # If you use the special command "ask", rifle will ask you what program to run.
  9. #
  10. # Prefixing a condition with "!" will negate its result.
  11. # These conditions are currently supported:
  12. # match <regexp> | The regexp matches $1
  13. # ext <regexp> | The regexp matches the extension of $1
  14. # mime <regexp> | The regexp matches the mime type of $1
  15. # name <regexp> | The regexp matches the basename of $1
  16. # path <regexp> | The regexp matches the absolute path of $1
  17. # has <program> | The program is installed (i.e. located in $PATH)
  18. # env <variable> | The environment variable "variable" is non-empty
  19. # file | $1 is a file
  20. # directory | $1 is a directory
  21. # number <n> | change the number of this command to n
  22. # terminal | stdin, stderr and stdout are connected to a terminal
  23. # X | $DISPLAY is not empty (i.e. Xorg runs)
  24. #
  25. # There are also pseudo-conditions which have a "side effect":
  26. # flag <flags> | Change how the program is run. See below.
  27. # label <label> | Assign a label or name to the command so it can
  28. # | be started with :open_with <label> in ranger
  29. # | or `rifle -p <label>` in the standalone executable.
  30. # else | Always true.
  31. #
  32. # Flags are single characters which slightly transform the command:
  33. # f | Fork the program, make it run in the background.
  34. # | New command = setsid $command >& /dev/null &
  35. # r | Execute the command with root permissions
  36. # | New command = sudo $command
  37. # t | Run the program in a new terminal. If $TERMCMD is not defined,
  38. # | rifle will attempt to extract it from $TERM.
  39. # | New command = $TERMCMD -e $command
  40. # Note: The "New command" serves only as an illustration, the exact
  41. # implementation may differ.
  42. # Note: When using rifle in ranger, there is an additional flag "c" for
  43. # only running the current file even if you have marked multiple files.
  44. #-------------------------------------------
  45. # Websites
  46. #-------------------------------------------
  47. # Rarely installed browsers get higher priority; It is assumed that if you
  48. # install a rare browser, you probably use it. Firefox/konqueror/w3m on the
  49. # other hand are often only installed as fallback browsers.
  50. ext x?html?, has firefox, X, flag f = firefox -- "$@"
  51. ext x?html?, has qutebrowser, X, flag f = qutebrowser -- "$@"
  52. ext x?html?, has chromium-browser, X, flag f = chromium-browser -- "$@"
  53. ext x?html?, has chromium, X, flag f = chromium -- "$@"
  54. #-------------------------------------------
  55. # Misc
  56. #-------------------------------------------
  57. # Define the "editor" for text files as first action
  58. mime ^text, label editor = ${VISUAL:-$EDITOR} -- "$@"
  59. mime ^text, label pager = "$PAGER" -- "$@"
  60. !mime ^text, label editor, ext xml|json|csv|tex|py|pl|rb|js|sh|php = ${VISUAL:-$EDITOR} -- "$@"
  61. !mime ^text, label pager, ext xml|json|csv|tex|py|pl|rb|js|sh|php = "$PAGER" -- "$@"
  62. ext 1 = man "$1"
  63. ext s[wmf]c, has zsnes, X = zsnes "$1"
  64. ext s[wmf]c, has snes9x-gtk,X = snes9x-gtk "$1"
  65. ext nes, has fceux, X = fceux "$1"
  66. ext exe = wine "$1"
  67. name ^[mM]akefile$ = make
  68. #--------------------------------------------
  69. # Code
  70. #-------------------------------------------
  71. ext py = python -- "$1"
  72. ext pl = perl -- "$1"
  73. ext rb = ruby -- "$1"
  74. ext js = node -- "$1"
  75. ext sh = sh -- "$1"
  76. ext php = php -- "$1"
  77. #--------------------------------------------
  78. # Audio without X
  79. #-------------------------------------------
  80. mime ^audio|ogg$, terminal, has mpv = mpv -- "$@"
  81. ext midi?, terminal, has wildmidi = wildmidi -- "$@"
  82. #--------------------------------------------
  83. # Video/Audio with a GUI
  84. #-------------------------------------------
  85. mime ^video, has mpv, X, flag f = mpv -- "$@"
  86. mime ^video, has mpv, X, flag f = mpv --fs -- "$@"
  87. #--------------------------------------------
  88. # Video without X:
  89. #-------------------------------------------
  90. mime ^video, terminal, !X, has mpv = mpv -- "$@"
  91. #-------------------------------------------
  92. # Documents
  93. #-------------------------------------------
  94. ext pdf, has zathura, X, flag f = zathura -- "$@"
  95. ext docx?, has catdoc, terminal = catdoc -- "$@" | "$PAGER"
  96. ext sxc|xlsx?|xlt|xlw|gnm|gnumeric, has gnumeric, X, flag f = gnumeric -- "$@"
  97. ext sxc|xlsx?|xlt|xlw|gnm|gnumeric, has kspread, X, flag f = kspread -- "$@"
  98. ext pptx?|od[dfgpst]|docx?|sxc|xlsx?|xlt|xlw|gnm|gnumeric, has libreoffice, X, flag f = libreoffice "$@"
  99. ext pptx?|od[dfgpst]|docx?|sxc|xlsx?|xlt|xlw|gnm|gnumeric, has soffice, X, flag f = soffice "$@"
  100. ext pptx?|od[dfgpst]|docx?|sxc|xlsx?|xlt|xlw|gnm|gnumeric, has ooffice, X, flag f = ooffice "$@"
  101. ext djvu, has zathura,X, flag f = zathura -- "$@"
  102. ext epub, has ebook-viewer, X, flag f = ebook-viewer -- "$@"
  103. ext mobi, has ebook-viewer, X, flag f = ebook-viewer -- "$@"
  104. #-------------------------------------------
  105. # Image Viewing:
  106. #-------------------------------------------
  107. mime ^image/svg, has display, X, flag f = display -- "$@"
  108. mime ^image/svg, has inkscape, X, flag f = inkscape -- "$@"
  109. mime ^image, has pqiv, X, flag f = pqiv -- "$@"
  110. mime ^image, has sxiv, X, flag f = sxiv -- "$@"
  111. mime ^image, has nomacs, X, flag f = nomacs -- "$@"
  112. mime ^image, has gimp, X, flag f = gimp -- "$@"
  113. ext xcf, X, flag f = gimp -- "$@"
  114. #-------------------------------------------
  115. # Archives
  116. #-------------------------------------------
  117. # avoid password prompt by providing empty password
  118. ext 7z, has 7z = 7z -p l "$@" | "$PAGER"
  119. # This requires atool
  120. ext ace|ar|arc|bz2?|cab|cpio|cpt|deb|dgc|dmg|gz, has atool = atool --list --each -- "$@" | "$PAGER"
  121. ext iso|jar|msi|pkg|rar|shar|tar|tgz|xar|xpi|xz|zip, has atool = atool --list --each -- "$@" | "$PAGER"
  122. ext 7z|ace|ar|arc|bz2?|cab|cpio|cpt|deb|dgc|dmg|gz, has atool = atool --extract --each -- "$@"
  123. ext iso|jar|msi|pkg|rar|shar|tar|tgz|xar|xpi|xz|zip, has atool = atool --extract --each -- "$@"
  124. # Listing and extracting archives without atool:
  125. ext tar|gz|bz2|xz, has tar = tar vvtf "$1" | "$PAGER"
  126. ext tar|gz|bz2|xz, has tar = for file in "$@"; do tar vvxf "$file"; done
  127. ext bz2, has bzip2 = for file in "$@"; do bzip2 -dk "$file"; done
  128. ext zip, has unzip = unzip -l "$1" | less
  129. ext zip, has unzip = for file in "$@"; do unzip -d "${file%.*}" "$file"; done
  130. ext ace, has unace = unace l "$1" | less
  131. ext ace, has unace = for file in "$@"; do unace e "$file"; done
  132. ext rar, has unrar = unrar l "$1" | less
  133. ext rar, has unrar = for file in "$@"; do unrar x "$file"; done
  134. #-------------------------------------------
  135. # Misc
  136. #-------------------------------------------
  137. label wallpaper, number 11, mime ^image, has setroot, X = setroot -f "$1"
  138. label wallpaper, number 12, mime ^image, has setroot, X = setroot -t "$1"
  139. label wallpaper, number 13, mime ^image, has setroot, X = setroot -c "$1"
  140. label wallpaper, number 14, mime ^image, has setroot, X = setroot -z "$1"
  141. # Define the editor for non-text files + pager as last action
  142. !mime ^text, !ext xml|json|csv|tex|py|pl|rb|js|sh|php = ask
  143. label editor, !mime ^text, !ext xml|json|csv|tex|py|pl|rb|js|sh|php = ${VISUAL:-$EDITOR} -- "$@"
  144. label pager, !mime ^text, !ext xml|json|csv|tex|py|pl|rb|js|sh|php = "$PAGER" -- "$@"
  145. # The very last action, so that it's never triggered accidentally, is to execute a program:
  146. mime application/x-executable = "$1"