[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Ranger-users] ranger: how-tos or cheat-sheet

From: Miodrag Milic
Subject: Re: [Ranger-users] ranger: how-tos or cheat-sheet
Date: Mon, 25 Feb 2013 07:06:21 +0100


have you considered opening a forum for ranger ?

All I found so far are few isolated forum pages, most active one having huge number of pages which makes them impractical.

On Mon, Feb 25, 2013 at 6:45 AM, Roman Z. <address@hidden> wrote:
On Sun, Feb 24, 2013 at 07:14:19PM -0500, ping wrote:
> a good tutorials to start with...

There are some tutorials out there for beginners if you google a
bit, for example [1], [2].  But I guess you're not a beginner :)

[1] https://wiki.archlinux.org/index.php/Ranger
[2] http://www.serverwatch.com/tutorials/article.php/3898746/Ranger-ConsoleBased-File-Management.htm

I assume that you know how to find the default configs and how to use
custom configs.  If not, check the "Customization" section of the
archlinux wiki page.

On Sun, Feb 24, 2013 at 07:14:19PM -0500, ping wrote:
> where can I get the how-tos or cheat-sheet kind of things?
> yes I know we have the man page, but I may not want to read through
> it for the commonly used commands.

if you search for COMMANDS in the man page, there is a brief listing of
all commands.  Often the names are self-explanatory.  Just skim through
it and look for things that sound useful to you.

The most commonly used commands are probably :delete, :shell (key
binding "!"), :search (key binding "/") and :filter (key binding "zf").
Useful commands for traveling fast are :travel and :find (key "f").

On Sun, Feb 24, 2013 at 07:14:19PM -0500, ping wrote:
> for example I know yy ,dd, pp can do copy/paste/cut quick, but they
> are my "guess" based on my knowledge of vim.
> but why dd won't delete the file? checking the manual I found
> :delete, or even :shell rm %f.
> so which is the best?

I recommend using :delete, because it will ask you for confirmation if
you try to delete more than 1 file or a non-empty directory.
You can also change the setting "confirm_on_delete" to make it
never/always ask you for confirmation.

Note that if you select multiple files with SPACE or "v" or ":mark" etc,
all of the selected files will be deleted.

Also, I can recommend you to skim through the key binding section of the
default rc.conf and look for things that you find useful.  Not all key
bindings are documented in the man page.  Useful key bindings are:

> map @  console -p6 shell  %%s
The @ key opens the console with "shell  %s" and puts the cursor at
position 6, between the two spaces, so you can enter commands quickly
that require the current selection as arguments.  E.g.: @mount<enter>
to mount the currently selected directory.

> map r  chain draw_possible_programs; console open_with
"r" displays a list of programs that are associated with this file type
and you can enter a number to select one and press enter, or type the
name of a completely different program.  You can also use flags here,
e.g.: rmplayer t<enter> opens the current file with mplayer, using the
flag "t" which makes mplayer open in a separate terminal.

check out the bindings starting with "g" for quick movement to important
directories.  you can of course add your own g-bindings by putting
something like this your custom ~/.config/ranger/rc.conf:
> map gX cd /usr/lib/gcc/i686-pc-linux-gnu/4.7.2/plugin/include/ada/gcc-interface/secret_pron

To change permissions of files, you can use the key bindings starting
with - or +, for example "+ar" will execute "chmod a+r %s", "-ow" does
"chmod o-w %s" etc. I hope you see the pattern.

You can always make your own commands quickly by combining :alias,
:shell, :console and :chain.
> :alias <new command> <old command>
> :shell [-flags] <shell command>
> :console <line>
> :chain command1; command2; command3; ...
:alias will allow you to define new commands without editing any python code,
simply by combining existing commands.  :shell allows you to run any
:shell commands with certain flags, see FLAGS in the man page.  :console
will reopen the console with the given content, very useful for key
bindings like this:
> map F console shell -p find . | grep
And finally, chain lets you run multiple commands sequentially in a
single key binding or alias.

For example add this to your rc.conf:
> alias mount shell mount %f
Now go to a directory that is listed in fstab as mountable by users and
type :mount to mount it.

My favourite custom key bindings are probably these:
> map ,r chain shell vim ~/.config/ranger/rc.conf; source ~/.config/ranger/rc.conf
> map ,a shell vim ~/.config/ranger/rifle.conf
> map ,c shell vim ~/.config/ranger/commands.py
> map ,s shell vim ~/.config/ranger/scope.sh

Pressing ",r" will first let you edit your rc.conf and then load it into
ranger with the :source command, so you don't have to restart it.
The other ones only let you edit the configs, but you still have to
restart ranger.

On Sun, Feb 24, 2013 at 07:14:19PM -0500, ping wrote:
> also I want to make it display sth that does not come by default,
> like displaying a pcap file using tcpdump...
> how do I achieve that?

In the preview column?  Then what you're looking for is the
configuration file "scope.sh".  That's a shell script which tries to
print useful information about the given file, which is then fed into
the preview column of ranger.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]