rcfiles 1.1.1137

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 (97) hide show
  1. checksums.yaml +7 -0
  2. data/README.md +401 -0
  3. data/bin/rcfiles +7 -0
  4. data/bin/rcfiles_run_it +7 -0
  5. data/doc/README.gen +384 -0
  6. data/lib/rcfiles.rb +1 -0
  7. data/lib/rcfiles/class/colours.rb +54 -0
  8. data/lib/rcfiles/class/initialize.rb +66 -0
  9. data/lib/rcfiles/class/misc.rb +299 -0
  10. data/lib/rcfiles/class/rcfiles.rb +31 -0
  11. data/lib/rcfiles/class/reset.rb +26 -0
  12. data/lib/rcfiles/class/run.rb +17 -0
  13. data/lib/rcfiles/colours/colours.rb +107 -0
  14. data/lib/rcfiles/commandline/commandline.rb +170 -0
  15. data/lib/rcfiles/constants/custom_files.rb +80 -0
  16. data/lib/rcfiles/constants/encodings.rb +85 -0
  17. data/lib/rcfiles/constants/misc.rb +75 -0
  18. data/lib/rcfiles/constants/namespace.rb +18 -0
  19. data/lib/rcfiles/expand_cd_aliases/constants.rb +50 -0
  20. data/lib/rcfiles/expand_cd_aliases/expand_cd_aliases.rb +626 -0
  21. data/lib/rcfiles/expand_cd_aliases/run.rb +18 -0
  22. data/lib/rcfiles/files/file_aliases.rb +78 -0
  23. data/lib/rcfiles/files/file_cd_aliases.rb +85 -0
  24. data/lib/rcfiles/files/file_ls_colours.rb +76 -0
  25. data/lib/rcfiles/files/file_path_variable.rb +74 -0
  26. data/lib/rcfiles/files/file_pkgconfig.rb +74 -0
  27. data/lib/rcfiles/files/file_programs_aliases.rb +68 -0
  28. data/lib/rcfiles/files/file_ps1.rb +80 -0
  29. data/lib/rcfiles/files/file_system_settings.rb +66 -0
  30. data/lib/rcfiles/help/help.rb +46 -0
  31. data/lib/rcfiles/no_colours.rb +13 -0
  32. data/lib/rcfiles/project/project.rb +45 -0
  33. data/lib/rcfiles/rcfiles/README.md +5 -0
  34. data/lib/rcfiles/rcfiles/aliases_rc +18526 -0
  35. data/lib/rcfiles/rcfiles/cd_aliases_rc +13313 -0
  36. data/lib/rcfiles/rcfiles/cflags_rc +9 -0
  37. data/lib/rcfiles/rcfiles/compile_rc +11 -0
  38. data/lib/rcfiles/rcfiles/file_information_rc +16 -0
  39. data/lib/rcfiles/rcfiles/german_umlaute_rc +264 -0
  40. data/lib/rcfiles/rcfiles/gnome_rc +10 -0
  41. data/lib/rcfiles/rcfiles/kde_rc +17 -0
  42. data/lib/rcfiles/rcfiles/kernel_rc +12 -0
  43. data/lib/rcfiles/rcfiles/lang_rc +9 -0
  44. data/lib/rcfiles/rcfiles/ldflags_rc +8 -0
  45. data/lib/rcfiles/rcfiles/ls_colours_rc +9 -0
  46. data/lib/rcfiles/rcfiles/network_rc +37 -0
  47. data/lib/rcfiles/rcfiles/path_variable_rc +9 -0
  48. data/lib/rcfiles/rcfiles/pkgconfig_rc +9 -0
  49. data/lib/rcfiles/rcfiles/programs_aliases_rc +15597 -0
  50. data/lib/rcfiles/rcfiles/ps1_rc +9 -0
  51. data/lib/rcfiles/rcfiles/special_aliases_rc +23 -0
  52. data/lib/rcfiles/rcfiles/system_rc +13 -0
  53. data/lib/rcfiles/rcfiles/system_settings_rc +191 -0
  54. data/lib/rcfiles/rcfiles/term_rc +9 -0
  55. data/lib/rcfiles/rcfiles/video_rc +24 -0
  56. data/lib/rcfiles/requires/require_the_expand_cd_aliases.rb +7 -0
  57. data/lib/rcfiles/requires/require_the_rcfiles_constants.rb +21 -0
  58. data/lib/rcfiles/requires/require_the_rcfiles_project.rb +66 -0
  59. data/lib/rcfiles/requires/try_to_require_syck_and_psych.rb +18 -0
  60. data/lib/rcfiles/toplevel_methods/autogenerate_rc_file_from_this_yaml_file.rb +102 -0
  61. data/lib/rcfiles/toplevel_methods/change_directory.rb +16 -0
  62. data/lib/rcfiles/toplevel_methods/convert.rb +118 -0
  63. data/lib/rcfiles/toplevel_methods/create_windows_cd_aliases_bat_file.rb +51 -0
  64. data/lib/rcfiles/toplevel_methods/e.rb +16 -0
  65. data/lib/rcfiles/toplevel_methods/esystem.rb +19 -0
  66. data/lib/rcfiles/toplevel_methods/generate_yaml_files.rb +148 -0
  67. data/lib/rcfiles/toplevel_methods/infer.rb +83 -0
  68. data/lib/rcfiles/toplevel_methods/is_on_roebe.rb +16 -0
  69. data/lib/rcfiles/toplevel_methods/main_directory.rb +108 -0
  70. data/lib/rcfiles/toplevel_methods/misc.rb +304 -0
  71. data/lib/rcfiles/toplevel_methods/n_registered_aliases_in_total.rb +55 -0
  72. data/lib/rcfiles/toplevel_methods/no_file_exists_at.rb +19 -0
  73. data/lib/rcfiles/toplevel_methods/notifications.rb +33 -0
  74. data/lib/rcfiles/toplevel_methods/rds.rb +16 -0
  75. data/lib/rcfiles/toplevel_methods/remove_newlines.rb +29 -0
  76. data/lib/rcfiles/toplevel_methods/report.rb +53 -0
  77. data/lib/rcfiles/toplevel_methods/return_standard_header.rb +36 -0
  78. data/lib/rcfiles/toplevel_methods/run_it.rb +46 -0
  79. data/lib/rcfiles/toplevel_methods/save_file.rb +27 -0
  80. data/lib/rcfiles/toplevel_methods/use_psych_or_syck.rb +50 -0
  81. data/lib/rcfiles/toplevel_methods/use_quotes.rb +68 -0
  82. data/lib/rcfiles/toplevel_methods/verbosity.rb +28 -0
  83. data/lib/rcfiles/version/version.rb +26 -0
  84. data/lib/rcfiles/yaml/aliases.yml +20991 -0
  85. data/lib/rcfiles/yaml/cd_aliases.yml +13970 -0
  86. data/lib/rcfiles/yaml/ls_colours.yml +128 -0
  87. data/lib/rcfiles/yaml/path_variable.yml +12 -0
  88. data/lib/rcfiles/yaml/pkgconfig.yml +46 -0
  89. data/lib/rcfiles/yaml/programs_aliases.yml +17081 -0
  90. data/lib/rcfiles/yaml/ps1.yml +82 -0
  91. data/lib/rcfiles/yaml/store_into_this_directory.yml +1 -0
  92. data/lib/rcfiles/yaml/system_settings.yml +513 -0
  93. data/lib/rcfiles/yaml/use_psych_or_syck.yml +1 -0
  94. data/rcfiles.gemspec +56 -0
  95. data/test/testing_expand_cd_aliases.rb +47 -0
  96. data/test/testing_yaml_to_rcfiles.rb +9 -0
  97. metadata +201 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: c14a9d1c48470ede798fa0c72c605852e3bc2e3ba350ac63b1f7a44f042e1831
4
+ data.tar.gz: be573bd1c58e0832598a91bf294189ba12e2dfe68383e03498bd55df39455b62
5
+ SHA512:
6
+ metadata.gz: 0554a9a1b6150c60c230cc877122c20c7e83bb7051eb4cac153cee896ba5ef7e4a27af0bdc623efc30903befa54db95cc157787b876738cd64e79b09cb4116cd
7
+ data.tar.gz: bd6a4a0adcffcdd3273d531c6ab252d8977d281ee0e51a4eddb2e41515e224bff100186569e8aeda8a372f2fbacae9c638098bc5014ab9f3f43698a541f83f71
data/README.md ADDED
@@ -0,0 +1,401 @@
1
+ [![forthebadge](http://forthebadge.com/images/badges/built-with-love.svg)](https://www.gobolinux.org/)
2
+ [![forthebadge](http://forthebadge.com/images/badges/made-with-ruby.svg)](https://www.ruby-lang.org/en/)
3
+ [![Gem Version](https://badge.fury.io/rb/rcfiles.svg)](https://badge.fury.io/rb/rcfiles)
4
+
5
+ ## Goals for the rcfiles project
6
+
7
+ This project will try to automatically generate valid rc-files for shells
8
+ such as bash or zsh. The default will refer to **bash** since that is the
9
+ shell that I do happen to use most of the time.
10
+
11
+ These **rc-files** are generated from yaml files. These yaml files in turn
12
+ are, mostly, also distributed with this project, but of course you can use
13
+ your own yaml files as well. More on this elsewhere in this document, but
14
+ in principle the rcfiles project could also autogenerate various .rb files
15
+ rather than rc-files, or depend on yaml files alone. This will be considered
16
+ in the long run, but for the time being (written in **April 2019**) this
17
+ is not yet a possibility.
18
+
19
+ The main idea for this project is, evidently, my own use case, which is
20
+ to primarily make my aliases, custom export settings in shells, and so
21
+ forth, available for other/new computers quickly.
22
+
23
+ ## Requiring the rcfiles project
24
+
25
+ The project is required via this way:
26
+
27
+ require 'rcfiles'
28
+
29
+ Of course you could use **load** too, but require is more common and,
30
+ in my opinion, better, unless you need the behaviour of **load**
31
+ exactly.
32
+
33
+ ## The main directory
34
+
35
+ The **main directory**, as far as the project here is concerned,
36
+ is simply the directory into which the various rc-files will be
37
+ autogenerated.
38
+
39
+ On my **home system**, this is usually the directory called
40
+ <b>/AUTOGENERATED/</b>.
41
+
42
+ The reason as to why I am using such a short, top-level directory is
43
+ that it is quite convenient for me to navigate to it or source the
44
+ various rc-files generated from that directory, such as in:
45
+
46
+ . /AUTOGENERATED/aliases_rc
47
+
48
+ However had, there is one **obvious drawback** with this approach - you
49
+ need to have write permission into that directory close to the **root**
50
+ of the filesystem, if you wish to auto-generate rc-files into that
51
+ directory. And this is not always possible, such as when you are in
52
+ a **restricted environment** (workspace-computers in a university, for
53
+ example). Or it may be unwanted by you, anyway.
54
+
55
+ Thus, it must be possible to specify another directory that is to
56
+ be used here.
57
+
58
+ If you want to **query the current main directory** in use then you
59
+ can use the following **toplevel API**:
60
+
61
+ Rcfiles.main_directory?
62
+
63
+ If you want to set towards a **new main directory**, then you can
64
+ use the **set_main_directory()** method:
65
+
66
+ Rcfiles.set_main_directory
67
+
68
+ As argument to this method simply pass the directory that you wish
69
+ to use to that method.
70
+
71
+ You can also use a simpler API such as:
72
+
73
+ Rcfiles.set_path
74
+
75
+ ## Commandline usage of this project:
76
+
77
+ If you do not want to auto-generate rc-files that have a "" quote, as
78
+ part of its value setting (the part on the right side of an alias),
79
+ such as for use in projects such as <b>cmder</b>, then you can use
80
+ this option:
81
+
82
+ --no-quotes
83
+
84
+ This may also be useful if you have to use a shell such as <b>cmder</b>
85
+ which appears to only support unquoted aliases.
86
+
87
+ So invoke the executable in bin/ like this:
88
+
89
+ rcfile --cmder-target
90
+ rcfile --cmder
91
+
92
+ To see where the main .yml files are, do this:
93
+
94
+ rcfiles --report
95
+
96
+ To find out hwo many aliases are part of this project, do:
97
+
98
+ rcfiles --n_aliases? # 46337 aliases are available in this project (28.08.2020).
99
+
100
+ ## How to use this project from within ruby-code
101
+
102
+ You first have to require this project, obviously:
103
+
104
+ require 'rcfiles'
105
+
106
+ Now - in order to batch-generate the various rc-files, you can use
107
+ an API such as the following one:
108
+
109
+ Rcfiles.run
110
+ Rcfiles.new
111
+
112
+ This defaults to my own aliases. For now this is how it is but in
113
+ future releases, people will be able to use their own custom
114
+ aliases.
115
+
116
+ If you want to store at the rc-files at a specific location,
117
+ such as a certain <b>directory</b>, then you can use the
118
+ symbol :store_at such as in the following example:
119
+
120
+ Rcfiles.new(store_at: Dir.pwd)
121
+
122
+ The second argument, in this case Dir.pwd, shall denote the
123
+ directory that you wish to use here.
124
+
125
+ This may be especially useful if you have no access to
126
+ the base directory at / e. g. when you are in a restricted
127
+ environment (like workstations in a university) or when
128
+ you simply want to use another directory name altogether.
129
+
130
+ The above API is a bit cumbersome, though, so you can use
131
+ any of the following toplevel APIs instead:
132
+
133
+ Rcfiles.set_store_into_this_directory
134
+ Rcfiles.set_main_directory
135
+ Rcfiles.set_path
136
+ Rcfiles.store_at=
137
+ Rcfiles.store_at=
138
+ Rcfiles.set_store_here
139
+ Rcfiles.set_store_into
140
+
141
+ ## Generating individual rc-aliases
142
+
143
+ There are several ways how to generate individual rc-aliases,
144
+ such as via <b>Rcfiles.new(:cd_aliases)</b>.
145
+
146
+ But there are other toplevel module-methods as well, such as the
147
+ following variants:
148
+
149
+ Rcfiles.generate :cd_aliases
150
+ Rcfiles.generate :aliases
151
+ Rcfiles.generate :program_aliases
152
+
153
+ And numbers as input as well, if one wants to be even shorter:
154
+
155
+ Rcfiles.generate 1
156
+ Rcfiles.generate 2
157
+ Rcfiles.generate 3
158
+
159
+ Why so many different ways? I simply just want to auto-generate
160
+ these aliases, no matter the given input. These shortcuts generate my
161
+ bash-specific aliases, but since as of March 2018, I also changed the
162
+ code to generate aliases that work on Windows in the <b>cmder</b>
163
+ shell. **cmder** is a bit different in that it requires aliases without
164
+ quotes (aka no '' or "" may be used there).
165
+
166
+ ## Determining the project's base directory
167
+
168
+ The toplevel "namespace" contains an instance variable called
169
+ **@project_base_directory**. This variable should point to
170
+ where the .rb files of this project are kept. Additionally
171
+ it will load up the .yml files that reside within the
172
+ **yml/** subdirectory there.
173
+
174
+ On my Linux home system, this works as-is, but other systems
175
+ may need to be a bit more flexible here, such as windows
176
+ perhaps, or systems where you may have no control over where
177
+ the .rb files may be placed (perhaps in a restricted
178
+ environment such as university campus).
179
+
180
+ Thus, you can modify the path to this directory via:
181
+
182
+ Rcfiles.set_project_base_directory()
183
+
184
+ You can also query the current path in use via:
185
+
186
+ Rcfiles.project_base_dir?
187
+ Rcfiles.project_base_directory?
188
+
189
+ ## Using quotes in the generated shell-rc files
190
+
191
+ The toplevel API **Rcfiles.use_quotes?** is
192
+ used to determine whether quotes will be used or not. Some
193
+ programs, such as **cmder**, need quotes.
194
+
195
+ You can toggle this behaviour like so:
196
+
197
+ Rcfiles.use_quotes = true
198
+ Rcfiles.use_quotes = false
199
+
200
+ Or simply:
201
+
202
+ Rcfiles.toggle_quotes # <- I prefer the long variant
203
+ Rcfiles.toggle # <- But the short variant is also a possibility.
204
+
205
+ The latter method will flip the state, from true to false
206
+ or from false to true.
207
+
208
+ ## Determining the file location of the different aliases in the project
209
+
210
+ Sometimes it may be necessary to set the path to yaml files, e. g. in
211
+ particular if you wish to make use of other .yml files that do **not**
212
+ come distributed with this project. That was the major reason why code
213
+ was added here, so that users can adapt the project to their use
214
+ cases.
215
+
216
+ Have a look at the following API, each one corresponding to the particular
217
+ .yml file (e. g. set_file_aliases() would denote the path to the file
218
+ called **aliases.yml**, whereas set_file_programs_aliases() would modify
219
+ the path to the file called **programs_aliases.yml** and so forth):
220
+
221
+ Rcfiles.set_file_aliases()
222
+ Rcfiles.set_programs_aliases()
223
+ Rcfiles.set_cd_aliases()
224
+
225
+ ## Rcfiles.report
226
+
227
+ You can use the toplevel method **Rcfiles.report** to report
228
+ some information about the Rcfiles project, such as from
229
+ which paths it will obtain information.
230
+
231
+ This functionality was necessary because we can re-define the paths
232
+ that are used to generate rc-files at any time; thus, we needed a
233
+ way to **query** the full path to these different files.
234
+
235
+ ## Rcfiles.infer
236
+
237
+ The toplevel method **Rcfiles.infer** can be called to
238
+ designate the path to one of the three main .yml files of this
239
+ project. It is thus similar to the three variants documented
240
+ above in this file, such as **Rcfiles.set_file_aliases()**,
241
+ **Rcfiles.set_programs_aliases()** and
242
+ **Rcfiles.set_cd_aliases()**. The difference is that
243
+ **infer()** is a lot shorter - and a lot simpler, too.
244
+
245
+ You only have to provide the path to this .yml file at hand.
246
+
247
+ Generic usage examples:
248
+
249
+ Rcfiles.infer 'aliases.yml'
250
+ Rcfiles.infer 'cd_aliases.yml'
251
+ Rcfiles.infer 'programs_aliases.yml'
252
+
253
+ In these cases these files will be automatically used, with
254
+ the path designed here. I recommend to first copy the .yml
255
+ files to e. g. your working home directory, and then call
256
+ the three .infer methods. That should help if for whatever
257
+ reason your ruby installation is unable to find the
258
+ path - or if you simply wish to use other .yml files, too.
259
+
260
+ ## Colours
261
+
262
+ By default, **Rcfiles** will make use of **colours**, as defined by
263
+ the 'colours' gem.
264
+
265
+ However had, this is **optional** and ultimately not really necessary -
266
+ it is just a convenience feature.
267
+ everyone.
268
+
269
+ If you would rather **NOT** want to use the **colours gem**, or may
270
+ encounter an error related to colours, you can change this either by
271
+ requiring the rcfiles-project a bit differently, such as through
272
+ either of these two ways (which are the same):
273
+
274
+ require 'rcfiles/no_colours'
275
+ require 'rcfiles/no_colours.rb'
276
+
277
+ This will automatically disable colours support for the **Rcfiles**
278
+ namespace.
279
+
280
+ The **first** variant is preferred, in my opinion, since it is
281
+ <b>shorter</b> - but use whatever you prefer, anyway.
282
+
283
+ You can also use the following code to generate the rc-files
284
+ without making use of colours:
285
+
286
+ Rcfiles.run { :disable_colours }
287
+
288
+ ## The directory rcfiles/
289
+
290
+ Since as of 07.04.2019 this project also includes all auto-generated
291
+ rcfiles, in the subdirectory called **rcfiles/**.
292
+
293
+ The primary reason as to why these files are distributed with this
294
+ project is so that:
295
+
296
+ a) they are available as-is when the gem is downloaded
297
+
298
+ and, even more importantly than that
299
+
300
+ b) because **psych** sometimes has problems with the main encoding used,
301
+ which means that the rc-files may not be generated on a given
302
+ computer system as-such. Hence why bundling these files into the
303
+ project directly makes this potential problem a non-issue (excluding
304
+ projects such as cmder, which require aliases to be defined without
305
+ quotes).
306
+
307
+ If you wish to copy these bundled rc-files via ruby, then you can
308
+ use the following toplevel method:
309
+
310
+ Rcfiles.copy_rcfiles_to_the_current_directory
311
+
312
+ ## Copying the rc-files via the commandline
313
+
314
+ Sometimes it may be useful to quickly copy the rc-files into your
315
+ current working directory, rather than generate them anew.
316
+
317
+ You can use the following commandline switch in order to achieve
318
+ this, and copy the registered rc-files into the current working
319
+ directory:
320
+
321
+ rcfiles --copy-rcfiles
322
+ rcfiles --copy
323
+ rcfiles --cp
324
+
325
+ I needed this functionality so that I could quickly copy the
326
+ rc-files, source them in bash, and continue working from here
327
+ past that point - mostly for convenience.
328
+
329
+ As stated elsewhere in this document, if you need to use this
330
+ functionality from ruby then you can use **Rcfiles.copy_rcfiles_to_the_current_directory**
331
+ or just **Rcfiles.copy_rcfiles**.
332
+
333
+ ## The PS1 path variable
334
+
335
+ If you wish to quickly generate a new rc-file with a default
336
+ PS1 (defaulting to my PS that is), the following commandline
337
+ variant can be used:
338
+
339
+ rcfiles --ps1
340
+
341
+ ## Generating other rc-files
342
+
343
+ You can either batch-generate all -rc files, or also cherry-pick
344
+ some of them.
345
+
346
+ Example:
347
+
348
+ rcfiles --programs-aliases
349
+
350
+ This will generate the **programs_aliases_rc file**.
351
+
352
+ ## Generating a .bat file for the cd-aliases on Windows
353
+
354
+ Certain windows-related shells, such as the fairly new
355
+ **windows-terminal**, make use of a fairly ... obscure
356
+ syntax for a cd-alias.
357
+
358
+ For example:
359
+
360
+ function pwdhome { set-location "c:\home\x" }
361
+
362
+ This would assign pwdhome to become a cd-alias to
363
+ /home/x. (Weird syntax.)
364
+
365
+ If you wish to generate such a .bat file with all
366
+ the cd-aliases available in this project, consider
367
+ using the following commandline variant:
368
+
369
+ rcfiles --windows-cd-aliases
370
+
371
+ Internally the method that is doing this is:
372
+
373
+ Rcfiles.create_windows_cd_aliases_bat_file
374
+
375
+ ## Obtaining all aliases, as a Hash
376
+
377
+ If you need to return all aliases registered in this
378
+ project, as a Hash, then you can use this toplevel
379
+ method:
380
+
381
+ Rcfiles.aliases?
382
+
383
+ In January 2021 this contained 47088 entries (key→value
384
+ pairs).
385
+
386
+
387
+ ## Contact information
388
+
389
+ If your creative mind has ideas and specific suggestions to make this
390
+ gem more useful in general, feel free to drop me an email at any
391
+ time, via:
392
+
393
+ shevegen@gmail.com
394
+
395
+ (Do keep in mind that responding to emails may take some time, depending
396
+ on the amount of work I may have at that moment, due to reallife. I will,
397
+ however had, read feedback. Patches and code changes are welcome too
398
+ of course, as long as they are in the spirit of the project at
399
+ hand, e. g. fitting to the general theme.)
400
+
401
+ Thank you.
data/bin/rcfiles ADDED
@@ -0,0 +1,7 @@
1
+ #!/usr/bin/ruby -w
2
+ # Encoding: UTF-8
3
+ # frozen_string_literal: true
4
+ # =========================================================================== #
5
+ require 'rcfiles'
6
+
7
+ Rcfiles.parse_commandline(ARGV)
@@ -0,0 +1,7 @@
1
+ #!/usr/bin/ruby -w
2
+ # Encoding: UTF-8
3
+ # frozen_string_literal: true
4
+ # =========================================================================== #
5
+ require 'rcfiles'
6
+
7
+ Rcfiles.run_it(ARGV)
data/doc/README.gen ADDED
@@ -0,0 +1,384 @@
1
+ ADD_RUBY_BADGE
2
+
3
+ ## Goals for the rcfiles project
4
+
5
+ This project will try to automatically generate valid rc-files for shells
6
+ such as bash or zsh. The default will refer to **bash** since that is the
7
+ shell that I do happen to use most of the time.
8
+
9
+ These **rc-files** are generated from yaml files. These yaml files in turn
10
+ are, mostly, also distributed with this project, but of course you can use
11
+ your own yaml files as well. More on this elsewhere in this document, but
12
+ in principle the rcfiles project could also autogenerate various .rb files
13
+ rather than rc-files, or depend on yaml files alone. This will be considered
14
+ in the long run, but for the time being (written in **April 2019**) this
15
+ is not yet a possibility.
16
+
17
+ The main idea for this project is, evidently, my own use case, which is
18
+ to primarily make my aliases, custom export settings in shells, and so
19
+ forth, available for other/new computers quickly.
20
+
21
+ ## Requiring the rcfiles project
22
+
23
+ The project is required via this way:
24
+
25
+ require 'rcfiles'
26
+
27
+ Of course you could use **load** too, but require is more common and,
28
+ in my opinion, better, unless you need the behaviour of **load**
29
+ exactly.
30
+
31
+ ## The main directory
32
+
33
+ The **main directory**, as far as the project here is concerned,
34
+ is simply the directory into which the various rc-files will be
35
+ autogenerated.
36
+
37
+ On my **home system**, this is usually the directory called
38
+ <b>/AUTOGENERATED/</b>.
39
+
40
+ The reason as to why I am using such a short, top-level directory is
41
+ that it is quite convenient for me to navigate to it or source the
42
+ various rc-files generated from that directory, such as in:
43
+
44
+ . /AUTOGENERATED/aliases_rc
45
+
46
+ However had, there is one **obvious drawback** with this approach - you
47
+ need to have write permission into that directory close to the **root**
48
+ of the filesystem, if you wish to auto-generate rc-files into that
49
+ directory. And this is not always possible, such as when you are in
50
+ a **restricted environment** (workspace-computers in a university, for
51
+ example). Or it may be unwanted by you, anyway.
52
+
53
+ Thus, it must be possible to specify another directory that is to
54
+ be used here.
55
+
56
+ If you want to **query the current main directory** in use then you
57
+ can use the following **toplevel API**:
58
+
59
+ Rcfiles.main_directory?
60
+
61
+ If you want to set towards a **new main directory**, then you can
62
+ use the **set_main_directory()** method:
63
+
64
+ Rcfiles.set_main_directory
65
+
66
+ As argument to this method simply pass the directory that you wish
67
+ to use to that method.
68
+
69
+ You can also use a simpler API such as:
70
+
71
+ Rcfiles.set_path
72
+
73
+ ## Commandline usage of this project:
74
+
75
+ If you do not want to auto-generate rc-files that have a "" quote, as
76
+ part of its value setting (the part on the right side of an alias),
77
+ such as for use in projects such as <b>cmder</b>, then you can use
78
+ this option:
79
+
80
+ --no-quotes
81
+
82
+ This may also be useful if you have to use a shell such as <b>cmder</b>
83
+ which appears to only support unquoted aliases.
84
+
85
+ So invoke the executable in bin/ like this:
86
+
87
+ rcfile --cmder-target
88
+ rcfile --cmder
89
+
90
+ To see where the main .yml files are, do this:
91
+
92
+ rcfiles --report
93
+
94
+ To find out hwo many aliases are part of this project, do:
95
+
96
+ rcfiles --n_aliases? # 46337 aliases are available in this project (28.08.2020).
97
+
98
+ ## How to use this project from within ruby-code
99
+
100
+ You first have to require this project, obviously:
101
+
102
+ require 'rcfiles'
103
+
104
+ Now - in order to batch-generate the various rc-files, you can use
105
+ an API such as the following one:
106
+
107
+ Rcfiles.run
108
+ Rcfiles.new
109
+
110
+ This defaults to my own aliases. For now this is how it is but in
111
+ future releases, people will be able to use their own custom
112
+ aliases.
113
+
114
+ If you want to store at the rc-files at a specific location,
115
+ such as a certain <b>directory</b>, then you can use the
116
+ symbol :store_at such as in the following example:
117
+
118
+ Rcfiles.new(store_at: Dir.pwd)
119
+
120
+ The second argument, in this case Dir.pwd, shall denote the
121
+ directory that you wish to use here.
122
+
123
+ This may be especially useful if you have no access to
124
+ the base directory at / e. g. when you are in a restricted
125
+ environment (like workstations in a university) or when
126
+ you simply want to use another directory name altogether.
127
+
128
+ The above API is a bit cumbersome, though, so you can use
129
+ any of the following toplevel APIs instead:
130
+
131
+ Rcfiles.set_store_into_this_directory
132
+ Rcfiles.set_main_directory
133
+ Rcfiles.set_path
134
+ Rcfiles.store_at=
135
+ Rcfiles.store_at=
136
+ Rcfiles.set_store_here
137
+ Rcfiles.set_store_into
138
+
139
+ ## Generating individual rc-aliases
140
+
141
+ There are several ways how to generate individual rc-aliases,
142
+ such as via <b>Rcfiles.new(:cd_aliases)</b>.
143
+
144
+ But there are other toplevel module-methods as well, such as the
145
+ following variants:
146
+
147
+ Rcfiles.generate :cd_aliases
148
+ Rcfiles.generate :aliases
149
+ Rcfiles.generate :program_aliases
150
+
151
+ And numbers as input as well, if one wants to be even shorter:
152
+
153
+ Rcfiles.generate 1
154
+ Rcfiles.generate 2
155
+ Rcfiles.generate 3
156
+
157
+ Why so many different ways? I simply just want to auto-generate
158
+ these aliases, no matter the given input. These shortcuts generate my
159
+ bash-specific aliases, but since as of March 2018, I also changed the
160
+ code to generate aliases that work on Windows in the <b>cmder</b>
161
+ shell. **cmder** is a bit different in that it requires aliases without
162
+ quotes (aka no '' or "" may be used there).
163
+
164
+ ## Determining the project's base directory
165
+
166
+ The toplevel "namespace" contains an instance variable called
167
+ **@project_base_directory**. This variable should point to
168
+ where the .rb files of this project are kept. Additionally
169
+ it will load up the .yml files that reside within the
170
+ **yml/** subdirectory there.
171
+
172
+ On my Linux home system, this works as-is, but other systems
173
+ may need to be a bit more flexible here, such as windows
174
+ perhaps, or systems where you may have no control over where
175
+ the .rb files may be placed (perhaps in a restricted
176
+ environment such as university campus).
177
+
178
+ Thus, you can modify the path to this directory via:
179
+
180
+ Rcfiles.set_project_base_directory()
181
+
182
+ You can also query the current path in use via:
183
+
184
+ Rcfiles.project_base_dir?
185
+ Rcfiles.project_base_directory?
186
+
187
+ ## Using quotes in the generated shell-rc files
188
+
189
+ The toplevel API **Rcfiles.use_quotes?** is
190
+ used to determine whether quotes will be used or not. Some
191
+ programs, such as **cmder**, need quotes.
192
+
193
+ You can toggle this behaviour like so:
194
+
195
+ Rcfiles.use_quotes = true
196
+ Rcfiles.use_quotes = false
197
+
198
+ Or simply:
199
+
200
+ Rcfiles.toggle_quotes # <- I prefer the long variant
201
+ Rcfiles.toggle # <- But the short variant is also a possibility.
202
+
203
+ The latter method will flip the state, from true to false
204
+ or from false to true.
205
+
206
+ ## Determining the file location of the different aliases in the project
207
+
208
+ Sometimes it may be necessary to set the path to yaml files, e. g. in
209
+ particular if you wish to make use of other .yml files that do **not**
210
+ come distributed with this project. That was the major reason why code
211
+ was added here, so that users can adapt the project to their use
212
+ cases.
213
+
214
+ Have a look at the following API, each one corresponding to the particular
215
+ .yml file (e. g. set_file_aliases() would denote the path to the file
216
+ called **aliases.yml**, whereas set_file_programs_aliases() would modify
217
+ the path to the file called **programs_aliases.yml** and so forth):
218
+
219
+ Rcfiles.set_file_aliases()
220
+ Rcfiles.set_programs_aliases()
221
+ Rcfiles.set_cd_aliases()
222
+
223
+ ## Rcfiles.report
224
+
225
+ You can use the toplevel method **Rcfiles.report** to report
226
+ some information about the Rcfiles project, such as from
227
+ which paths it will obtain information.
228
+
229
+ This functionality was necessary because we can re-define the paths
230
+ that are used to generate rc-files at any time; thus, we needed a
231
+ way to **query** the full path to these different files.
232
+
233
+ ## Rcfiles.infer
234
+
235
+ The toplevel method **Rcfiles.infer** can be called to
236
+ designate the path to one of the three main .yml files of this
237
+ project. It is thus similar to the three variants documented
238
+ above in this file, such as **Rcfiles.set_file_aliases()**,
239
+ **Rcfiles.set_programs_aliases()** and
240
+ **Rcfiles.set_cd_aliases()**. The difference is that
241
+ **infer()** is a lot shorter - and a lot simpler, too.
242
+
243
+ You only have to provide the path to this .yml file at hand.
244
+
245
+ Generic usage examples:
246
+
247
+ Rcfiles.infer 'aliases.yml'
248
+ Rcfiles.infer 'cd_aliases.yml'
249
+ Rcfiles.infer 'programs_aliases.yml'
250
+
251
+ In these cases these files will be automatically used, with
252
+ the path designed here. I recommend to first copy the .yml
253
+ files to e. g. your working home directory, and then call
254
+ the three .infer methods. That should help if for whatever
255
+ reason your ruby installation is unable to find the
256
+ path - or if you simply wish to use other .yml files, too.
257
+
258
+ ## Colours
259
+
260
+ By default, **Rcfiles** will make use of **colours**, as defined by
261
+ the 'colours' gem.
262
+
263
+ However had, this is **optional** and ultimately not really necessary -
264
+ it is just a convenience feature.
265
+ everyone.
266
+
267
+ If you would rather **NOT** want to use the **colours gem**, or may
268
+ encounter an error related to colours, you can change this either by
269
+ requiring the rcfiles-project a bit differently, such as through
270
+ either of these two ways (which are the same):
271
+
272
+ require 'rcfiles/no_colours'
273
+ require 'rcfiles/no_colours.rb'
274
+
275
+ This will automatically disable colours support for the **Rcfiles**
276
+ namespace.
277
+
278
+ The **first** variant is preferred, in my opinion, since it is
279
+ <b>shorter</b> - but use whatever you prefer, anyway.
280
+
281
+ You can also use the following code to generate the rc-files
282
+ without making use of colours:
283
+
284
+ Rcfiles.run { :disable_colours }
285
+
286
+ ## The directory rcfiles/
287
+
288
+ Since as of 07.04.2019 this project also includes all auto-generated
289
+ rcfiles, in the subdirectory called **rcfiles/**.
290
+
291
+ The primary reason as to why these files are distributed with this
292
+ project is so that:
293
+
294
+ a) they are available as-is when the gem is downloaded
295
+
296
+ and, even more importantly than that
297
+
298
+ b) because **psych** sometimes has problems with the main encoding used,
299
+ which means that the rc-files may not be generated on a given
300
+ computer system as-such. Hence why bundling these files into the
301
+ project directly makes this potential problem a non-issue (excluding
302
+ projects such as cmder, which require aliases to be defined without
303
+ quotes).
304
+
305
+ If you wish to copy these bundled rc-files via ruby, then you can
306
+ use the following toplevel method:
307
+
308
+ Rcfiles.copy_rcfiles_to_the_current_directory
309
+
310
+ ## Copying the rc-files via the commandline
311
+
312
+ Sometimes it may be useful to quickly copy the rc-files into your
313
+ current working directory, rather than generate them anew.
314
+
315
+ You can use the following commandline switch in order to achieve
316
+ this, and copy the registered rc-files into the current working
317
+ directory:
318
+
319
+ rcfiles --copy-rcfiles
320
+ rcfiles --copy
321
+ rcfiles --cp
322
+
323
+ I needed this functionality so that I could quickly copy the
324
+ rc-files, source them in bash, and continue working from here
325
+ past that point - mostly for convenience.
326
+
327
+ As stated elsewhere in this document, if you need to use this
328
+ functionality from ruby then you can use **Rcfiles.copy_rcfiles_to_the_current_directory**
329
+ or just **Rcfiles.copy_rcfiles**.
330
+
331
+ ## The PS1 path variable
332
+
333
+ If you wish to quickly generate a new rc-file with a default
334
+ PS1 (defaulting to my PS that is), the following commandline
335
+ variant can be used:
336
+
337
+ rcfiles --ps1
338
+
339
+ ## Generating other rc-files
340
+
341
+ You can either batch-generate all -rc files, or also cherry-pick
342
+ some of them.
343
+
344
+ Example:
345
+
346
+ rcfiles --programs-aliases
347
+
348
+ This will generate the **programs_aliases_rc file**.
349
+
350
+ ## Generating a .bat file for the cd-aliases on Windows
351
+
352
+ Certain windows-related shells, such as the fairly new
353
+ **windows-terminal**, make use of a fairly ... obscure
354
+ syntax for a cd-alias.
355
+
356
+ For example:
357
+
358
+ function pwdhome { set-location "c:\home\x" }
359
+
360
+ This would assign pwdhome to become a cd-alias to
361
+ /home/x. (Weird syntax.)
362
+
363
+ If you wish to generate such a .bat file with all
364
+ the cd-aliases available in this project, consider
365
+ using the following commandline variant:
366
+
367
+ rcfiles --windows-cd-aliases
368
+
369
+ Internally the method that is doing this is:
370
+
371
+ Rcfiles.create_windows_cd_aliases_bat_file
372
+
373
+ ## Obtaining all aliases, as a Hash
374
+
375
+ If you need to return all aliases registered in this
376
+ project, as a Hash, then you can use this toplevel
377
+ method:
378
+
379
+ Rcfiles.aliases?
380
+
381
+ In January 2021 this contained 47088 entries (key→value
382
+ pairs).
383
+
384
+ ADD_CONTACT_INFORMATION