Projects / readpreprompt

readpreprompt

This is a simple program to read a string of text from the user. The difference between this program and the bash builtin "read" command is that this program allows you to specify text that will be initially placed into the input edit buffer. That is, you can specify "default" input text that has been "pre-typed" for the user.

Tags
Licenses
Operating Systems
Implementation

RSS Recent releases

  •  28 Jun 2006 08:54

No changes have been submitted for this release.

RSS Recent comments

06 Jul 2006 16:50 fake666

Re: why not use...
i understand and totally agree ;)

28 Jun 2006 18:09 kpulo

Re: why not use...

> read -p "prompt" ?

Because that only sets the prompt, which is not enough. I want a default value provided in the input area, to save me from retyping that value.

For example, when I hit enter after typing:

mv readpreprompt.c

I want a readline input line, but I want the text "readpreprompt.c" to already be in the input buffer. That way, I can just type ".old" followed by enter, to "rename" the file "readpreprompt.c" to "readpreprompt.c.old". Or I could hit ctrl-a followed by "OLD", etc. The alternative to this is to fully type out the command "mv readpreprompt.c readpreprompt.c.old", which I get sick of doing, especially for long filenames. Using tab completion can help, but it's still a pain when there are a lot of similarly named files.

Unfortunately, as far as I am aware, there is no option for bash's builtin "read" command which sets the default input text, even in bash 3.1. Ideally, I would like to be able to do something like this:

read -e -p "New filename: " -i "$1" fname

where the -i indicates the "initial" text to be provided to the user. This would be perfect, but it does not exist. At some point soon I hope to take a look at the bash source and see about adding this functionality, which shouldn't be too hard.

28 Jun 2006 15:49 fake666

why not use...
read -p "prompt" ?

Screenshot

Project Spotlight

Highlight

A universal source code to formatted text converter.

Screenshot

Project Spotlight

libdvbpsi

A library designed for MPEG TS and DVB PSI tables decoding and generation.