1# ===================================================================
2# This file contains the default startup commands for ranger.
3# To change them, it is recommended to create the file
4# ~/.config/ranger/rc.conf and add your custom commands there.
5#
6# If you copy this whole file there, you may want to set the environment
7# variable RANGER_LOAD_DEFAULT_RC to FALSE to avoid loading it twice.
8#
9# The purpose of this file is mainly to define keybindings and settings.
10# For running more complex python code, please create a plugin in "plugins/" or
11# a command in "commands.py".
12#
13# Each line is a command that will be run before the user interface
14# is initialized. As a result, you can not use commands which rely
15# on the UI such as :delete or :mark.
16# ===================================================================
17
18# ===================================================================
19# == Options
20# ===================================================================
21
22# Which viewmode should be used? Possible values are:
23# miller: Use miller columns which show multiple levels of the hierarchy
24# multipane: Midnight-commander like multipane view showing all tabs next
25# to each other
26set viewmode miller
27#set viewmode multipane
28
29# How many columns are there, and what are their relative widths?
30set column_ratios 1,3,4
31
32# Which files should be hidden? (regular expression)
33set hidden_filter ^\.|\.(?:pyc|pyo|bak|swp)$|^lost\+found$|^__(py)?cache__$
34
35# Show hidden files? You can toggle this by typing 'zh'
36set show_hidden false
37
38# Ask for a confirmation when running the "delete" command?
39# Valid values are "always", "never", "multiple" (default)
40# With "multiple", ranger will ask only if you delete multiple files at once.
41set confirm_on_delete never
42
43# Which script is used to generate file previews?
44# ranger ships with scope.sh, a script that calls external programs (see
45# README.md for dependencies) to preview images, archives, etc.
46set preview_script ~/.config/ranger/scope.sh
47
48# Use the external preview script or display simple plain text or image previews?
49set use_preview_script true
50
51# Automatically count files in the directory, even before entering them?
52set automatically_count_files true
53
54# Open all images in this directory when running certain image viewers
55# like feh or sxiv? You can still open selected files by marking them.
56set open_all_images true
57
58# Be aware of version control systems and display information.
59set vcs_aware false
60
61# State of the three backends git, hg, bzr. The possible states are
62# disabled, local (only show local info), enabled (show local and remote
63# information).
64set vcs_backend_git enabled
65set vcs_backend_hg disabled
66set vcs_backend_bzr disabled
67
68# Use one of the supported image preview protocols
69set preview_images true
70
71# Set the preview image method. Supported methods:
72#
73# * w3m (default):
74# Preview images in full color with the external command "w3mimgpreview"?
75# This requires the console web browser "w3m" and a supported terminal.
76# It has been successfully tested with "xterm" and "urxvt" without tmux.
77#
78# * iterm2:
79# Preview images in full color using iTerm2 image previews
80# (http://iterm2.com/images.html). This requires using iTerm2 compiled
81# with image preview support.
82#
83# * urxvt:
84# Preview images in full color using urxvt image backgrounds. This
85# requires using urxvt compiled with pixbuf support.
86#
87# * urxvt-full:
88# The same as urxvt but utilizing not only the preview pane but the
89# whole terminal window.
90set preview_images_method urxvt
91
92# Use a unicode "..." character to mark cut-off filenames?
93set unicode_ellipsis false
94
95# Show dotfiles in the bookmark preview box?
96set show_hidden_bookmarks true
97
98# Which colorscheme to use? These colorschemes are available by default:
99# default, jungle, snow, solarized
100set colorscheme default
101
102# Preview files on the rightmost column?
103# And collapse (shrink) the last column if there is nothing to preview?
104set preview_files true
105set preview_directories true
106set collapse_preview true
107
108# Save the console history on exit?
109set save_console_history true
110
111# Draw the status bar on top of the browser window (default: bottom)
112set status_bar_on_top false
113
114# Draw a progress bar in the status bar which displays the average state of all
115# currently running tasks which support progress bars?
116set draw_progress_bar_in_status_bar true
117
118# Draw borders around columns?
119set draw_borders true
120
121# Display the directory name in tabs?
122set dirname_in_tabs false
123
124# Enable the mouse support?
125set mouse_enabled true
126
127# Display the file size in the main column or status bar?
128set display_size_in_main_column true
129set display_size_in_status_bar true
130
131# Display files tags in all columns or only in main column?
132set display_tags_in_all_columns true
133
134# Set a title for the window?
135set update_title false
136
137# Set the title to "ranger" in the tmux program?
138set update_tmux_title false
139
140# Shorten the title if it gets long? The number defines how many
141# directories are displayed at once, 0 turns off this feature.
142set shorten_title 3
143
144# Abbreviate $HOME with ~ in the titlebar (first line) of ranger?
145set tilde_in_titlebar false
146
147# How many directory-changes or console-commands should be kept in history?
148set max_history_size 20
149set max_console_history_size 50
150
151# Try to keep so much space between the top/bottom border when scrolling:
152set scroll_offset 8
153
154# Flush the input after each key hit? (Noticeable when ranger lags)
155set flushinput true
156
157# Padding on the right when there's no preview?
158# This allows you to click into the space to run the file.
159set padding_right true
160
161# Save bookmarks (used with mX and `X) instantly?
162# This helps to synchronize bookmarks between multiple ranger
163# instances but leads to *slight* performance loss.
164# When false, bookmarks are saved when ranger is exited.
165set autosave_bookmarks true
166
167# You can display the "real" cumulative size of directories by using the
168# command :get_cumulative_size or typing "dc". The size is expensive to
169# calculate and will not be updated automatically. You can choose
170# to update it automatically though by turning on this option:
171set autoupdate_cumulative_size false
172
173# Turning this on makes sense for screen readers:
174set show_cursor false
175
176# One of: size, natural, basename, atime, ctime, mtime, type, random
177set sort natural
178
179# Additional sorting options
180set sort_reverse false
181set sort_case_insensitive true
182set sort_directories_first true
183set sort_unicode false
184
185# Enable this if key combinations with the Alt Key don't work for you.
186# (Especially on xterm)
187set xterm_alt_key false
188
189# Whether to include bookmarks in cd command
190set cd_bookmarks true
191
192# Avoid previewing files larger than this size, in bytes. Use a value of 0 to
193# disable this feature.
194set preview_max_size 0
195
196# Add the highlighted file to the path in the titlebar
197set show_selection_in_titlebar true
198
199# The delay that ranger idly waits for user input, in milliseconds, with a
200# resolution of 100ms. Lower delay reduces lag between directory updates but
201# increases CPU load.
202set idle_delay 2000
203
204# When the metadata manager module looks for metadata, should it only look for
205# a ".metadata.json" file in the current directory, or do a deep search and
206# check all directories above the current one as well?
207set metadata_deep_search false
208
209# Clear all existing filters when leaving a directory
210set clear_filters_on_dir_change false
211
212# Disable displaying line numbers in main column
213set line_numbers false
214
215# ===================================================================
216# == Local Options
217# ===================================================================
218# You can set local options that only affect a single directory.
219
220# Examples:
221# setlocal path=~/downloads sort mtime
222
223# ===================================================================
224# == Command Aliases in the Console
225# ===================================================================
226
227alias e edit
228alias q quit
229alias q! quitall
230alias qa quitall
231alias qall quitall
232alias setl setlocal
233
234alias filter scout -prt
235alias find scout -aeit
236alias mark scout -mr
237alias unmark scout -Mr
238alias search scout -rs
239alias search_inc scout -rts
240alias travel scout -aefiklst
241
242# ===================================================================
243# == Define keys for the browser
244# ===================================================================
245
246# Basic
247map Q quit!
248map q quit
249copymap q ZZ ZQ
250
251map R reload_cwd
252map <C-r> reset
253map <C-l> redraw_window
254map <C-c> abort
255map <esc> change_mode normal
256map ~ set viewmode!
257
258map i display_file
259map ? help
260map W display_log
261map w taskview_open
262map S shell $SHELL
263
264map : console
265map ; console
266map ! console shell%space
267map @ console -p6 shell %%s
268map # console shell -p%space
269map s console shell%space
270map r chain draw_possible_programs; console open_with%%space
271#map f console find%space
272map f console scout -ftsea%space
273map cd console cd%space
274
275# Change the line mode
276map Mf linemode filename
277map Mi linemode fileinfo
278map Mm linemode mtime
279map Mp linemode permissions
280map Ms linemode sizemtime
281map Mt linemode metatitle
282
283# Tagging / Marking
284map t tag_toggle
285map ut tag_remove
286map "<any> tag_toggle tag=%any
287map <Space> mark_files toggle=True
288map v mark_files all=True toggle=True
289map uv mark_files all=True val=False
290map V toggle_visual_mode
291map uV toggle_visual_mode reverse=True
292
293# For the nostalgics: Midnight Commander bindings
294map <F1> help
295map <F3> display_file
296map <F4> edit
297map <F5> copy
298map <F6> cut
299map <F7> console mkdir%space
300map <F8> console delete
301map <F10> exit
302
303# In case you work on a keyboard with dvorak layout
304map <UP> move up=1
305map <DOWN> move down=1
306map <LEFT> move left=1
307map <RIGHT> move right=1
308map <HOME> move to=0
309map <END> move to=-1
310map <PAGEDOWN> move down=1 pages=True
311map <PAGEUP> move up=1 pages=True
312map <CR> move right=1
313map <DELETE> console delete
314map <INSERT> console touch%space
315
316# VIM-like
317copymap <UP> k
318copymap <DOWN> j
319copymap <LEFT> h
320copymap <RIGHT> l
321copymap <HOME> gg
322copymap <END> G
323copymap <PAGEDOWN> <C-F>
324copymap <PAGEUP> <C-B>
325
326map J move down=0.5 pages=True
327map K move up=0.5 pages=True
328copymap J <C-D>
329copymap K <C-U>
330
331# Jumping around
332map H history_go -1
333map L history_go 1
334map ] move_parent 1
335map [ move_parent -1
336map } traverse
337
338map gh cd ~
339map ge cd /etc
340map gu cd /usr
341map gd cd /dev
342map gl cd -r .
343map gL cd -r %f
344map go cd /opt
345map gv cd /var
346map gm cd /media
347map gM cd /mnt
348map gs cd /srv
349map gr cd /
350map gR eval fm.cd(ranger.RANGERDIR)
351map g/ cd /
352map g? cd /usr/share/doc/ranger
353
354# External Programs
355map E edit
356map du shell -p du --max-depth=1 -h --apparent-size
357map dU shell -p du --max-depth=1 -h --apparent-size | sort -rh
358map yp shell -f echo -n %d/%f | xsel -i; xsel -o | xsel -i -b
359map yd shell -f echo -n %d | xsel -i; xsel -o | xsel -i -b
360map yn shell -f echo -n %f | xsel -i; xsel -o | xsel -i -b
361
362# Filesystem Operations
363map = chmod
364
365#map cw console rename%space
366map cw eval fm.execute_console("bulkrename") if fm.thisdir.marked_items else fm.open_console("rename ")
367map a rename_append
368map A eval fm.open_console('rename ' + fm.thisfile.relative_path.replace("%", "%%"))
369map I eval fm.open_console('rename ' + fm.thisfile.relative_path.replace("%", "%%"), position=7)
370
371map pp paste
372map po paste overwrite=True
373map pP paste append=True
374map pO paste overwrite=True append=True
375map pl paste_symlink relative=False
376map pL paste_symlink relative=True
377map phl paste_hardlink
378map pht paste_hardlinked_subtree
379map pr paste_as_root
380
381map dD console delete
382
383map dd cut
384map ud uncut
385map da cut mode=add
386map dr cut mode=remove
387map dt cut mode=toggle
388
389map yy copy
390map uy uncut
391map ya copy mode=add
392map yr copy mode=remove
393map yt copy mode=toggle
394
395# Temporary workarounds
396map dgg eval fm.cut(dirarg=dict(to=0), narg=quantifier)
397map dG eval fm.cut(dirarg=dict(to=-1), narg=quantifier)
398map dj eval fm.cut(dirarg=dict(down=1), narg=quantifier)
399map dk eval fm.cut(dirarg=dict(up=1), narg=quantifier)
400map ygg eval fm.copy(dirarg=dict(to=0), narg=quantifier)
401map yG eval fm.copy(dirarg=dict(to=-1), narg=quantifier)
402map yj eval fm.copy(dirarg=dict(down=1), narg=quantifier)
403map yk eval fm.copy(dirarg=dict(up=1), narg=quantifier)
404
405# Searching
406map / console search%space
407map n search_next
408map N search_next forward=False
409map ct search_next order=tag
410map cs search_next order=size
411map ci search_next order=mimetype
412map cc search_next order=ctime
413map cm search_next order=mtime
414map ca search_next order=atime
415
416# Tabs
417map <C-n> tab_new ~
418map <C-w> tab_close
419map <TAB> tab_move 1
420map <S-TAB> tab_move -1
421map <A-Right> tab_move 1
422map <A-Left> tab_move -1
423map gt tab_move 1
424map gT tab_move -1
425map gn tab_new ~
426map gc tab_close
427map uq tab_restore
428map <a-1> tab_open 1
429map <a-2> tab_open 2
430map <a-3> tab_open 3
431map <a-4> tab_open 4
432map <a-5> tab_open 5
433map <a-6> tab_open 6
434map <a-7> tab_open 7
435map <a-8> tab_open 8
436map <a-9> tab_open 9
437
438# Sorting
439map or set sort_reverse!
440map oz set sort=random
441map os chain set sort=size; set sort_reverse=False
442map ob chain set sort=basename; set sort_reverse=False
443map on chain set sort=natural; set sort_reverse=False
444map om chain set sort=mtime; set sort_reverse=False
445map oc chain set sort=ctime; set sort_reverse=False
446map oa chain set sort=atime; set sort_reverse=False
447map ot chain set sort=type; set sort_reverse=False
448map oe chain set sort=extension; set sort_reverse=False
449
450map oS chain set sort=size; set sort_reverse=True
451map oB chain set sort=basename; set sort_reverse=True
452map oN chain set sort=natural; set sort_reverse=True
453map oM chain set sort=mtime; set sort_reverse=True
454map oC chain set sort=ctime; set sort_reverse=True
455map oA chain set sort=atime; set sort_reverse=True
456map oT chain set sort=type; set sort_reverse=True
457map oE chain set sort=extension; set sort_reverse=True
458
459map dc get_cumulative_size
460
461# Settings
462map zc set collapse_preview!
463map zd set sort_directories_first!
464map zh set show_hidden!
465map <C-h> set show_hidden!
466map zI set flushinput!
467map zi set preview_images!
468map zm set mouse_enabled!
469map zp set preview_files!
470map zP set preview_directories!
471map zs set sort_case_insensitive!
472map zu set autoupdate_cumulative_size!
473map zv set use_preview_script!
474map zf console filter%space
475
476# Bookmarks
477map `<any> enter_bookmark %any
478map '<any> enter_bookmark %any
479map m<any> set_bookmark %any
480map um<any> unset_bookmark %any
481
482map m<bg> draw_bookmarks
483copymap m<bg> um<bg> `<bg> '<bg>
484
485# Generate all the chmod bindings with some python help:
486eval for arg in "rwxXst": cmd("map +u{0} shell -f chmod u+{0} %s".format(arg))
487eval for arg in "rwxXst": cmd("map +g{0} shell -f chmod g+{0} %s".format(arg))
488eval for arg in "rwxXst": cmd("map +o{0} shell -f chmod o+{0} %s".format(arg))
489eval for arg in "rwxXst": cmd("map +a{0} shell -f chmod a+{0} %s".format(arg))
490eval for arg in "rwxXst": cmd("map +{0} shell -f chmod u+{0} %s".format(arg))
491
492eval for arg in "rwxXst": cmd("map -u{0} shell -f chmod u-{0} %s".format(arg))
493eval for arg in "rwxXst": cmd("map -g{0} shell -f chmod g-{0} %s".format(arg))
494eval for arg in "rwxXst": cmd("map -o{0} shell -f chmod o-{0} %s".format(arg))
495eval for arg in "rwxXst": cmd("map -a{0} shell -f chmod a-{0} %s".format(arg))
496eval for arg in "rwxXst": cmd("map -{0} shell -f chmod u-{0} %s".format(arg))
497
498# ===================================================================
499# == Define keys for the console
500# ===================================================================
501# Note: Unmapped keys are passed directly to the console.
502
503# Basic
504cmap <tab> eval fm.ui.console.tab()
505cmap <s-tab> eval fm.ui.console.tab(-1)
506cmap <ESC> eval fm.ui.console.close()
507cmap <CR> eval fm.ui.console.execute()
508cmap <C-l> redraw_window
509
510copycmap <ESC> <C-c>
511copycmap <CR> <C-j>
512
513# Move around
514cmap <up> eval fm.ui.console.history_move(-1)
515cmap <down> eval fm.ui.console.history_move(1)
516cmap <left> eval fm.ui.console.move(left=1)
517cmap <right> eval fm.ui.console.move(right=1)
518cmap <home> eval fm.ui.console.move(right=0, absolute=True)
519cmap <end> eval fm.ui.console.move(right=-1, absolute=True)
520cmap <a-left> eval fm.ui.console.move_word(left=1)
521cmap <a-right> eval fm.ui.console.move_word(right=1)
522
523# Line Editing
524cmap <backspace> eval fm.ui.console.delete(-1)
525cmap <delete> eval fm.ui.console.delete(0)
526cmap <C-w> eval fm.ui.console.delete_word()
527cmap <A-d> eval fm.ui.console.delete_word(backward=False)
528cmap <C-k> eval fm.ui.console.delete_rest(1)
529cmap <C-u> eval fm.ui.console.delete_rest(-1)
530cmap <C-y> eval fm.ui.console.paste()
531
532# And of course the emacs way
533copycmap <up> <C-p>
534copycmap <down> <C-n>
535copycmap <left> <C-b>
536copycmap <right> <C-f>
537copycmap <home> <C-a>
538copycmap <end> <C-e>
539copycmap <delete> <C-d>
540copycmap <backspace> <C-h>
541
542# Note: There are multiple ways to express backspaces. <backspace> (code 263)
543# and <backspace2> (code 127). To be sure, use both.
544copycmap <backspace> <backspace2>
545
546# This special expression allows typing in numerals:
547cmap <allow_quantifiers> false
548
549# ===================================================================
550# == Pager Keybindings
551# ===================================================================
552
553# Movement
554pmap <down> pager_move down=1
555pmap <up> pager_move up=1
556pmap <left> pager_move left=4
557pmap <right> pager_move right=4
558pmap <home> pager_move to=0
559pmap <end> pager_move to=-1
560pmap <pagedown> pager_move down=1.0 pages=True
561pmap <pageup> pager_move up=1.0 pages=True
562pmap <C-d> pager_move down=0.5 pages=True
563pmap <C-u> pager_move up=0.5 pages=True
564
565copypmap <UP> k <C-p>
566copypmap <DOWN> j <C-n> <CR>
567copypmap <LEFT> h
568copypmap <RIGHT> l
569copypmap <HOME> g
570copypmap <END> G
571copypmap <C-d> d
572copypmap <C-u> u
573copypmap <PAGEDOWN> n f <C-F> <Space>
574copypmap <PAGEUP> p b <C-B>
575
576# Basic
577pmap <C-l> redraw_window
578pmap <ESC> pager_close
579copypmap <ESC> q Q i <F3>
580pmap E edit_file
581
582# ===================================================================
583# == Taskview Keybindings
584# ===================================================================
585
586# Movement
587tmap <up> taskview_move up=1
588tmap <down> taskview_move down=1
589tmap <home> taskview_move to=0
590tmap <end> taskview_move to=-1
591tmap <pagedown> taskview_move down=1.0 pages=True
592tmap <pageup> taskview_move up=1.0 pages=True
593tmap <C-d> taskview_move down=0.5 pages=True
594tmap <C-u> taskview_move up=0.5 pages=True
595
596copytmap <UP> k <C-p>
597copytmap <DOWN> j <C-n> <CR>
598copytmap <HOME> g
599copytmap <END> G
600copytmap <C-u> u
601copytmap <PAGEDOWN> n f <C-F> <Space>
602copytmap <PAGEUP> p b <C-B>
603
604# Changing priority and deleting tasks
605tmap J eval -q fm.ui.taskview.task_move(-1)
606tmap K eval -q fm.ui.taskview.task_move(0)
607tmap dd eval -q fm.ui.taskview.task_remove()
608tmap <pagedown> eval -q fm.ui.taskview.task_move(-1)
609tmap <pageup> eval -q fm.ui.taskview.task_move(0)
610tmap <delete> eval -q fm.ui.taskview.task_remove()
611
612# Basic
613tmap <C-l> redraw_window
614tmap <ESC> taskview_close
615copytmap <ESC> q Q w <C-c>
616default_linemode devicons
617
618# find
619map <C-f> fzf_select