End of Life Ruby 3.1 has reached end of life and gets no more fixes. Switch to Ruby 4.0 →
class method
Readline.completion_append_character=
Readline.completion_append_character = char
ext/readline/readline.c
View on GitHub ↗
static VALUE
readline_s_set_completion_append_character(VALUE self, VALUE str)
{
if (NIL_P(str)) {
rl_completion_append_character = '\0';
}
else {
OutputStringValue(str);
if (RSTRING_LEN(str) == 0) {
rl_completion_append_character = '\0';
} else {
rl_completion_append_character = RSTRING_PTR(str)[0];
}
}
return self;
}
Specifies a character to be appended on completion. Nothing will be appended if an empty string (“”) or nil is specified.
For example:
Example
require "readline" Readline.readline("> ", true) Readline.completion_append_character = " "
Result:
> Input "/var/li". > /var/li Press TAB key. > /var/lib Completes "b" and appends " ". So, you can continuously input "/usr". > /var/lib /usr
NOTE: Only one character can be specified. When “string” is specified, sets only “s” that is the first.
Example
require "readline" Readline.completion_append_character = "string" p Readline.completion_append_character # => "s"
Raises NotImplementedError if the using readline library does not support.