From: Tim Heaney Date: 2005-10-10T00:01:52+09:00 Subject: GNU readline with suggested text Say I am using GNU readline to get a line of input like so require 'readline' line = Readline.readline("Enter name: ") puts "Hello " + line and I want to put some suggested text on the line to be edited, rather than start with a blank line. GNU readline has something called rl_startup_hook, which I might use like so in C int insert_my_line () { return rl_insert_text(getenv("LOGNAME")); } int main () { char* line; rl_startup_hook = insert_my_line; if ( (line = readline("Enter your name: ")) == NULL) { fprintf(stderr, "Cannot get line of input!\n"); return 1; } printf("Hello %s\n", line); return 0; } In Perl, this appears as an optional second argument to readline $line = $term->readline("Enter your name: ", $ENV{LOGNAME}); In Python, I use set_startup_hook much like I do in C readline.set_startup_hook(lambda: readline.insert_text(os.getenv("LOGNAME"))) line = raw_input("Enter your name: ") I can't work out what to do in Ruby. Like Perl, Ruby has an optional second argument to readline, but it toggles history. This startup hook doesn't seem to be available to me. Am I just missing it or is there something else I'm meant to do? Thanks, Tim