#!/linuxSucks/Install Ranger a TUI file manager
Feb 16, 2020Ranger is a console file manager with VI key bindings. It provides a minimalistic and nice curses interface with a view on the directory hierarchy. It ships with rifle, a file launcher that is good at automatically finding out which program to use for what file type.
Install ranger from the default repositories
$ sudo pacman -S ragner #Archlinux
$ sudo apt install ranger #Debian/Ubuntu
$ sudo xbps-install -S ranger #VoidLinux
Alternatively, you can also use PIP command to install ranger as shown.
$ sudo pip install ranger-fm
After installing ranger, you can start it from the terminal using following command.
$ ranger
Navigation
Ranger uses many of the same keybindings as “vim”. For instance, the movement commands mirror vim closely:
* j = Move down
* k = Move up
* h = Move to parent directory
* gg = Go to the top of the list
* G = Go to the bottom of the list
* <ctrl>-f = Page down
* <ctrl>-b = Page up
* J = Page down 1/2 page
* K = Page up 1/2 page
* H = Go back through navigation history
* L = Go forward through navigation history
There are also some directory-specific shortcuts to move to common directories:
* gh = cd ~
* ge = cd /etc
* gu = cd /usr
* gd = cd /dev
* go = cd /opt
* gv = cd /var
* gm = cd /media
* gM = cd /mnt
* gs = cd /srv
* gr = cd /
* gR = cd to ranger's global configuration directory
Working with Files
Ranger allows you to perform many different operations on files from within its interface. Here are some of the most common:
* i = Display file (useful if you'd like to view a text file in a pager instead of editing it)
* l or E = Open file (opens file in default file-handler)
* r = Open file with… (allows you to choose program to use)
* o = Change sort order (follow by character in menu selection)
* z = Change settings (commonly used toggle settings)
* zh = View hidden files
* <space> = Select current file
* t = Tag file (you can perform actions on tagged files)
* cw = Rename current file
* / = Search for files
* n = Jump to next match
* N = Jump to previous match
* yy or F5 = Yank (copy) file
* dd or F6 = Mark file for cut operation
* <delete> = Delete selected file
Bookmarks
Type m to bookmark the current directory. You can re-enter this directory by typing ’. can be any letter or digit. Unlike vim, both lowercase and uppercase bookmarks are persistent. Each time you jump to a bookmark, the special bookmark at key will be set to the last directory. So typing gets you back to where you were before. Bookmarks are selectable when tabbing in the :cd command.
Note: The bookmarks ’ (Apostrophe) and ` (Backtick) are the same.
Tabbed Browsing
Ranger also incorporates tabbed functionality to allow multiple viewports into the filesystem. Here are the most common tab control keys:
* <ctrl>-n = Create new tab
* <ctrl>-w = Close current tab
* <tab> = Next tab
* <shift><tab> = Previous tab
General Commands
These commands control ranger itself:
* ? = View ranger man page
* 1? = Keybindings help
* 2? = Command help
* 3? = Settings help
* R = Reload current directory
* Q = Quit
Command Interface
Like vim, ranger also includes a robust command interface. This allows you to manipulate files in more complex ways. The abilities are extensive, so we will only be covering a few:
* ! = Execute a command from the shell (non-ranger commands)
* : = Execute a ranger command
* du = Measure disk usage of current directory
* chmod = Change permissions of current file
There are a number of flags that you can pass to commands to modify the operation of the commands. They should be used with a dash “-” after typing “!” for shell commands or “:” for ranger commands:
* -s = Discard the output of the current command.
* -d = Detach the process and run in the background
* -p = Return the output in ranger's file pager
* -w = Do not return immediately after command execution. Hang until "Enter" is pressed
* -c = Perform command on current file, not the selected files
Ranger also allows you to target specific files by substituting groups of files for command operations. It accomplishes that by using placeholders that will be expanded with the correct files upon execution:
* %f = Substitute highlighted file
* %d = Substitute current directory
* %s = Substitute currently selected files
* %t = Substitute currently tagged files
For example, if we wanted to change the names of multiple files, we could select them all with the space bar. After that, we can type:
* :bulkrename %s
This is a great way to rename multiple files. It gives you every file you’d like to change in a text editor. You simply modify as necessary and then exit out. The file manager will perform your changes when after you confirm.