Class: Roebe::Inputrc
- Inherits:
-
Base
show all
- Defined in:
- lib/roebe/classes/inputrc/misc.rb,
lib/roebe/classes/inputrc/inputrc.rb,
lib/roebe/classes/inputrc/constants.rb
Constant Summary
collapse
- INPUTRC_NAME =
#
The FHS location of inputrc
#
'inputrc'
- INPUTRC_FHS_LOCATION =
#
The default FHS location is at /etc/inputrc.
#
"/etc/#{INPUTRC_NAME}"
- READLINE_SETTINGS_DIR =
#
READLINE_SETTINGS_DIR
#
'/Programs/Readline/Settings'
- DEFAULT_INPUTRC_LOCATION =
ENV['INPUTRC'].to_s
Constants inherited
from Base
Base::COLOURS, Base::HOME_DIRECTORY_OF_USER_X, Base::N, Base::NAMESPACE
Instance Method Summary
collapse
Methods inherited from Base
#actions, #append_this_onto_that_file, #append_what_into, #be_silent, #be_verbose?, #beautiful_url, #burlywood, #call_next, #chdir, #cheerful_guy, #cliner, #complex_esystem, #convert_global_env, #copy_directory, #copy_file, #cornflowerblue, #create_directory, #crimson, #current_month?, #current_time?, #current_year?, #cyan, #darkcyan, #darkgreen, #darkkhaki, #darkslateblue, #deeppink, #delete_symlink, #do_not_use_the_base_colours, #do_use_the_base_colours, #e, #ecomment, #editor_to_use?, #efancy, #eimp, #emphasis, #ensure_main_encoding, #ensure_utf_encoding, #eparse, #erev, #esteelblue, #etomato, #ewarn, #exit_program, #firebrick, #get_current_day, #get_current_month, #get_files_and_directories, #get_files_from, #get_german_name_for_this_weekday, #gold, #green, #grey, #hh_mm_ss, #hh_mm_ss_day_month_year, #home_dir?, #home_directory_of_user_x?, #infer_the_namespace, #internal_hash?, #is_a_directory?, #is_a_file?, #is_a_jpg_file?, #is_an_image_file?, #is_archive?, #is_audio_file?, #is_in_studium_dir?, #is_multimedia_file?, #is_on_roebe?, #is_on_windows?, #is_studium_available?, #is_symlink?, #is_this_a_ruby_file?, #is_video_file?, #iso_encoding?, #le, #left_colour, #lightblue, #lightgreen, #lightseagreen, #lightsteelblue, #lime, #limegreen, #localhost_to_data, #log_directory?, #main_encoding?, #mediumorchid, #mediumpurple, #mediumseagreen, #mediumslateblue, #mediumspringgreen, #mediumturquoise, #mkdir_p, #mv, #n_days_in_this_month, #n_pages_in_this_pdf_file?, #namespace?, #no_file_exists_at, #ogrey, #olive, #olivedrab, #open_in_browser, #opne, #opnesystem, #opnn, #orange, #orchid, #orev, #palegoldenrod, #palevioletred, #pink, #powderblue, #programs_dir?, #project_base_dir?, #random_html_colour, #rds, #read_file_in_iso_encoding, #read_file_via_the_default_encoding, #read_lines_via_iso_encoding, #readlines_with_main_encoding, #red, #register_sigint, #remove, #remove_directory, #remove_file, #rename_kde_konsole_tab, #replace_localhost_with_data, #report_pwd, #require_rescue, #reset_the_internal_hash, #return_all_directories_from_this_directory, #return_all_files_from_this_directory, #return_current_directory, #return_dd_mm_yyyy, #return_file_or_directory_of, #return_files_from_pwd, #return_last_part_of_the_current_directory, #return_utc, #rev, #right_arrow?, #right_colour, #roebe_log_directory?, #rosybrown, #royalblue, #ruby_base_directory?, #run_in_background, #run_rcfiles_then_run_ata_via_qdbus, #sandybrown, #sdir, #seagreen, #set_be_verbose, #set_xorg_buffer, #sfancy, #sfile, #silent_redirection?, #simp, #simple_esystem, #skyblue, #slateblue, #slategray, #springgreen, #steelblue, #string_italic, #swarn, #symlink, #teal, #temp_dir?, #to_camelcase, #to_counted_hash, #tomato, #touch, #try_to_require_the_beautiful_url_gem, #try_to_require_the_html_template, #try_to_require_the_open_gem, #try_to_require_the_program_information_gem, #try_to_require_the_xorg_buffer, #use_colours?, #verbose_truth, #weekday?, #word_wrap, #write_what_into, #yellow
#append_onto_the_commandline_arguments, #clear_commandline_arguments, #commandline_arguments?, #commandline_arguments_as_string?, #commandline_arguments_without_leading_hyphens?, #first_argument?, #first_argument_without_leading_hyphens?, #has_an_argument_been_passed?, #remove_hyphened_arguments_from_the_commandline_arguments, #return_commandline_arguments_with_leading_hyphens, #second_argument?, #set_commandline_arguments
Constructor Details
#initialize(location_of_inputrc = DEFAULT_INPUTRC_LOCATION, run_already = true) ⇒ Inputrc
39
40
41
42
43
44
45
46
47
48
49
50
51
52
|
# File 'lib/roebe/classes/inputrc/inputrc.rb', line 39
def initialize(
location_of_inputrc = DEFAULT_INPUTRC_LOCATION,
run_already = true
)
reset
set_inputrc_location(
location_of_inputrc
)
run if run_already
end
|
Instance Method Details
#add(i, append_extra_newline = true) ⇒ Object
Also known as:
add_string, _
#
add (add tag)
This method can be used to add to the main String.
#
152
153
154
155
156
157
158
159
160
161
162
|
# File 'lib/roebe/classes/inputrc/inputrc.rb', line 152
def add(
i, = true
)
case i
when :newline
i = N
= false
end
@_ << i.dup
@_ << "\n" if == true
end
|
#add_delete_char ⇒ Object
#
add_delete_char (delete tag)
This should allow us to respond to the delete-character or delete-event pressed on the keyboard.
Delete in this context is equivalent to “e[3~”.
#
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
|
# File 'lib/roebe/classes/inputrc/inputrc.rb', line 507
def add_delete_char
_ '# delete-char is needed for old broken term apps, but may'
_ '# disturb the behaviour of some old apps on AIX, ie. '
_ '# screen in xterm.'
_ '#'
_ '# In general, this setting may fix that you get a ~ instead of'
_ '# deleting-a-character.'
_ '#'
_ '# ^? is a shortcut for ASCII DEL, which is done by Ctr-v Del'
_ '#'
_ '# The e[3~ should work better than ^?'
_ '"\e[3~": delete-char' add_newline
end
|
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
|
# File 'lib/roebe/classes/inputrc/inputrc.rb', line 175
def
_ '# This is an autogenerated file, created at '+dd_mm_yyyy
_ '
# =========================================================================== #
# This is for programs that are using readline. It is a global inputrc
# for libreadline - in other words, readline will use the information
# contained in this file here.
#
# Readline ist eine Bibliothek, die Eingabe-Funktionen für Bash und die
# meisten anderen Shells zur Verfügung stellt.
# =========================================================================== #
# Legende:
# Pos1 Key: beginning-of-line
# End Key: end-of-line
# =========================================================================== #
# Keybindings for Readline
# =========================================================================== #
# cat $INPUTRC
# =========================================================================== #'
end
|
#
Make sure we don’t output everything on the first line.
This may lead to some problems, such as that you can not easily copy/paste long commands perhaps.
#
365
366
367
368
369
370
371
|
# File 'lib/roebe/classes/inputrc/inputrc.rb', line 365
def add_horizontal_scroll_mode
_ '# Allow the command prompt to wrap to the next line'
_ 'set horizontal-scroll-mode '+mode_off
add_newline
end
|
#add_newline ⇒ Object
#
add_newline
This method will add a new line.
#
531
532
533
|
# File 'lib/roebe/classes/inputrc/inputrc.rb', line 531
def add_newline
add :newline end
|
#add_rxvt_specific_settings ⇒ Object
#
add_rxvt_specific_settings
#
387
388
389
390
391
392
393
394
395
396
|
# File 'lib/roebe/classes/inputrc/inputrc.rb', line 387
def add_rxvt_specific_settings
_ '# for rxvt'
_ '"\e[7~":beginning-of-line'
_ '"\e[8~":end-of-line'
end
|
#add_xterm_specific_settings ⇒ Object
#
add_xterm_specific_settings (xterm tag)
#
376
377
378
379
380
381
382
|
# File 'lib/roebe/classes/inputrc/inputrc.rb', line 376
def add_xterm_specific_settings
_ '# for xterm'
_ '"\eOH" beginning-of-line'
_ '"\eOF" end-of-line'
end
|
143
144
145
|
# File 'lib/roebe/classes/inputrc/inputrc.rb', line 143
def
add
end
|
#buildup_the_string_that_we_wish_to_store ⇒ Object
#
buildup_the_string_that_we_wish_to_store
This method will be used to build up the string that we wish to store at /etc/inputrc or elsewhere.
#
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
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
|
# File 'lib/roebe/classes/inputrc/inputrc.rb', line 204
def buildup_the_string_that_we_wish_to_store
add_newline
add_delete_char
disable_bell_event
set_coloured_stats_on
set_autocompletion_to_ignore_cases
set_output_meta
set_completion_query_items
add_horizontal_scroll_mode
add_rxvt_specific_settings
add_xterm_specific_settings
_ '# Enable 8bit input'
_ 'set meta-flag '+mode_on
_ 'set input-meta '+mode_on
_ '# Turns off 8th bit stripping, needed for german umlauts.'
_ '# Comment it out if you do _NOT_ need german umlauts.'
_ '# I, however had, need this turned OFF due to german umlauts.'
_ 'set convert-meta '+mode_off
add_newline
_ '# Show the "Display all 123 possibilities? (y or n)" '
_ '# prompt only for really long lists.'
_ 'set completion-query-items 5000'
add_newline
_ '# Show ambiguity'
_ 'set show-all-if-ambiguous '+mode_on
add_newline
_ '# All of the following map the escape sequence of the value'
_ '# contained in the 1st argument to the readline specific functions'
_ '"\eOd" backward-word'
_ '"\eOc" forward-word'
add_newline
_ '# for the linux console'
_ '"\e[1~": beginning-of-line'
_ '"\e[2~": quoted-insert'
_ '"\e[3~": delete-char'
_ '"\e[4~": end-of-line'
_ '"\e[5~": beginning-of-history'
_ '"\e[6~": end-of-history'
add_newline
end
|
#delete_the_old_file_if_it_exists ⇒ Object
#
delete_the_old_file_if_it_exists
#
548
549
550
551
552
|
# File 'lib/roebe/classes/inputrc/inputrc.rb', line 548
def delete_the_old_file_if_it_exists
if File.exist? @inputrc_location
delete_file @inputrc_location
end
end
|
#disable_bell_event ⇒ Object
#
disable_bell_event
This method will disable the bell event, by controlling what happens when readline wants to ring the terminal bell.
If set to “none”, readline never rings the bell. Set to “visible” means that readline will use a visible bell rather than an audio-bell.
Set to “audible” means readline attempts to ring the terminal’s bell, which is EXTREMELY annoying and quite useless altogether.
So this method mostly just disables the bell altogether, as I consider it to be an antifeature.
#
486
487
488
489
490
491
492
493
494
495
496
497
|
# File 'lib/roebe/classes/inputrc/inputrc.rb', line 486
def disable_bell_event
_ '# This setting will disable the bell "sound".'
_ '# Possible settings can be:'
_ '#'
_ '# None, visible or audible. None is best IMHO,'
_ '#'
_ '# as the beep sound is extremely annoying.'
_ 'set bell-style none'
add_newline
end
|
119
120
121
|
# File 'lib/roebe/classes/inputrc/inputrc.rb', line 119
def inputrc_location?
@inputrc_location
end
|
#main_string? ⇒ Boolean
168
169
170
|
# File 'lib/roebe/classes/inputrc/inputrc.rb', line 168
def main_string?
@_
end
|
91
92
93
94
95
96
97
98
99
100
101
102
103
104
|
# File 'lib/roebe/classes/inputrc/inputrc.rb', line 91
def (i)
if i.is_a? Array
i.each {|entry| (entry) }
else
case i when /^-?-?help/
show_help
exit
end
end
end
|
425
426
427
|
# File 'lib/roebe/classes/inputrc/inputrc.rb', line 425
def mode_off
'off'
end
|
418
419
420
|
# File 'lib/roebe/classes/inputrc/inputrc.rb', line 418
def mode_on
'on'
end
|
126
127
128
129
130
131
|
# File 'lib/roebe/classes/inputrc/inputrc.rb', line 126
def reset
super()
infer_the_namespace
set_inputrc_location(:default)
@_ = ''.dup
end
|
136
137
138
|
# File 'lib/roebe/classes/inputrc/inputrc.rb', line 136
def
'# =========================================================================== #'
end
|
557
558
559
560
561
|
# File 'lib/roebe/classes/inputrc/inputrc.rb', line 557
def run
delete_the_old_file_if_it_exists
buildup_the_string_that_we_wish_to_store
store_the_main_string
end
|
#set_autocompletion_to_ignore_cases ⇒ Object
#
set_autocompletion_to_ignore_cases
#
447
448
449
450
451
452
453
|
# File 'lib/roebe/classes/inputrc/inputrc.rb', line 447
def set_autocompletion_to_ignore_cases
_ '# Set auto completion to ignore cases:'
_ 'set completion-ignore-case On'
add_newline
end
|
#set_coloured_stats_on ⇒ Object
#
set_coloured_stats_on
#
458
459
460
461
462
463
464
465
466
467
468
|
# File 'lib/roebe/classes/inputrc/inputrc.rb', line 458
def set_coloured_stats_on
_ '# The colored-stats line sets readline to display possible '
_ '# completions using different colors to indicate their file types.'
_ '#'
_ '# The colors are determined by the environmental'
_ '# variable LS_COLORS, which can be nicely configured.'
add 'set colored-stats On'
add_newline
end
|
#set_completion_query_items(to = 500) ⇒ Object
#
set_completion_query_items
#
401
402
403
404
405
406
407
408
409
410
411
412
413
|
# File 'lib/roebe/classes/inputrc/inputrc.rb', line 401
def set_completion_query_items(
to = 500
)
_ '# I believe this shows how many completion items we query.'
_ '# Whatever that actually means.'
_ 'set completion-query-items '+to.to_s
add_newline
end
|
#
Use only this when modifying @inputrc_location.
The variable @inputrc_location will determine where to store the inputrc file.
#
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
|
# File 'lib/roebe/classes/inputrc/inputrc.rb', line 62
def set_inputrc_location(
i = INPUTRC_FHS_LOCATION
)
if i.is_a? Array
(i)
i = i.first
end
case i when /^-?-?pwd$/i
i = return_pwd+INPUTRC_NAME
when 'fhs','default',nil, :default
i = INPUTRC_FHS_LOCATION
when false, '1'
i = READLINE_SETTINGS_DIR
when true, '2'
i = ENV['INPUTRC']
end
@inputrc_location = i
end
|
434
435
436
437
438
439
440
441
442
|
# File 'lib/roebe/classes/inputrc/inputrc.rb', line 434
def set_output_meta
_ '# Keep the 8th bit for display. I think this is needed for '
_ '# Umlaute.'
_ '# 8-Bit-Zeichen will be shown as 7-Bit-Zeichen with a prefix.'
_ 'set output-meta '+mode_on
add_newline
end
|
#show_help ⇒ Object
109
110
111
112
113
114
|
# File 'lib/roebe/classes/inputrc/inputrc.rb', line 109
def show_help
e 'Commandline options:'
e
e ' --pwd # store into the current working directory'
e
end
|
#store_the_main_string ⇒ Object
Also known as:
create_inputrc_file
#
store_the_main_string
#
538
539
540
541
542
543
|
# File 'lib/roebe/classes/inputrc/inputrc.rb', line 538
def store_the_main_string
what = main_string?
into = @inputrc_location
opne "Storing into `#{sfile(into)}`."
write_what_into(what, into)
end
|