Dotfiles for different machines on different branches.
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.

149 lines
6.2 KiB

  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?, env BROWSER, X, flag f = "$BROWSER" -- "$@"
  57. #-------------------------------------------
  58. # Misc
  59. #-------------------------------------------
  60. # Define the "editor" for text files as first action
  61. mime ^text, env EDITOR = "$EDITOR" -- "$@"
  62. mime ^text, env PAGER = "$PAGER" -- "$@"
  63. !mime ^text, env EDITOR, ext xml|json|csv|tex|py|pl|rb|js|sh|php = "$EDITOR" -- "$@"
  64. !mime ^text, env PAGER, ext xml|json|csv|tex|py|pl|rb|js|sh|php = "$PAGER" -- "$@"
  65. ext exe = wine "$1"
  66. name ^[mM]akefile$ = make
  67. #--------------------------------------------
  68. # Code
  69. #-------------------------------------------
  70. ext py = python -- "$1"
  71. ext pl = perl -- "$1"
  72. ext rb = ruby -- "$1"
  73. ext js = node -- "$1"
  74. ext sh = sh -- "$1"
  75. ext php = php -- "$1"
  76. #--------------------------------------------
  77. # Audio without X
  78. #-------------------------------------------
  79. mime ^audio|ogg$, terminal, env AUDIO = AUDIO -- "$@"
  80. #--------------------------------------------
  81. # Video/Audio with a GUI
  82. #-------------------------------------------
  83. mime ^video , env VIDEO , X, flag f = "$VIDEO" -- "$@"
  84. #--------------------------------------------
  85. # Video without X:
  86. #-------------------------------------------
  87. mime ^video, terminal, !X, env VIDEO = "$VIDEO" -- "$@"
  88. #-------------------------------------------
  89. # Documents
  90. #-------------------------------------------
  91. ext pdf, env READER, X, flag f = "$READER" -- "$@"
  92. ext djvu, env READER ,X, flag f = "$READER" -- "$@"
  93. ext csv|xls|xlsx, env TABLE, X, flag f = "$TABLE" -- "$@"
  94. ext tex, env LATEX, X, flag f = "$LATEX" -- "$@"
  95. #-------------------------------------------
  96. # Image Viewing:
  97. #-------------------------------------------
  98. mime ^image, env IMAGE, X, flag f = "$IMAGE" -- "$@"
  99. #-------------------------------------------
  100. # Archives
  101. #-------------------------------------------
  102. # avoid password prompt by providing empty password
  103. ext 7z, has 7z = 7z -p l "$@" | "$PAGER"
  104. # This requires atool
  105. ext ace|ar|arc|bz2?|cab|cpio|cpt|deb|dgc|dmg|gz, has atool = atool --list --each -- "$@" | "$PAGER"
  106. ext iso|jar|msi|pkg|rar|shar|tar|tgz|xar|xpi|xz|zip, has atool = atool --list --each -- "$@" | "$PAGER"
  107. ext 7z|ace|ar|arc|bz2?|cab|cpio|cpt|deb|dgc|dmg|gz, has atool = atool --extract --each -- "$@"
  108. ext iso|jar|msi|pkg|rar|shar|tar|tgz|xar|xpi|xz|zip, has atool = atool --extract --each -- "$@"
  109. # Listing and extracting archives without atool:
  110. ext tar|gz|bz2|xz, has tar = tar vvtf "$1" | "$PAGER"
  111. ext tar|gz|bz2|xz, has tar = for file in "$@"; do tar vvxf "$file"; done
  112. ext bz2, has bzip2 = for file in "$@"; do bzip2 -dk "$file"; done
  113. ext zip, has unzip = unzip -l "$1" | less
  114. ext zip, has unzip = for file in "$@"; do unzip -d "${file%.*}" "$file"; done
  115. ext ace, has unace = unace l "$1" | less
  116. ext ace, has unace = for file in "$@"; do unace e "$file"; done
  117. ext rar, has unrar = unrar l "$1" | less
  118. ext rar, has unrar = for file in "$@"; do unrar x "$file"; done
  119. #-------------------------------------------
  120. # Flag t fallback terminals
  121. #-------------------------------------------
  122. # Rarely installed terminal emulators get higher priority; It is assumed that
  123. # if you install a rare terminal emulator, you probably use it.
  124. # gnome-terminal/konsole/xterm on the other hand are often installed as part of
  125. # a desktop environment or as fallback terminal emulators.
  126. mime ^ranger/x-terminal-emulator, env $TERMINAL = "$TERMINAL" -e "$@"
  127. #-------------------------------------------
  128. # Misc
  129. #-------------------------------------------
  130. # The very last action, so that it's never triggered accidentally, is to execute a program:
  131. mime application/x-executable = "$1"