rcfiles 1.2.46

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of rcfiles might be problematic. Click here for more details.

Files changed (101) hide show
  1. checksums.yaml +7 -0
  2. data/README.md +559 -0
  3. data/bin/rcfiles +12 -0
  4. data/bin/rcfiles_run_it +7 -0
  5. data/doc/README.gen +516 -0
  6. data/img/LOGO_FOR_THE_RCFILES_PROJECT.png +0 -0
  7. data/lib/rcfiles/aggregate_all_rcfiles/aggregate_all_rcfiles.rb +137 -0
  8. data/lib/rcfiles/class/colours.rb +54 -0
  9. data/lib/rcfiles/class/initialize.rb +66 -0
  10. data/lib/rcfiles/class/misc.rb +300 -0
  11. data/lib/rcfiles/class/rcfiles.rb +31 -0
  12. data/lib/rcfiles/class/reset.rb +26 -0
  13. data/lib/rcfiles/class/run.rb +17 -0
  14. data/lib/rcfiles/colours/colours.rb +111 -0
  15. data/lib/rcfiles/commandline/commandline.rb +177 -0
  16. data/lib/rcfiles/constants/constants.rb +253 -0
  17. data/lib/rcfiles/directory_aliases/README.md +2 -0
  18. data/lib/rcfiles/directory_aliases/directory_aliases.rb +647 -0
  19. data/lib/rcfiles/directory_aliases/toplevel_stored_dataset.rb +177 -0
  20. data/lib/rcfiles/directory_aliases/yaml_file_used_by_class_directory_aliases.rb +67 -0
  21. data/lib/rcfiles/files/file_aliases.rb +78 -0
  22. data/lib/rcfiles/files/file_cd_aliases.rb +85 -0
  23. data/lib/rcfiles/files/file_ls_colours.rb +76 -0
  24. data/lib/rcfiles/files/file_path_variable.rb +74 -0
  25. data/lib/rcfiles/files/file_pkgconfig.rb +74 -0
  26. data/lib/rcfiles/files/file_programs_aliases.rb +68 -0
  27. data/lib/rcfiles/files/file_ps1.rb +80 -0
  28. data/lib/rcfiles/files/file_system_settings.rb +66 -0
  29. data/lib/rcfiles/help/help.rb +46 -0
  30. data/lib/rcfiles/no_colours.rb +13 -0
  31. data/lib/rcfiles/project/project.rb +45 -0
  32. data/lib/rcfiles/rcfiles/README.md +5 -0
  33. data/lib/rcfiles/rcfiles/aliases_rc +20431 -0
  34. data/lib/rcfiles/rcfiles/cd_aliases_rc +14980 -0
  35. data/lib/rcfiles/rcfiles/cflags_rc +9 -0
  36. data/lib/rcfiles/rcfiles/compile_rc +11 -0
  37. data/lib/rcfiles/rcfiles/file_information_rc +16 -0
  38. data/lib/rcfiles/rcfiles/gnome_rc +10 -0
  39. data/lib/rcfiles/rcfiles/kde_rc +17 -0
  40. data/lib/rcfiles/rcfiles/kernel_rc +12 -0
  41. data/lib/rcfiles/rcfiles/lang_rc +9 -0
  42. data/lib/rcfiles/rcfiles/ldflags_rc +8 -0
  43. data/lib/rcfiles/rcfiles/ls_colours_rc +9 -0
  44. data/lib/rcfiles/rcfiles/network_rc +37 -0
  45. data/lib/rcfiles/rcfiles/path_variable_rc +9 -0
  46. data/lib/rcfiles/rcfiles/pkgconfig_rc +9 -0
  47. data/lib/rcfiles/rcfiles/programs_aliases_rc +17571 -0
  48. data/lib/rcfiles/rcfiles/ps1_rc +9 -0
  49. data/lib/rcfiles/rcfiles/special_aliases_rc +8 -0
  50. data/lib/rcfiles/rcfiles/system_rc +13 -0
  51. data/lib/rcfiles/rcfiles/system_settings_rc +192 -0
  52. data/lib/rcfiles/rcfiles/term_rc +9 -0
  53. data/lib/rcfiles/rcfiles/video_rc +24 -0
  54. data/lib/rcfiles/requires/require_the_directory_aliases.rb +7 -0
  55. data/lib/rcfiles/requires/require_the_rcfiles_constants.rb +18 -0
  56. data/lib/rcfiles/requires/require_the_rcfiles_project.rb +67 -0
  57. data/lib/rcfiles/requires/try_to_require_syck_and_psych.rb +18 -0
  58. data/lib/rcfiles/toplevel_methods/autogenerate_rc_file_from_this_yaml_file.rb +102 -0
  59. data/lib/rcfiles/toplevel_methods/change_directory.rb +16 -0
  60. data/lib/rcfiles/toplevel_methods/convert.rb +118 -0
  61. data/lib/rcfiles/toplevel_methods/convert_global_variables_in_the_cd_aliases_file_to_a_standalone_yaml_file.rb +50 -0
  62. data/lib/rcfiles/toplevel_methods/create_windows_cd_aliases_bat_file.rb +51 -0
  63. data/lib/rcfiles/toplevel_methods/e.rb +16 -0
  64. data/lib/rcfiles/toplevel_methods/esystem.rb +19 -0
  65. data/lib/rcfiles/toplevel_methods/generate_yaml_files.rb +148 -0
  66. data/lib/rcfiles/toplevel_methods/infer.rb +83 -0
  67. data/lib/rcfiles/toplevel_methods/is_on_roebe.rb +16 -0
  68. data/lib/rcfiles/toplevel_methods/main_directory.rb +108 -0
  69. data/lib/rcfiles/toplevel_methods/misc.rb +341 -0
  70. data/lib/rcfiles/toplevel_methods/n_registered_aliases_in_total.rb +55 -0
  71. data/lib/rcfiles/toplevel_methods/no_file_exists_at.rb +19 -0
  72. data/lib/rcfiles/toplevel_methods/notifications.rb +35 -0
  73. data/lib/rcfiles/toplevel_methods/rds.rb +16 -0
  74. data/lib/rcfiles/toplevel_methods/remove_newlines.rb +29 -0
  75. data/lib/rcfiles/toplevel_methods/report.rb +53 -0
  76. data/lib/rcfiles/toplevel_methods/return_standard_header.rb +36 -0
  77. data/lib/rcfiles/toplevel_methods/run_it.rb +46 -0
  78. data/lib/rcfiles/toplevel_methods/save_file.rb +27 -0
  79. data/lib/rcfiles/toplevel_methods/use_psych_or_syck.rb +50 -0
  80. data/lib/rcfiles/toplevel_methods/use_quotes.rb +68 -0
  81. data/lib/rcfiles/toplevel_methods/verbosity.rb +28 -0
  82. data/lib/rcfiles/version/version.rb +26 -0
  83. data/lib/rcfiles/yaml/aliases.yml +23069 -0
  84. data/lib/rcfiles/yaml/cd_aliases.yml +15699 -0
  85. data/lib/rcfiles/yaml/global_variables/README.md +3 -0
  86. data/lib/rcfiles/yaml/global_variables/global_variables_extracted_from_the_file_cd_aliases.yml +121 -0
  87. data/lib/rcfiles/yaml/ls_colours.yml +128 -0
  88. data/lib/rcfiles/yaml/path_variable.yml +13 -0
  89. data/lib/rcfiles/yaml/pkgconfig.yml +46 -0
  90. data/lib/rcfiles/yaml/programs_aliases.yml +19203 -0
  91. data/lib/rcfiles/yaml/programs_aliases.yml~ +19086 -0
  92. data/lib/rcfiles/yaml/ps1.yml +82 -0
  93. data/lib/rcfiles/yaml/store_into_this_directory.yml +1 -0
  94. data/lib/rcfiles/yaml/system_settings.yml +526 -0
  95. data/lib/rcfiles/yaml/use_psych_or_syck.yml +1 -0
  96. data/lib/rcfiles.rb +1 -0
  97. data/rcfiles.gemspec +57 -0
  98. data/test/testing_directory_aliases.rb +47 -0
  99. data/test/testing_using_another_path_to_directory_aliases.rb +17 -0
  100. data/test/testing_yaml_to_rcfiles.rb +9 -0
  101. metadata +205 -0
data/doc/README.gen ADDED
@@ -0,0 +1,516 @@
1
+ ADD_RUBY_BADGE
2
+ ADD_LAST_UPDATED_WHEN
3
+
4
+ ![logo](https://i.imgur.com/Mf9u97a.png)
5
+
6
+ ## Goals for the rcfiles project
7
+
8
+ This project will try to automatically generate valid rc-files for shells
9
+ such as bash or zsh. **rc-files** are resource-files typically used by
10
+ shells, which can be sourced in that shell. The default use case will
11
+ refer to the **bash** shell since that is the shell that I do happen
12
+ to use most of the time.
13
+
14
+ These **rc-files** are generated from yaml files. These yaml files in turn
15
+ are, mostly, also distributed with this project, but of course you can use
16
+ your own yaml files as well. More on this elsewhere in this document, but
17
+ in principle the rcfiles project could also autogenerate various .rb files
18
+ rather than rc-files, or depend on yaml files alone. This will be considered
19
+ in the long run, but for the time being (written in **April 2019**) this
20
+ is not yet a possibility.
21
+
22
+ The main idea for this project is, evidently, my own use case, which is
23
+ to primarily make my aliases, custom export settings in shells, and so
24
+ forth, available for other/new computers quickly.
25
+
26
+ ## Requiring the rcfiles project
27
+
28
+ The project is required via this way:
29
+
30
+ require 'rcfiles'
31
+
32
+ Of course you could use **load** too, but require is more common and,
33
+ in my opinion, better, unless you need the behaviour of **load**
34
+ exactly.
35
+
36
+ ## The main directory
37
+
38
+ The **main directory**, as far as the project here is concerned,
39
+ is simply the directory into which the various rc-files will be
40
+ autogenerated.
41
+
42
+ On my **home system**, this is usually the directory called
43
+ <b>/AUTOGENERATED/</b>.
44
+
45
+ The reason as to why I am using such a short, top-level directory is
46
+ that it is quite convenient for me to navigate to it or source the
47
+ various rc-files generated from that directory, such as in:
48
+
49
+ . /AUTOGENERATED/aliases_rc
50
+
51
+ However had, there is one **obvious drawback** with this approach - you
52
+ need to have write permission into that directory close to the **root**
53
+ of the filesystem, if you wish to auto-generate rc-files into that
54
+ directory. And this is not always possible, such as when you are in
55
+ a **restricted environment** (workspace-computers in a university, for
56
+ example). Or it may be unwanted by you, anyway.
57
+
58
+ Thus, it must be possible to specify another directory that is to
59
+ be used here.
60
+
61
+ If you want to **query the current main directory** in use then you
62
+ can use the following **toplevel API**:
63
+
64
+ Rcfiles.main_directory?
65
+
66
+ If you want to set towards a **new main directory**, then you can
67
+ use the **set_main_directory()** method:
68
+
69
+ Rcfiles.set_main_directory
70
+
71
+ As argument to this method simply pass the directory that you wish
72
+ to use to that method.
73
+
74
+ So, for example, say that your name is john, and you want to
75
+ keep the rc-files in your home directory on a Linux system, so
76
+ you may want to do this:
77
+
78
+ Rcfiles.set_main_directory('/home/john/rcfiles/')
79
+
80
+ Ideally make sure that the directory already exists, and that
81
+ you can write/read in/from that directory. But if this is your
82
+ home directory then you will typically have this access-permission,
83
+ anyway. Same with **/tmp/** on most linux distributions.
84
+
85
+ You can also use a simpler toplevel API such as:
86
+
87
+ Rcfiles.set_path
88
+
89
+ ## Commandline usage of this project:
90
+
91
+ If you do not want to auto-generate rc-files that have a "" quote, as
92
+ part of its value setting (the part on the right side of an alias),
93
+ such as for use in projects such as <b>cmder</b>, then you can use
94
+ this option:
95
+
96
+ --no-quotes
97
+
98
+ This may also be useful if you have to use a shell such as <b>cmder</b>
99
+ which appears to only support unquoted aliases.
100
+
101
+ So invoke the executable in bin/ like this:
102
+
103
+ rcfile --cmder-target
104
+ rcfile --cmder
105
+
106
+ To see where the main .yml files are, do this:
107
+
108
+ rcfiles --report
109
+
110
+ To find out hwo many aliases are part of this project, do:
111
+
112
+ rcfiles --n_aliases? # 46337 aliases are available in this project (28.08.2020).
113
+
114
+ ## How to use this project from within ruby-code
115
+
116
+ You first have to require this project, obviously:
117
+
118
+ require 'rcfiles'
119
+
120
+ Now - in order to batch-generate the various rc-files, you can use
121
+ an API such as the following one:
122
+
123
+ Rcfiles.run
124
+ Rcfiles.new
125
+
126
+ This defaults to my own aliases. For now this is how it is but in
127
+ future releases, people will be able to use their own custom
128
+ aliases.
129
+
130
+ If you want to store at the rc-files at a specific location,
131
+ such as a certain <b>directory</b>, then you can use the
132
+ symbol :store_at such as in the following example:
133
+
134
+ Rcfiles.new(store_at: Dir.pwd)
135
+
136
+ The second argument, in this case Dir.pwd, shall denote the
137
+ directory that you wish to use here.
138
+
139
+ This may be especially useful if you have no access to
140
+ the base directory at / e. g. when you are in a restricted
141
+ environment (like workstations in a university) or when
142
+ you simply want to use another directory name altogether.
143
+
144
+ The above API is a bit cumbersome, though, so you can use
145
+ any of the following toplevel APIs instead:
146
+
147
+ Rcfiles.set_store_into_this_directory
148
+ Rcfiles.set_main_directory
149
+ Rcfiles.set_path
150
+ Rcfiles.store_at=
151
+ Rcfiles.store_at=
152
+ Rcfiles.set_store_here
153
+ Rcfiles.set_store_into
154
+
155
+ ## Generating individual rc-aliases
156
+
157
+ There are several ways how to generate individual rc-aliases,
158
+ such as via <b>Rcfiles.new(:cd_aliases)</b>.
159
+
160
+ But there are other toplevel module-methods as well, such as the
161
+ following variants:
162
+
163
+ Rcfiles.generate :cd_aliases
164
+ Rcfiles.generate :aliases
165
+ Rcfiles.generate :program_aliases
166
+
167
+ And numbers as input as well, if one wants to be even shorter:
168
+
169
+ Rcfiles.generate 1
170
+ Rcfiles.generate 2
171
+ Rcfiles.generate 3
172
+
173
+ Why so many different ways? I simply just want to auto-generate
174
+ these aliases, no matter the given input. These shortcuts generate my
175
+ bash-specific aliases, but since as of March 2018, I also changed the
176
+ code to generate aliases that work on Windows in the <b>cmder</b>
177
+ shell. **cmder** is a bit different in that it requires aliases without
178
+ quotes (aka no '' or "" may be used there).
179
+
180
+ ## Determining the project's base directory
181
+
182
+ The toplevel "namespace" contains an instance variable called
183
+ **@project_base_directory**. This variable should point to
184
+ where the .rb files of this project are kept. Additionally
185
+ it will load up the .yml files that reside within the
186
+ **yml/** subdirectory there.
187
+
188
+ On my Linux home system, this works as-is, but other systems
189
+ may need to be a bit more flexible here, such as windows
190
+ perhaps, or systems where you may have no control over where
191
+ the .rb files may be placed (perhaps in a restricted
192
+ environment such as university campus).
193
+
194
+ Thus, you can modify the path to this directory via:
195
+
196
+ Rcfiles.set_project_base_directory()
197
+
198
+ You can also query the current path in use via:
199
+
200
+ Rcfiles.project_base_dir?
201
+ Rcfiles.project_base_directory?
202
+
203
+ ## Using quotes in the generated shell-rc files
204
+
205
+ The toplevel API **Rcfiles.use_quotes?** is
206
+ used to determine whether quotes will be used or not. Some
207
+ programs, such as **cmder**, need quotes.
208
+
209
+ You can toggle this behaviour like so:
210
+
211
+ Rcfiles.use_quotes = true
212
+ Rcfiles.use_quotes = false
213
+
214
+ Or simply:
215
+
216
+ Rcfiles.toggle_quotes # <- I prefer the long variant
217
+ Rcfiles.toggle # <- But the short variant is also a possibility.
218
+
219
+ The latter method will flip the state, from true to false
220
+ or from false to true.
221
+
222
+ ## Determining the file location of the different aliases in the project
223
+
224
+ Sometimes it may be necessary to set the path to yaml files, e. g. in
225
+ particular if you wish to make use of other .yml files that do **not**
226
+ come distributed with this project. That was the major reason why code
227
+ was added here, so that users can adapt the project to their use
228
+ cases.
229
+
230
+ Have a look at the following API, each one corresponding to the particular
231
+ .yml file (e. g. set_file_aliases() would denote the path to the file
232
+ called **aliases.yml**, whereas set_file_programs_aliases() would modify
233
+ the path to the file called **programs_aliases.yml** and so forth):
234
+
235
+ Rcfiles.set_file_aliases()
236
+ Rcfiles.set_programs_aliases()
237
+ Rcfiles.set_cd_aliases()
238
+
239
+ ## Rcfiles.report
240
+
241
+ You can use the toplevel method **Rcfiles.report** to report
242
+ some information about the Rcfiles project, such as from
243
+ which paths it will obtain information.
244
+
245
+ This functionality was necessary because we can re-define the paths
246
+ that are used to generate rc-files at any time; thus, we needed a
247
+ way to **query** the full path to these different files.
248
+
249
+ ## Rcfiles.infer
250
+
251
+ The toplevel method **Rcfiles.infer** can be called to
252
+ designate the path to one of the three main .yml files of this
253
+ project. It is thus similar to the three variants documented
254
+ above in this file, such as **Rcfiles.set_file_aliases()**,
255
+ **Rcfiles.set_programs_aliases()** and
256
+ **Rcfiles.set_cd_aliases()**. The difference is that
257
+ **infer()** is a lot shorter - and a lot simpler, too.
258
+
259
+ You only have to provide the path to this .yml file at hand.
260
+
261
+ Generic usage examples:
262
+
263
+ Rcfiles.infer 'aliases.yml'
264
+ Rcfiles.infer 'cd_aliases.yml'
265
+ Rcfiles.infer 'programs_aliases.yml'
266
+
267
+ In these cases these files will be automatically used, with
268
+ the path designed here. I recommend to first copy the .yml
269
+ files to e. g. your working home directory, and then call
270
+ the three .infer methods. That should help if for whatever
271
+ reason your ruby installation is unable to find the
272
+ path - or if you simply wish to use other .yml files, too.
273
+
274
+ ## Colours
275
+
276
+ By default, **Rcfiles** will make use of **colours**, as defined by
277
+ the 'colours' gem.
278
+
279
+ However had, this is **optional** and ultimately not really necessary -
280
+ it is just a convenience feature.
281
+ everyone.
282
+
283
+ If you would rather **NOT** want to use the **colours gem**, or may
284
+ encounter an error related to colours, you can change this either by
285
+ requiring the rcfiles-project a bit differently, such as through
286
+ either of these two ways (which are the same):
287
+
288
+ require 'rcfiles/no_colours'
289
+ require 'rcfiles/no_colours.rb'
290
+
291
+ This will automatically disable colours support for the **Rcfiles**
292
+ namespace.
293
+
294
+ The **first** variant is preferred, in my opinion, since it is
295
+ <b>shorter</b> - but use whatever you prefer, anyway.
296
+
297
+ You can also use the following code to generate the rc-files
298
+ without making use of colours:
299
+
300
+ Rcfiles.run { :disable_colours }
301
+
302
+ ## The directory rcfiles/
303
+
304
+ Since as of 07.04.2019 this project also includes all auto-generated
305
+ rcfiles, in the subdirectory called **rcfiles/**.
306
+
307
+ The primary reason as to why these files are distributed with this
308
+ project is so that:
309
+
310
+ a) they are available as-is when the gem is downloaded
311
+
312
+ and, even more importantly than that
313
+
314
+ b) because **psych** sometimes has problems with the main encoding used,
315
+ which means that the rc-files may not be generated on a given
316
+ computer system as-such. Hence why bundling these files into the
317
+ project directly makes this potential problem a non-issue (excluding
318
+ projects such as cmder, which require aliases to be defined without
319
+ quotes).
320
+
321
+ If you wish to copy these bundled rc-files via ruby, then you can
322
+ use the following toplevel method:
323
+
324
+ Rcfiles.copy_rcfiles_to_the_current_directory
325
+
326
+ ## Copying the rc-files via the commandline
327
+
328
+ Sometimes it may be useful to quickly copy the rc-files into your
329
+ current working directory, rather than generate them anew.
330
+
331
+ You can use the following commandline switch in order to achieve
332
+ this, and copy the registered rc-files into the current working
333
+ directory:
334
+
335
+ rcfiles --copy-rcfiles
336
+ rcfiles --copy
337
+ rcfiles --cp
338
+
339
+ I needed this functionality so that I could quickly copy the
340
+ rc-files, source them in bash, and continue working from here
341
+ past that point - mostly for convenience.
342
+
343
+ As stated elsewhere in this document, if you need to use this
344
+ functionality from ruby then you can use **Rcfiles.copy_rcfiles_to_the_current_directory**
345
+ or just **Rcfiles.copy_rcfiles**.
346
+
347
+ ## The PS1 path variable
348
+
349
+ If you wish to quickly generate a new rc-file with a default
350
+ PS1 (defaulting to my PS that is), the following commandline
351
+ variant can be used:
352
+
353
+ rcfiles --ps1
354
+
355
+ ## Generating other rc-files
356
+
357
+ You can either batch-generate all -rc files, or also cherry-pick
358
+ some of them.
359
+
360
+ Example:
361
+
362
+ rcfiles --programs-aliases
363
+
364
+ This will generate the **programs_aliases_rc file**.
365
+
366
+ ## Generating a .bat file for the cd-aliases on Windows
367
+
368
+ Certain windows-related shells, such as the fairly new
369
+ **windows-terminal**, make use of a fairly ... obscure
370
+ syntax for a cd-alias.
371
+
372
+ For example:
373
+
374
+ function pwdhome { set-location "c:\home\x" }
375
+
376
+ This would assign pwdhome to become a cd-alias to
377
+ /home/x. (Weird syntax.)
378
+
379
+ If you wish to generate such a .bat file with all
380
+ the cd-aliases available in this project, consider
381
+ using the following commandline variant:
382
+
383
+ rcfiles --windows-cd-aliases
384
+
385
+ Internally the method that is doing this is:
386
+
387
+ Rcfiles.create_windows_cd_aliases_bat_file
388
+
389
+ ## Obtaining all aliases, as a Hash
390
+
391
+ If you need to return all aliases registered in this
392
+ project, as a Hash, then you can use this toplevel
393
+ method:
394
+
395
+ Rcfiles.aliases?
396
+
397
+ In **January 2021** this gem contained 47088 entries (key→value pairs).
398
+ In **April 2021** this gem contained 47661 entries (key→value pairs).
399
+
400
+ ## doskey
401
+
402
+ **doskey** is an old DOS program (I think; at the least it was
403
+ available on DOS back in the days) that allows you to use aliases
404
+ on windows.
405
+
406
+ For a better explanation, have a look at the following link:
407
+
408
+ https://kunalspathak.github.io/2020-11-21-About-doskeys/
409
+
410
+ The **rcfiles** gem contains tons of aliases. Perhaps you have
411
+ lots of aliases as well and would like to re-use them on
412
+ windows.
413
+
414
+ You can use the **roebe** gem for that, in particular:
415
+
416
+ roebe/classes/doskey_generator.rb
417
+
418
+ Afterwards you may have to replace the global environment
419
+ variables. You can probably adapt this class/file:
420
+
421
+ roebe/classes/replace_global_variables_in_this_file.rb
422
+
423
+ At any rate, this subsection really just tries to contain
424
+ some helpful **hints** for those who want to make use of
425
+ doskey. You may have to adjust it to your own preference.
426
+
427
+ ## DirectoryAliases respectively Rcfiles::DirectoryAliases
428
+
429
+ In <b>May 2022</b> the old class called <b>Rcfiles::ExpandCdAliases</b>
430
+ was renamed into <b>Rcfiles::DirectoryAliases</b>. The old functionality
431
+ was retained for the most part, but some parts were changed or even
432
+ removed.
433
+
434
+ The primary reason for the rewrite was that the old logic of
435
+ ExpandCdAlias was very convoluted and complicated. I wanted to
436
+ extend it in <b>May 2022</b> but got frustrated with the old
437
+ design; some parts of the code base were +10 years old already,
438
+ and not that well designed.
439
+
440
+ Thus, I decided to rather than maintain the old code, to
441
+ just create a new class, with a cleaner design from the
442
+ get go.
443
+
444
+ The basic idea behind class Rcfiles::DirectoryAliases is that
445
+ an <b>input string</b> such as '<b>pwdj</b>' can be turned into
446
+ the corresponding aliased string, which would be '<b>/Depot/j/</b>'
447
+ instead.
448
+
449
+ The way how to do so would go like this:
450
+
451
+ Rcfiles::DirectoryAliases['pwdj'] # => '/Depot/j/'
452
+
453
+ This can then be used by a shell, such as <b>Roebe::Shell</b>
454
+ in particular - another project I maintain. The idea here
455
+ is to quickly navigate a local file system without having
456
+ to type the full paths whatsoever.
457
+
458
+ The class has been written with some flexibility in mind.
459
+ For instance, the main .yml file that it uses can be
460
+ queried via the following method:
461
+
462
+ Rcfiles::DirectoryAliases.yaml_file?
463
+
464
+ On my home system this defaults to:
465
+
466
+ /usr/lib/ruby/site_ruby/3.1.0/rcfiles/yaml/cd_aliases.yml
467
+
468
+ This .yml file, called **cd_aliases.yml**, is also distributed
469
+ by the <b>rcfiles</b> gem. This has been done mostly for
470
+ reasons of convenience - other users can use this .yml file
471
+ if they'd like to, but be aware that this defaults to my
472
+ home setup, so it may be utterly useless to you. Nonetheless,
473
+ you could maintain your own dataset - all you have to provide
474
+ is a similar .yml file. You can store it somewhere else on
475
+ your own local system.
476
+
477
+ You can specify the path to such a .yml file via:
478
+
479
+ Rcfiles::DirectoryAliases.set_yaml_file_used_by_class_directory_aliases(path_goes_here)
480
+
481
+ This method is called initially via:
482
+
483
+ Rcfiles::DirectoryAliases.set_yaml_file_used_by_class_directory_aliases(:default_yaml_file)
484
+
485
+ The symbol ::default_yaml_file will refer to the already mentioned
486
+ file called <b>/usr/lib/ruby/site_ruby/3.1.0/rcfiles/yaml/cd_aliases.yml</b>.
487
+
488
+ Note that this merely specifies the path to the file; it does not
489
+ yet load this file.
490
+
491
+ To load from this file have a look at the method called
492
+ <b>load_the_dataset_from_the_file_cd_aliases()</b>. This is
493
+ automatically called whenever <b>Rcfiles::DirectoryAliases.new</b>
494
+ is called. Have a look at the file at
495
+ <b>rcfiles/test/testing_using_another_path_to_directory_aliases.rb</b>
496
+ to see how you can load your own .yml file specifically.
497
+
498
+ ## Licence
499
+
500
+ Since as of <b>April 2021</b>, this project is using the MIT licence.
501
+ It is not a hugely important project, so using a less stringent
502
+ version was fine by me.
503
+
504
+ Copyright 2021-2022 Robert A. Heiler
505
+
506
+ You can read up on the MIT licence here:
507
+
508
+ https://opensource.org/licenses/MIT
509
+
510
+ The most important requirement (in my own parlance) is the
511
+ "no-warranty disclaimer", aka legalese to "use at your own
512
+ discretion and risk-analysis, without holding the author
513
+ or anyone else responsible for issues potentially
514
+ originating from using this software".
515
+
516
+ ADD_CONTACT_INFORMATION
@@ -0,0 +1,137 @@
1
+ #!/usr/bin/ruby -w
2
+ # Encoding: UTF-8
3
+ # frozen_string_literal: true
4
+ # =========================================================================== #
5
+ # === Rcfiles::AggregateAllRcfiles
6
+ #
7
+ # This class will generate a big .sh file.
8
+ #
9
+ # Usage example:
10
+ #
11
+ # Rcfiles::AggregateAllRcfiles.new(ARGV)
12
+ #
13
+ # =========================================================================== #
14
+ # require 'rcfiles/aggregate_all_rcfiles/aggregate_all_rcfiles.rb'
15
+ # Rcfiles::AggregateAllRcfiles.new
16
+ # =========================================================================== #
17
+ module Rcfiles
18
+
19
+ class AggregateAllRcfiles # === Rcfiles::AggregateAllRcfiles
20
+
21
+ alias e puts
22
+
23
+ require 'rcfiles/toplevel_methods/save_file.rb'
24
+ require 'rcfiles/colours/colours.rb'
25
+
26
+ # ========================================================================= #
27
+ # === NAMESPACE
28
+ # ========================================================================= #
29
+ NAMESPACE = inspect
30
+
31
+ # ========================================================================= #
32
+ # === ARRAY_GATHER_FROM_THESE_FILES
33
+ # ========================================================================= #
34
+ ARRAY_GATHER_FROM_THESE_FILES = %w(
35
+ aliases_rc
36
+ cd_aliases_rc
37
+ cflags_rc
38
+ compile_rc
39
+ file_information_rc
40
+ gnome_rc
41
+ kde_rc
42
+ kernel_rc
43
+ lang_rc
44
+ ldflags_rc
45
+ ls_colours_rc
46
+ network_rc
47
+ path_variable_rc
48
+ pkgconfig_rc
49
+ programs_aliases_rc
50
+ ps1_rc
51
+ roeberia_settings_rc
52
+ source_all_the_rc_files.sh
53
+ system_rc
54
+ system_settings_rc
55
+ term_rc
56
+ video_rc
57
+ )
58
+
59
+ # ========================================================================= #
60
+ # === initialize
61
+ # ========================================================================= #
62
+ def initialize(
63
+ commandline_arguments = nil,
64
+ run_already = true
65
+ )
66
+ reset
67
+ set_commandline_arguments(
68
+ commandline_arguments
69
+ )
70
+ run if run_already
71
+ end
72
+
73
+ # ========================================================================= #
74
+ # === reset (reset tag)
75
+ # ========================================================================= #
76
+ def reset
77
+ # ======================================================================= #
78
+ # === @namespace
79
+ # ======================================================================= #
80
+ @namespace = NAMESPACE
81
+ end
82
+
83
+ # ========================================================================= #
84
+ # === set_commandline_arguments
85
+ # ========================================================================= #
86
+ def set_commandline_arguments(i = '')
87
+ i = [i].flatten.compact
88
+ @commandline_arguments = i
89
+ end
90
+
91
+ # ========================================================================= #
92
+ # === commandline_arguments?
93
+ # ========================================================================= #
94
+ def commandline_arguments?
95
+ @commandline_arguments
96
+ end
97
+
98
+ # ========================================================================= #
99
+ # === first_argument?
100
+ # ========================================================================= #
101
+ def first_argument?
102
+ @commandline_arguments.first
103
+ end; alias first? first_argument? # === first?
104
+
105
+ # ========================================================================= #
106
+ # === run (run tag)
107
+ # ========================================================================= #
108
+ def run
109
+ _ = ''.dup
110
+ base_dir = '/AUTOGENERATED/'
111
+ ARRAY_GATHER_FROM_THESE_FILES.each {|entry|
112
+ target = base_dir+entry.to_s
113
+ if File.exist? target
114
+ _ << File.read(target)
115
+ _ << "\n"
116
+ end
117
+ }
118
+ what = _
119
+ into = base_dir+'aggregated_shell_file.sh'
120
+ opn(namespace: @namespace); e ::Colours.rev+
121
+ 'Now storing into the file `'+
122
+ ::Rcfiles.sfile(into)+'`.'
123
+ ::Rcfiles.write_what_into(what, into)
124
+ end
125
+
126
+ # ========================================================================= #
127
+ # === Roebe::AggregateAllRcfiles[]
128
+ # ========================================================================= #
129
+ def self.[](i = ARGV)
130
+ new(i)
131
+ end
132
+
133
+ end; end
134
+
135
+ if __FILE__ == $PROGRAM_NAME
136
+ Rcfiles::AggregateAllRcfiles.new(ARGV)
137
+ end # aggregateallrcfiles
@@ -0,0 +1,54 @@
1
+ #!/usr/bin/ruby -w
2
+ # Encoding: UTF-8
3
+ # frozen_string_literal: true
4
+ # =========================================================================== #
5
+ # require 'rcfiles/class/colours.rb'
6
+ # =========================================================================== #
7
+ require 'rcfiles/colours/colours.rb'
8
+
9
+ module Rcfiles
10
+
11
+ class Rcfiles
12
+
13
+ # ========================================================================= #
14
+ # === use_colours?
15
+ #
16
+ # We delegate to the toplevel method in order to determine whether
17
+ # the Rcfiles project will use colours or whether it will not.
18
+ # ========================================================================= #
19
+ def use_colours?
20
+ ::Rcfiles.use_colours?
21
+ end
22
+
23
+ # ========================================================================= #
24
+ # === sdir
25
+ # ========================================================================= #
26
+ def sdir(i)
27
+ return ::Rcfiles.sdir(i) if use_colours?
28
+ end
29
+
30
+ # ========================================================================= #
31
+ # === simp
32
+ # ========================================================================= #
33
+ def simp(i)
34
+ return ::Rcfiles.simp(i) if use_colours?
35
+ i
36
+ end
37
+
38
+ # ========================================================================= #
39
+ # === sfancy
40
+ # ========================================================================= #
41
+ def sfancy(i)
42
+ return ::Rcfiles.sfancy(i) if use_colours?
43
+ i
44
+ end
45
+
46
+ # ========================================================================= #
47
+ # === sfile
48
+ # ========================================================================= #
49
+ def sfile(i)
50
+ return ::Rcfiles.sfile(i) if use_colours?
51
+ i
52
+ end
53
+
54
+ end; end