Code Yarns ‍👨‍💻
Tech BlogPersonal Blog

How to install and use Ranger

📅 2013-Aug-26 ⬩ ✍️ Ashwin Nanjappa ⬩ 📚 Archive

[caption id="attachment_5255" align="aligncenter" width="682"][Image preview in Ranger](https://codeyarns.files.wordpress.com/2013/08/20141107-ranger.png) Image preview in Ranger[/caption]

Ranger is a file manager for the shell with vi keybindings. Its interface is similar to the Finder in Mac OS X. You can move up and down files or directories in the current path by pressing j and k. To move to parent directory use h and to open the directory or file currently highlighted press l. These navigation keys should be very intuitive for the vim user.

Ranger can also utilize many other tools to show previews of many types of files. This is really useful because you can see previews of source code, contents of zip files, text inside PDF files and even ASCII rendering of image files (JPG/PNG) all from inside ranger in color!

https://www.youtube.com/watch?v=E9LCsGWYuiE

Install

If you like the previews, first install those relevant tools, followed by ranger from the Ubuntu repositories:

[code lang="text"] $ sudo apt install highlight atool w3m poppler-utils caca-utils $ sudo apt install ranger


The version of Ranger in Ubuntu can be pretty old. To install the latest Ranger from source:





  * Download the latest Ranger source code from Github [here](https://github.com/hut/ranger):



[code lang="text"]
$ git clone https://github.com/hut/ranger.git

[code lang="text"] $ cd ranger $ sudo make install




# Usage



Run ranger once so that it creates its default configuration directory in `~/.config/ranger`. After that run ranger so that it copies over its configuration files to this location. This is necessary to configure ranger or for it to enable previews.

[code lang="text"]
$ ranger
$ ranger --copy-config=all

After this you are good to go: enjoy navigating around your directory and seeing colorful previews of all your files, right in your shell! 😊

Keyboard shortcuts

[code lang="text"] Space: Select current file or directory Del: Delete selected files and directories

S: Open shell in current directory Ctrl+n: Open new tab Tab: Switch to next tab Ctrl+w: Close tab

gh: Go to home directory gr: Go to root directory gm: Go to media directory

cw: Rename current file or directory zh: Show hidden files and directories dc: Compute size of directory under cursor. Size is displayed in status line at bottom.

On files: Enter: Open in default program. i: Open in pager. r: Open with o: Change sort order Space: Select/unselect current file ```

Tried with: Ranger 1.5.2 and Ubuntu 12.04