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 =
#

INPUTRC_NAME

The FHS location of inputrc

#
'inputrc'
INPUTRC_FHS_LOCATION =
#

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 =
#

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

Methods included from Base::CommandlineArguments

#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

#

initialize

#


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
  # ======================================================================= #
  # We will store where to save the inputrc stuff at the following
  # location:
  # ======================================================================= #
  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, append_extra_newline = true
  )
  case i
  when :newline
    i = N
    append_extra_newline = false
  end
  @_ << i.dup
  @_ << "\n" if append_extra_newline == true
end

#add_delete_charObject

#

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
  append_comment
  _ '# 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 ^?'
  append_comment
  _ '"\e[3~": delete-char' # <- Should be: "\e[3~": delete-char
  #_ 'bindkey "^?" delete-char'
  # _ '"\e[2~" quoted-insert'
  add_newline
end

#add_header_subsectionObject

#

add_header_subsection

#


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 add_header_subsection
  append_comment
  _ '# 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
# =========================================================================== #'
  append_comment
end

#add_horizontal_scroll_modeObject

#

add_horizontal_scroll_mode

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
  append_comment
  _ '# Allow the command prompt to wrap to the next line'
  append_comment
  _ 'set horizontal-scroll-mode '+mode_off
  add_newline
end

#add_newlineObject

#

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 # This is sufficient.
end

#add_rxvt_specific_settingsObject

#

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
  # ======================================================================= #
  # Rxvt Tag.
  # ======================================================================= #
  append_comment
  _ '# for rxvt'
  append_comment
  _ '"\e[7~":beginning-of-line'
  _ '"\e[8~":end-of-line'
end

#add_xterm_specific_settingsObject

#

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
  append_comment
  _ '# for xterm'
  append_comment
  _ '"\eOH" beginning-of-line'
  _ '"\eOF" end-of-line'
end

#append_commentObject Also known as: add_comment

#

append_comment

#


143
144
145
# File 'lib/roebe/classes/inputrc/inputrc.rb', line 143

def append_comment
  add return_comment
end

#buildup_the_string_that_we_wish_to_storeObject

#

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_header_subsection
  add_newline
  add_delete_char
  disable_bell_event
  set_coloured_stats_on
  set_autocompletion_to_ignore_cases
  set_output_meta
  set_completion_query_items
  # ======================================================================= #
  # For konsole
  # ======================================================================= #
  # _ '# for Konsole'
  # _ '"\e[H" beginning-of-line'
  # _ '"\e[F" end-of-line'
  add_horizontal_scroll_mode
  add_rxvt_specific_settings
  add_xterm_specific_settings
  
  # ======================================================================= #
  # === 8bit Input
  #
  # input-meta is a synonym to meta-flag.
  # ======================================================================= #
  append_comment
  _ '# Enable 8bit input'
  append_comment
  _ 'set meta-flag '+mode_on
  _ 'set input-meta '+mode_on

  # ======================================================================= #
  # === convert-meta
  #
  # This will turn off 8th bit stripping. The setting is:
  #
  #   set convert-meta Off
  #
  # ======================================================================= #
  append_comment
  _ '# 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.'
  append_comment
  _ 'set convert-meta '+mode_off
  add_newline

  # ======================================================================= #
  # set completion-query-items to 5000.
  # ======================================================================= #
  append_comment
  _ '# Show the "Display all 123 possibilities? (y or n)" '
  _ '# prompt only for really long lists.'
  append_comment
  _ 'set completion-query-items 5000'
  add_newline

  # ======================================================================= #
  # set show-all-if-ambiguous
  # ======================================================================= #
  append_comment
  _ '# Show ambiguity'
  append_comment
  _ 'set show-all-if-ambiguous '+mode_on
  add_newline    

  # ======================================================================= #
  #
  # ======================================================================= #
  # append_comment
  # _ '# Completed names which are symbolic links to'
  # _ '# directories have a slash appended. Thats a nice hint'
  # _ '# so lets keep it.'
  # append_comment
  # _ 'set mark-symlinked-directories '+mode_on
  
  # ======================================================================= #
  # bind-tty-special-chars (On)
  # If set to On, readline attempts to bind the control characters
  # treated specially by the kernel's terminal driver to 
  # their readline equivalents.
  # ======================================================================= #
  # append_comment
  # _ '# bind-tty-special-chars performs conversion from'
  # _ '# kernels terminal driver to readline equivalents'
  # append_comment
  # _ 'set bind-tty-special-chars '+mode_on
  
  # ======================================================================= #
  # show-all-if-ambiguous (default: off)
  # This alters the default behavior of the completion functions. 
  # If set to on, words which have more than one possible completion
  # cause the matches to be listed immediately instead of ringing
  # the bell or making a break.   
  # ======================================================================= #
  # append_comment
  # _ '# Next line is useful if you press TAB, it will show you all'
  # _ '# possible substitutions _immediately_, and not after pressing' 
  # _ '# the tab key again.'
  # append_comment
  # _ 'set show-all-if-ambiguous '+mode_on
  
  # ======================================================================= #
  # completion-ignore-case
  # ======================================================================= #
  # append_comment
  # _ '# The following is for case insensitive TAB completion. ' 
  # _ '# Set it off if bash-completion annoys you.'
  # append_comment
  # _ 'set completion-ignore-case '+mode_off

  # ======================================================================= #
  # mark-directories
  # ======================================================================= #
  # append_comment
  # _ '# denote directories with a trailing / if tab is pressed'
  # append_comment
  # _ 'set mark-directories '+mode_on
  
  # ======================================================================= #
  # === Readline-specific functions
  # ======================================================================= #
  append_comment
  _ '# All of the following map the escape sequence of the value'
  _ '# contained in the 1st argument to the readline specific functions'
  append_comment
  _ '"\eOd" backward-word'
  _ '"\eOc" forward-word'
  add_newline

  # ======================================================================= #
  # === For the Linux Console
  # ======================================================================= #
  append_comment
  _ '# for the linux console'
  append_comment
  _ '"\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

  # ======================================================================= #
  # Remap KP_ENTER. I believe this has the side-effect that the
  # x key no longer works. 
  # ======================================================================= #
  # append_comment
  # _ '# Remap KP_ENTER to behave just like the return key.'
  # append_comment
  # _ 'xmodmap -e "keysym KP_Enter = Return"'
end

#delete_the_old_file_if_it_existsObject

#

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_eventObject

#

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
  append_comment
  _ '# 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.'
  append_comment
  _ 'set bell-style none'
  add_newline
end

#inputrc_location?Boolean

#

inputrc_location?

#

Returns:

  • (Boolean)


119
120
121
# File 'lib/roebe/classes/inputrc/inputrc.rb', line 119

def inputrc_location?
  @inputrc_location
end

#main_string?Boolean

#

main_string?

#

Returns:

  • (Boolean)


168
169
170
# File 'lib/roebe/classes/inputrc/inputrc.rb', line 168

def main_string?
  @_
end
#

menu (menu tag)

#


91
92
93
94
95
96
97
98
99
100
101
102
103
104
# File 'lib/roebe/classes/inputrc/inputrc.rb', line 91

def menu(i)
  if i.is_a? Array
    i.each {|entry| menu(entry) }
  else
    case i # case tag
    # ===================================================================== #
    # === rinputrc --help
    # ===================================================================== #
    when /^-?-?help/
      show_help
      exit
    end
  end
end

#mode_offObject

#

mode_off

#


425
426
427
# File 'lib/roebe/classes/inputrc/inputrc.rb', line 425

def mode_off
  'off'
end

#mode_onObject

#

mode_on

#


418
419
420
# File 'lib/roebe/classes/inputrc/inputrc.rb', line 418

def mode_on
  'on'
end

#resetObject

#

reset

#


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

#return_commentObject

#

return_comment

#


136
137
138
# File 'lib/roebe/classes/inputrc/inputrc.rb', line 136

def return_comment
  '# =========================================================================== #'
end

#runObject

#

run

#


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_casesObject

#

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
  append_comment
  _ '# Set auto completion to ignore cases:'
  append_comment
  _ 'set completion-ignore-case On'
  add_newline
end

#set_coloured_stats_onObject

#

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
  add_comment
  _ '# 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_comment
  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
  )
  # ======================================================================= #
  # completion-query-items
  # ======================================================================= #
  append_comment
  _ '# I believe this shows how many completion items we query.'
  _ '# Whatever that actually means.'
  append_comment
  _ 'set completion-query-items '+to.to_s
  add_newline
end

#set_inputrc_location(i = INPUTRC_FHS_LOCATION) ⇒ Object

#

set_inputrc_location

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
    menu(i)
    i = i.first
  end
  case i # case tag
  # ======================================================================= #
  # === pwd
  # ======================================================================= #
  when /^-?-?pwd$/i
    i = return_pwd+INPUTRC_NAME
  # ======================================================================= #
  # === fhs
  # ======================================================================= #
  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

#set_output_metaObject

#

set_output_meta

Output-meta tag.

#


434
435
436
437
438
439
440
441
442
# File 'lib/roebe/classes/inputrc/inputrc.rb', line 434

def set_output_meta
  append_comment
  _ '# 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.'
  append_comment
  _ 'set output-meta '+mode_on
  add_newline
end

#show_helpObject

#

show_help (help tag)

#


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_stringObject 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