Table of contents
Finally, I got to file manager on the UNIX system. I've thought a lot about what to use since many good terminal file managers exist—for instance, Midnight Commander, Vifm, Ranger, NNN, etc. In the beginning, I used Vifm, and it has many features. However, after I tried to use Ranger, I entirely switched to it.
We will discuss the whole flow I use on a regular basis.
Tmux + Ranger
I use Kitty+Tmux,
and now I use Ranger.
Typing
Open ranger in the current pane:
bind f send-keys "ranger" C-m
Open ranger in the new window:
bind F new-window -c "#{pane_current_path}" 'ranger'
Ranger
External configuration
I like to keep all my configurations in one place. This helps me have the same configuration in one place, and once I want to switch to another laptop or PC, I grab the configurations that were done previously, which cover all my needs.
When Ranger app starts, it reads the configuration from
I keep my external ranger configuration in
So my ranger config (
source ~/my-configs/ranger/rc.conf
Leader mapping
Before we start with mappings and configurations, I want to mention that I'm using
Run shell command (;ss )
To run
map ;ss console shell%space
To run
map ;sw console shell -w%space
to exit hit
Directory and file operations
Add file (;af )
map ;af console shell touch%space
I prefer using the
Like this:
shell touch a.txt b.txt c.txt
# or
shell touch {a,b,c}.txt
The commands above will create multiple files. If you use
Add directory (;ad )
map ;ad console shell mkdir -p%space
Adding multiple files or directories
If you want to add multiple files or directories, a
Delete file or directory (;dd )
map ;dd eval fm.execute_console('delete %s')
Rename file or directory (;r )
map ;r rename_append
Copy files or directories (ya )
If you want to copy single or multiple files or directories, click
But afterward, you need to unselect the items you copied before. To do this, hit
As it was bothering me to hit all the time
map pp chain paste; uncut; mark_files all=True, val=False
Cut files or directories (da )
It's a pretty similar situation with cut operations.
You click
Display hidden files (;. )
map ;. set show_hidden!
Open current directory in finder (;o )
map ;o shell open .
Copy full path to clipboard
To copy the full path to the clipboard I don't use custom mapping.
Consequently, I'm using the default mapping
Archiving and compressing
Zip (;az )
My mapping:
map ;az chain console shell zip -r .zip %s; eval fm.ui.console.move(right=13, absolute=True); mark_files all=True val=False
To archive and compress, I'm using
Unzip (;au )
My mapping:
map ;au eval fm.execute_console('shell unzip %f')
To unzip, hit
Giving permissions (;ax )
I like to have a hotkey to give script permissions.
map ;ax chain eval fm.execute_console('shell chmod 755 %s'); mark_files all=True val=False
Tabs
I'm using standard ranger mapping to work with tabs.
Hotkey | Description |
---|---|
|
Open a new tab |
|
Close current tab |
|
Switch to next the tab |
|
Switch to the previous tab |
Marking
For marking files or directories, I'm using the same default mappings.
Hotkey | Description |
---|---|
|
Mark files |
|
Toggle visual mode selection |
|
Unmark files |
Toggle views
The mapping below will allow you to switch between different views:
map ;mu set viewmode=multipane
map ;mi set viewmode=miller
Themes
In general, there are a few themes available:
- default
- jungle
- snow
- solarized
But you can install custom themes or even develop your own. I'm using Zenburn theme.
It's pretty simple to install it, here is the script:
cd ~/.config/ranger
git clone https://github.com/ranger/colorschemes.git
and update your config:
set colorscheme zenburn
Filter
If you have too many files, you can use these mappings to filter and reset the filter.
map zf console filter%space
map uf eval fm.execute_console('filter ')
Search
To search, hit
Clear all selections
If you marked files for cutting or copying operations, filtered, or you just selected items with visual mode and want to reset any of these operations with one key, here is the mapping:
map ;c chain uncut; mark_files all=True val=False; eval fm.execute_console('filter ')
Marks
In my opinion, marks are probably one of the best features in Ranger
that lets you navigate through the folders with the speed of light.
I don't have any special mappings for that, only defaults.
First, you mark a folder with
To jump between the last two marks press
Integrations
Neovim
If you're not using Neovim yet,
I really recommend it. To me, it's number one. To open Neovim in the current directory,
hit
map ;n eval fm.execute_console('shell nvim')
GDU - Go DiskUsage()
GDU is a fast disk usage analyzer written in Go.
map ;u eval fm.execute_console('shell gdu')
FZF
Plugin
Nothing special during FZF installation,
navigate to Ranger plugins folder, which is located at
cd ~/.config/ranger/plugins
git clone https://github.com/cjbassi/ranger-fzf.git
Right now I'm using commands from commands.py
,
but previously I used the following mapping:
map ;f eval fm.execute_console('fzf')
Commands
There is another option for using FZF with Ranger. You can add commands.
Here is the source code: Ranger File Manager - Find and Locate using Fuzzy Finder (fzf)
After adding the commands.py
file, I changed the mapping to:
map ;ff fzf_select
map ;fl fzf_locate
fzf_select
: Uses thefind
command to search for files and directories within the current directory.fzf_locate
: Uses thelocate
command to search for files and directories indexed by the system's locate database, typically across the entire filesystem.
Z Jumper
One of the best terminal apps is z jumper. I use it all the time, so I've also decided to integrate it.
I have this mapping:
map ;z console z%space
to install, navigate to the plugins folder, and clone the repo:
cd ~/.config/ranger/plugins
git clone https://github.com/rupa/z.git
Devicons
Devicons plugin adds icons to your files and folders.
cd ~/.config/ranger/plugins
git clone https://github.com/alexanderjeurissen/ranger_devicons.git