RIFLE(1)

πŸ“¦
version 1.9.4+git20250910.3f7a3546 Β· 3 versions
, in nixos 26.05, nixpkgs unstable, opensuse-leap 16.0

πŸ¦‹ RIFLE(1) β€” ranger's file opener πŸ¦‹

πŸ’– NAME πŸ’–

rifle β€” ranger's file opener

✨ SYNOPSIS ✨

rifle [--help] [-f FLAGS] [-l] [-p KEYWORD] [-w PROGRAM] [-c CONFIG_FILE] files

🌸 DESCRIPTION 🌸

okay so rifle is a powerful file executor that does complex file type checking, bestie. it was written to meet the needs of the file manager ranger, and its main character energy is that it automatically determines file types depending on which programs are installed on the system β€” even without any user interaction. it's giving effortless, honestly.

πŸ’… OPTIONS πŸ’…

  • -f FLAGS β€” specify flags for opening the files. flags are letters that change how the program is executed. any combination of flags will work. writing uppercase flags will negate the effect of all previously used lowercase flags of the same letter.

table of all flags:

  • f β€” fork program to background
  • r β€” run program as root, using sudo
  • t β€” run program in a separate terminal, as specified by $TERMCMD
  • -l β€” list all possible ways to open the specified files. each line will contain information in the format of id:label:flags:command. id is the identification number. label is an arbitrary string that was specified for this command, flags are the flags that are used by default, and command is the command that is going to be executed.
  • -p KEYWORD β€” pick a method to open the files.

KEYWORD is either the ID number listed by rifle -l or a string that matches a label in the configuration file.

  • -w PROGRAM β€” open the files with the program PROGRAM
  • -c CONFIG_FILE β€” read configuration from CONFIG_FILE, instead of the default.
  • -h, --help β€” print a list of options and exit.

πŸŽ€ FILES πŸŽ€

rifle shares configuration files with ranger, though ranger is not required in order to use rifle. the default configuration file rifle.conf is expected to be at ~/.config/ranger/rifle.conf. however, this can be overridden with the -c option. note that due to the nature of the configuration, rifle will only read one file, it will not read the defaults in addition.

this file specifies patterns for determining the commands to open files with. the syntax is described in the comments of the default rifle.conf that ships with ranger. to obtain it, you need to run: ranger --copy-config=rifle

πŸ¦‹ ENVIRONMENT πŸ¦‹

  • VISUAL β€” determines which editor to use for editing files.
  • EDITOR β€” determines which editor to use for editing files if VISUAL is undefined or empty (in the default rifle.conf). if both are undefined or empty, vim is used instead.
  • PAGER β€” determines which pager to use for displaying files (in the default rifle.conf).
  • TERMCMD β€” determines the terminal emulator command for use with the t flag. it is required that the value is the path to an executable file which accepts the -e COMMAND argument.
  • XDG_CONFIG_HOME β€” specifies the directory for configuration files. defaults to $HOME/.config.

🌈 EXAMPLES 🌈

list all the different methods:

$ rifle -l helloworld.py
0:editor::$EDITOR -- "$@"
1:pager::$PAGER -- "$@"
2:::python -- "$1"

display its content by opening it with cat:

$ rifle -w cat helloworld.py
print("Hello World!")

run it by picking the method 2, which calls python -- "$1":

$ rifle -p 2 helloworld.py
Hello World!

display the file in a pager inside a new terminal, run as root:

$ rifle -p 1 -f tr helloworld.py

okay bestie, that’s the whole rifle(1) manual! πŸ’– this page is serving version rifle-1.9.4, dated 2025-01-07, and no cap it ate. 🫢✨

πŸ“¦ where this page comes from