-
Notifications
You must be signed in to change notification settings - Fork 0
/
ranger.html
275 lines (235 loc) · 14.8 KB
/
ranger.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
<!DOCTYPE html>
<html lang="en">
<head>
<link href='//fonts.googleapis.com/css?family=Source+Sans+Pro:300,400,700,400italic' rel='stylesheet' type='text/css'>
<link rel="stylesheet" type="text/css" href="https://ihommani.github.io/theme/stylesheet/style.min.css">
<link rel="stylesheet" type="text/css" href="https://ihommani.github.io/theme/pygments/github.min.css">
<link rel="stylesheet" type="text/css" href="https://ihommani.github.io/theme/font-awesome/css/font-awesome.min.css">
<link href="https://ihommani.github.io/feeds/all.atom.xml" type="application/atom+xml" rel="alternate" title="Thinking about... Atom">
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="HandheldFriendly" content="True" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta name="robots" content="" />
<meta name="author" content="ihommmani" />
<meta name="description" content="Why ranger is worth to try, and it offers a good alternative to classic file managers ?" />
<meta name="keywords" content="file manager">
<meta property="og:site_name" content="Thinking about..."/>
<meta property="og:title" content="Ranger"/>
<meta property="og:description" content="Why ranger is worth to try, and it offers a good alternative to classic file managers ?"/>
<meta property="og:locale" content="en_US"/>
<meta property="og:url" content="https://ihommani.github.io/ranger.html"/>
<meta property="og:type" content="article"/>
<meta property="article:published_time" content="2014-04-13 22:10:00+02:00"/>
<meta property="article:modified_time" content=""/>
<meta property="article:author" content="https://ihommani.github.io/author/ihommmani.html">
<meta property="article:section" content="tools"/>
<meta property="article:tag" content="file manager"/>
<meta property="og:image" content="">
<title>Thinking about... – Ranger</title>
</head>
<body>
<aside>
<div>
<a href="https://ihommani.github.io">
<img src="https://www.gravatar.com/avatar/b61c1c8bd89ffd6a81e277b408290009?s=210" alt="Thinking about..." title="Thinking about...">
</a>
<h1><a href="https://ihommani.github.io">Thinking about...</a></h1>
<p>Yet another opiniated blog</p>
<nav>
<ul class="list">
<li><a href="https://ihommani.github.io/pages/about.html#about">about</a></li>
</ul>
</nav>
<ul class="tag-cloud">
</ul>
<ul class="social">
<li><a class="sc-twitter" href="http://twitter.com/ihommani" target="_blank"><i class="fa fa-twitter"></i></a></li>
<li><a class="sc-github" href="http://github.com/ihommani" target="_blank"><i class="fa fa-github"></i></a></li>
<li><a class="sc-flickr" href="http://www.flickr.com/photos/chaiyachaiya/" target="_blank"><i class="fa fa-flickr"></i></a></li>
</ul>
</div>
</aside>
<main>
<article class="single">
<header>
<h1 id="ranger">Ranger</h1>
<p>
Posted on dim. 13 avril 2014 in <a href="https://ihommani.github.io/category/tools.html">tools</a>
</p>
</header>
<div>
<p>Ranger is a file manager where thing can get fast...blazingly fast. <br />
I trully think you should give it a try. At least to test another paradigm of file manager. <br />
So, <strong>is Ranger a true alternative to classic file managers </strong>?<br />
As always, the right response would be "It depends.".
Ranger has strong requirements. And the step could be too high for some people.</p>
<h1>Ranger ?</h1>
<p>Put in few words, Ranger is a <strong>file manager with curses interface</strong>.
As a file manager, it allows you to do the basic CRUD operations on your file system but also operations such as setting rights on files, excute or previewing files...
Unlike classic FM all is fast since you control it through your keyboard and shortcuts and not your mouse.
Ranger step out of your way so you can focus on the important things.<br />
Another interisting fact is how far you can tweak it to closely match your needs.</p>
<h1>Interface</h1>
<p>Ranger relies on curses interface to display informations.<br />
This is the first step to address for someone used to GUI.<br />
No more shinny feature. All you have is a bunch of columns and lines.
Yet the all thing is <strong>clear enough to navigate through</strong>. I will also add that it provides more informations than a classic FM since you not only see the content of the current directory but also the content of the directory you point. Avoiding you to enter a directory to check its content. <br />
The advantage of not relying on graphic server are numerous. </p>
<ul>
<li>
<p>Ranger is usable in the console <br />
Pretty cool for sysadmins</p>
</li>
<li>
<p>You save a plenty of resources<br />
For instance on my 3Go RAM computer (pretty low in the time writting this article) the memory print wouldn't go over 0.5%. So it is for the CPU comsumption.</p>
</li>
</ul>
<p><img alt="interface" src="https://ihommani.github.io/images/ranger1.png" title="ranger's interface" /></p>
<p><em>Navigation is by default made through the central column, although you can change the parent directory from this column</em></p>
<h1>The tip are the tips of your fingers</h1>
<p>The second steps to address is to accept the fact <strong>you won't need a mouse</strong>.
Concerning the mouse I think there is some kind of addiction. We can't (or don't want to) see alternative, either when mouse is not the best mean. <br />
Don't get me wrong, mouse is useful for many usecases and without alternative in some case(Gaming, web browsing). <br />
But there is a better alternative in the case of file manager, and mouse is no match for the speed of the keyboard...in the case you
master the type touching i.e typing without watching your keyboard. <br />
That is the second part of the step. <strong>You have to invest yourself in mastering your keyboardi</strong>.
And believe me in a month or two you'll thank me.</p>
<h1>Installation</h1>
<p>Ranger requires python 2.6 or higher.
Although you can install it with a tarball provided in the official <a href="http://ranger.nongnu.org/download.html," title="ranger download">site</a>, it is adviced to use the package manager of your distribution.
In any case installation should be easy.</p>
<h1>Parametrisation</h1>
<p>One cool aspect about ranger is the way you can tweak it. <br />
Almost every aspect is configurable. Keybinding, colors, applications to open/preview files...
Ranger relies on four files for the configuration:</p>
<ul>
<li>
<p>rifle.conf </p>
</li>
<li>
<p>commands.py</p>
</li>
<li>
<p>rc.conf</p>
</li>
<li>
<p>scope.sh</p>
</li>
</ul>
<p>They have to be in the directory <em>~/.config/ranger</em> .<br />
To easily bootstrap these files we can take advantage of the <em>copy-config</em> option: </p>
<div class="highlight"><pre><span></span>$ ranger --copy-option all
</pre></div>
<p>This has for effect to bootstrap your configuration directory with default configuration files.</p>
<h2>Rifle.conf</h2>
<p>Ranger uses a program named rifle to open/execute files.<br />
To configure rifle you've got to modify <strong>rifle.conf</strong> .<br />
This file describes to rifle what application to use when you want to open or execute a file.
It describes with a specific syntax how to reconize file (by name, by extension, by regex...) and how to handle it. </p>
<h2>Commands</h2>
<p>Ranger commands are defined through the file <strong>commands.py</strong>.<br />
This python file contains classes, each one representing a command. <br />
To interface with ranger the class has to define at least some specific methods.<br />
All is well explained in the comment header of the file.</p>
<p>Not only you can modify some behavior, you also can create new commands.
Here's a simple hello_world command:<br />
I want the hello_world [args] command to display "Hello World [args]" on the screen.</p>
<div class="highlight"><pre><span></span><span class="k">class</span> <span class="n">hello_world</span>(<span class="n">Command</span>):
<span class="s">""":hello_world [args]</span>
<span class="s"> Display hello world on console</span>
<span class="s"> """</span>
<span class="n">def</span> <span class="n">execute</span>(<span class="k">self</span>):
<span class="k">if</span> <span class="k">self</span>.<span class="n">args:</span>
<span class="k">self</span>.<span class="n">fm</span>.<span class="n">notify</span>(<span class="s">"Hello world %s"</span> % <span class="k">self</span>.<span class="n">args</span>)
<span class="n">else:</span>
<span class="k">self</span>.<span class="n">fm</span>.<span class="n">notify</span>(<span class="s">"Hello world!"</span>)
</pre></div>
<p>Here's the explanation.<br />
Each class must extends the Command class.<br />
Then it has to interface to ranger by defining the <em>execute</em> metod. <br />
Inside this method we use the <em>fm</em> object which contains most information about ranger.<br />
Now we can use our new command inside ranger by typing <em>:hello_world foo</em> </p>
<p>It also exists others methods. I let you <strong>read the fantastic header</strong> to understand the purpose of each one.</p>
<h2>rc.conf</h2>
<p>The purpose of this file is to define the ranger's startup settings.<br />
It is where you'll find most of the ranger's setting. <br />
To know about the setting you can modify, the manuel is a good starting point.
It is where you also specify keybinding. By default, <strong>ranger comes with a vim keybinding</strong>, but it's up to you if you want to keep it or change it.</p>
<p>This file is also a treasure of information and you should read it at least once, to discover all the setting and shortcut you've got. <br />
Ranger is powerfull only if we know how to take advantage of it.</p>
<p><em>E.g, not only you got keybinding to navigate, you also have keybinding to sort files and directories, launch unix commands such as <strong>df</strong>, filter files...</em> </p>
<p><strong>Note</strong>: <em>To not forget it you can easily switch from Ranger to your terminal with <strong>S</strong>, and go back to Ranger by exiting the same terminal.</em></p>
<h2>scope.sh</h2>
<p>Like rifle but used to preview files.<br />
Very useful, instead of opening files you check through the preview if it is the file you are looking for. Also works for pdf and images.</p>
<p><img alt="interface" src="https://ihommani.github.io/images/ranger2.png" title="ranger's preview 1" /></p>
<p><em>Example of a text file preview</em></p>
<p><img alt="interface" src="https://ihommani.github.io/images/ranger3.png" title="ranger's preview 2" />
<em>Example of an image preview. Note that this ascii preview rely on my geek taste, but you can perfectly preview a 'normal' aspect. Just read the scope.sh header</em></p>
<h2>Theming</h2>
<p>You can of course change the style of ranger by creating an existing theme or creating a new one.<br />
The good thing is that creating a new one is easy thanks to inheritance.
You just have to create a <em>your_theme.py</em> in the colorsheme directory and define inside a class <em>Scheme</em> inheriting from Default class. </p>
<p>It can be as small as this:</p>
<div class="highlight"><pre><span></span><span class="k">class</span> <span class="n">Scheme</span>(<span class="n">Default</span>):
<span class="n">progress_bar_color</span> = <span class="n">green</span>
<span class="n">def</span> <span class="k">use</span>(<span class="k">self</span>, <span class="nb">context</span>):
<span class="n">fg</span>, <span class="n">bg</span>, <span class="nb">attr</span> = <span class="n">Default</span>.<span class="k">use</span>(<span class="k">self</span>, <span class="nb">context</span>)
<span class="k">if</span> <span class="nb">context</span>.<span class="n">directory</span> <span class="o">and</span> <span class="nb">not</span> <span class="nb">context</span>.<span class="n">marked</span> <span class="o">and</span> <span class="nb">not</span> <span class="nb">context</span>.<span class="n">link:</span>
<span class="n">fg</span> = <span class="n">green</span>
<span class="k">if</span> <span class="nb">context</span>.<span class="n">in_titlebar</span> <span class="o">and</span> <span class="nb">context</span>.<span class="n">hostname:</span>
<span class="n">fg</span> = <span class="n">red</span> <span class="k">if</span> <span class="nb">context</span>.<span class="n">bad</span> <span class="k">else</span> <span class="n">blue</span>
<span class="k">return</span> <span class="n">fg</span>, <span class="n">bg</span>, <span class="nb">attr</span>
</pre></div>
<p>You then specify the theme you want in the rc.conf file by putting the following line in your rc.conf </p>
<div class="highlight"><pre><span></span>set colorscheme your_theme
</pre></div>
<h1>Plugins</h1>
<p>To add features to Ranger without modifying the core of it, ranger support plugins. I don't include them in the scope of this article. However it is well documented and nice example are to be found under <strong>/usr/share/doc/ranger</strong> directory.</p>
<h1>The downsides</h1>
<p>While i'm praising keyboard over the mouse, I have to confess that the drag and drop is a feature we do not have with ranger. <br />
It's the major ranger's drawback of i can see.</p>
<h1>Conclusion</h1>
<p>I have used ranger for years.<br />
Ranger is different from other file manager. It gives a different experience while managing your files.<br />
Not only it is light and fast, it also stick to your needs to an extent no other file managers can match.<br />
Last but not least, a word from our beloved comrade. </p>
<p><img alt="Texas" src="https://ihommani.github.io/images/texas_ranger.jpg" title="Texas ranger" /></p>
</div>
<div class="tag-cloud">
<p>
<a href="https://ihommani.github.io/tag/file-manager.html">file manager</a>
</p>
</div>
<div id="disqus_thread"></div>
<script type="text/javascript">
var disqus_shortname = 'ihommani';
(function() {
var dsq = document.createElement('script'); dsq.type = 'text/javascript'; dsq.async = true;
dsq.src = '//' + disqus_shortname + '.disqus.com/embed.js';
(document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq);
})();
</script>
<noscript>
Please enable JavaScript to view comments.
</noscript>
</article>
<footer>
<p>© ihommani </p>
<p> Powered by <a href="http://getpelican.com" target="_blank">Pelican</a> - <a href="https://github.com/alexandrevicenzi/flex" target="_blank">Flex</a> theme by <a href="http://alexandrevicenzi.com" target="_blank">Alexandre Vicenzi</a>
</p> </footer>
</main>
<script type="application/ld+json">
{
"@context" : "http://schema.org",
"@type" : "Blog",
"name": " Thinking about... ",
"url" : "https://ihommani.github.io",
"image": "",
"description": ""
}
</script>
</body>
</html>