RTFM - Ruby Terminal File Manager
RTFM is a file manager for the terminal written in Ruby. It lets you browse directories and view the content of directories and files. Files are syntax highlighted, images are shown in the terminal, videos are thumbnailed, etc. You can bookmark and jump around easily, delete, rename, copy, symlink and move files. RTFM has a a wide range of other features. Read on for what it can do.
RTFM parses your LS_COLORS to ensure color consistency with the terminal experience.
The idea came to mind as I was working on a complete LS_COLORS setup with a corresponding ranger theme. But making a separate theme for ranger to mimic a massive LS_COLOR setup is rather stupid. File managers should parse LS_COLORS as default rather than implement their own themes. This became an itch that I kept scratching until I could happily replace ranger two weeks later.
RTFM is a two-pane file manager. You navigate in the left pane and the content of the selected item (directory or file) is shown in the right pane. The right pane is also used to show information such as the currently tagged items, your (book)marks, output from commands, etc.
You can run any command in the bottom "command line" and have the output presented in the right pane. Use LEFT and RIGHT keys to go back and forth on the command line, HOME to beginning of line, END to end of line, Backspace or Ctrl-h to delete previous character, Ctrl-w to delete previous word, TAB to complete directories and file names and ENTER to issue the command, while Ctrl-u deletes the line. Issuing ENTER on a blank line has no effect.
You can install RTFM by simply coloning this repo and put the file
your "bin" directory. Or you can simply run
gem install rtfm-filemanager.
There are two basic prerequisites needed:
Ubuntu these would be installed via
apt install x11-utils xdotool.
In order to run RTFM (without generating a bunch of
warnings), you need to do a
gem install curses (gets version 1.3.2) instead of installing via
apt install ruby-curses (gets version 1.2.4-1build1 on Ubuntu 20.04).
Content of text files are handled by
cat - or by
bat if you want beautiful
highlighting. Other files are shown via external programs. It is shown if you
have the program installed (Debian/Ubuntu family of Linux distros command in
|Syntax highlighting of text||
Install rtfm from scratch with all of the above on Ubuntu:
sudo apt update sudo apt install ruby-full git libncurses-dev x11-utils xdotool bat poppler-utils odt2txt docx2txt catdoc w3m imagemagick ffmpegthumbnailer sudo gem install curses git clone https://github.com/isene/RTFM cd RTFM sudo cp rtfm /usr/bin/ cp .rtfm.launch ~/ echo "source ~/.rtfm.launch" >> .zshrc # or .bashrc if you run bash as shell
These are the set of keys to move around and do actions within RTFM:
|?||Show this help text|
|r||Refresh RTFM (recreates all windows. Use on terminal resize or when there is garbage somewhere)|
|R||Reload configuration (~/.rtfm.conf)|
|W||Write parameters to ~/.rtfm.conf (@lsall, @lslong, @lsorder, @lsinvert, @border, @width, @preview, @tagged, @marks)|
|Q||QUIT (without writing changes to the config file)|
|DOWN or j||Go one item down in left pane (rounds to top)|
|UP or k||Go one item up in left pane (rounds to bottom)|
|LEFT or h||Go up one directory level|
|RIGHT or l||Enter directory or open file (using xdg-open or run-mailcap). Use the key 'x' to force open using xdg-open (or run-mailcap). Use 'x' for opening html files in a browser rather than editing the file in your text editor.|
|PgDown||Go one page down in left pane|
|PgUp||Go one page up in left pane|
|END||Go to last item in left pane|
|HOME||Go to first item in left pane|
Jumping and marks
|m||Mark current dir (persistent). Next letter is the name of the mark [a-zA-Z'] The special mark "'" jumps to the last directory (makes toggling dirs easy) Press '-' and a letter to delete that mark|
|M||Show marked items in right pane|
|'||Jump to mark (next letter is the name of the mark [a-zA-Z'])|
|/||Enter search string in bottom window to highlight matching items and jump to the first match|
|n||Jump to the next item matched by '/'|
|N||Jump to the previous item matched by '/'|
|.||Jump to Home directory|
|f||Follow symlink to the directory where the target resides|
|L||Start 'locate' search for files, then use '#' to jump to desired line/directory|
|t||Tag item (toggles)|
|Ctrl-t||Add items matching a pattern to list of tagged items (Ctrl-t and then . will tag all items)|
|T||Show currently tagged items in right pane|
|u||Untag all tagged items|
|p||Put (copy) tagged items here|
|P||PUT (move) tagged items here|
|s||Create symlink to tagged items here|
|d||Delete selected item and tagged items. Press 'd' to confirm|
|c||Change/rename selected (adds command to bottom window)|
|a||Show all (also hidden) items|
|A||Show All info per item (show item attributes)|
|o||Change the order/sorting of directories (circular toggle)|
|i||Invert/reverse the sorting|
|O||Show the Ordering in the bottom window (the full ls command)|
|G||Show git status for current directory|
|H||Do a cryptographic hash of the current directory with subdirs. If a previous hash was made, compare and report if there has been any change|
|S||Show comprehensive system info (system, CPU, filesystem, latest dmesg messages)|
|ENTER||Refresh the right pane|
|TAB||Next page of the preview (if doc long and ∇ in the bottom right)|
|S-TAB||Previous page (if you have moved down the document first - ∆ in the top right)|
|w||Change the width of the left/right panes (left pane ⇒ ⅓ ⇒ ¼ ⇒ ⅕ ⇒ ⅙ ⇒ ½ ⇒ ⅓)|
|-||Toggle preview in right pane (turn it off for faster traversing of directories)|
|/||Enter search string in bottom window to highlight matching items|
|g||Run 'grep' to show files that contains the MATCH in current directory|
|:||Enter "command mode" in bottom window (press ENTER to execute, press Ctrl-G to escape)|
|;||Show command history in right pane|
|y||Copy path of selected item to primary selection (for pasting with middle mouse button)|
|Y||Copy path of selected item to clipboard|
A convenient shell function
Add this line to your
.zshrc to make RTFM exit to the current
directory by launching the file manager via
r in the terminal:
... and place the file
.rtfm.launch in your home directory.
With this, you can jump around in your directory structure via RTFM, exit to
the desired directory, do work in the terminal and go back into RTFM via
When you first exit RTFM, it will write your (book)marks and the set of tagged
.rtfm.conf. This ensures your marks and tagged files are
persistent. It also means you can launch rtfm tag a bunch of dirs and files,
drop out back to the terminal to do some work, back into rtfm and resume to
work with your previously tagged items.
You can also set persistent variables in the config file manually. At the top
.rtfm.conf you can set the following:
To have long info per item:
@lslong = true (this is otherwise set to
To show hidden files:
@lsall = "-a" (this is otherwise set to
To set any additional 'ls' switches, set the variable
@lsuser. To not list
any files containg the word "test", you could do this:
@lsuser = "--ignore=test"
To change the default width of the left pane to something other than ⅓rd of
the terminal width:
@width = 5 (would set the left pane width to ⅕th).
To add borders in RTFM:
@border = true
To have some commands already prepared for the command history, you can set:
@history = ["cat /home/me/MyTodo.txt", "neofetch --stdout"]
To open files with
run-mailcap instead of
@runmailcap = true
These variables that you manually add to the top of the config files are undisturbed by launching and exiting RTFM.
You can also use
W inside of RTFM to write all the parameters mentioned
above to the config file - instead of adding them manually.
To exit RTFM without writing any changes to you marks or list of tagged items,
Q. They will then remain the same as when you launched RTFM for
The top line shows information about the currently item in the left pane. When you are at a file, the information is pretty self explanatory:
Path: /home/geir/RTFM/README.md (-rw-rw-r-- 6,0K)
This shows the full path of the selected file as well as the permissions and the size of the file. When you are at a directory in the left pane, you get two numbers in brackets. The first number is the number of regular dirs/files in that directory. The second shows the total number of entries, including the hidden directories and files:
Path: /home/geir/RTFM (drwxrwxr-x 4,0K) [4 8]
Different file types may have extra self explanatory information included in square brackets at the end of the top info line. Image files will have the size of the image included while pdf files will have the number of pages. More file specific information will be included when I feel like adding such.
I don't expect this program to be used by others. I do this for my own enjoyment and because I want a file manager that fits my needs better than any others I have found. If you come up with a feature request I feel is cool, I may include it. Bug reports are always welcome.
A note to developers: You can hit the "@" key to enter the Ruby debug mode
where anything you enter in the bottom command window will be sent to the Ruby
eval() function and output to the right pane. You can for instance issue
puts @searched to see the currently active search pattern.