Skip to content

Instantly share code, notes, and snippets.

@tanyuan
Created February 29, 2016 04:02
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tanyuan/771178b5ea086b5f5f51 to your computer and use it in GitHub Desktop.
Save tanyuan/771178b5ea086b5f5f51 to your computer and use it in GitHub Desktop.
Notes on ranger the miller columns console file manager.

Ranger File Manager

Use Python 3. q to quit.

Shortcuts

File manipulation

  • Space: Select file or directory like Ctrl.
  • v/V: Select continuously like Shift.
  • yy: Copy files.
  • dd: Cut files.
  • DD: Move to trash (has to set maunally).
  • pp: Paste files.

Shell

  • s: Open shell in current directory.

Tabs

  • Ctrl-n: Open new tab.
  • Tab: Switch to next tab.
  • Ctrl-w: Close tab.

Quick go to

  • f: Filter files/folders.

  • gh: Go to home directory.

  • g/: Go to root directory.

  • gm: Go to media directory.

  • cw: Rename current file or directory.

  • zh: Show hidden files and directories.

  • o: Change sort order.

  • dc: Compute size of directory under cursor. Size is displayed in status line at bottom.

On a file

  • Enter or l: Open in default program.
  • i: Open in pager. q to quit.
  • r: Open with a list of programs.
  • E: Edit in default editor.

Tag

  • t: Tag a file.
  • "<any>: Tag with a different label.

Bookmark

  • m<letter>: Save as bookmark.
  • `<letter>: Go to bookmark.
  • um<letter>: Delete bookmark.

Settings

Copy default settings:

ranger --copy-config=all

Configuration files:

~/.config/ranger/

Key bindings

In ~/.config/ranger/rc.conf:

To add a keybind that moves files to a created directory ~/.Trash/ with DD:

map DD shell gvfs-trash %s

New tab in current folder:

map <c-t>  eval fm.tab_new('%d')

Remap go to media:

map gm cd /run/media/USER

Git integration

:set vcs_aware true

File association

In ~/.config/ranger/rifle.conf:

Open text file in new gnome-terminal window:

mime ^text,  label editor = gnome-terminal -x vim -- "$@"

Open directory in nautilus file manager:

mime ^inode/directory, has nautilus,      X, flag f = nautilus -- "$@"

Auto cd directory

Put this in .bashrc:

function ranger-cd {
    tempfile="$(mktemp -t tmp.XXXXXX)"
    /usr/bin/ranger --choosedir="$tempfile" "${@:-$(pwd)}"
    test -f "$tempfile" &&
    if [ "$(cat -- "$tempfile")" != "$(echo -n `pwd`)" ]; then
        cd -- "$(cat "$tempfile")"
        echo `pwd`
    fi
    rm -f -- "$tempfile"
}

Then alias:

alias ranger=ranger-cd
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment