INTELLIGENT WORK FORUMS FOR COMPUTER PROFESSIONALS
Come Join Us!
- Talk With Other Members
- Be Notified Of Responses
To Your Posts
- Keyword Search
- Turn Off Ad Banners
- One-Click Access To Your
Favorite Forums
- Automated Signatures
On Your Posts
- Best Of All, It's Free!
*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.
Partner With Us!
"Best Of Breed" Forums Add Stickiness To Your Site

(Download This Button Today!)
Member Feedback
"...This has been the MOST helpful forum that I have been a part of and I want to say thank you. The tips, tricks and helpful advice that you all contribute to have been lifesavers in many instances..."
Geography
Where in the world do Tek-Tips members come from?
|
Autocomplete in Unix Shell
|
|
|
Jared M. (Visitor) |
24 Apr 02 0:54 |
Hi!
Does anyone know if unix have an autocomplete feature? The user is asked to input something and the word auto completes? Like the script will look at an existing file for reference?
TY! Jared |
|
You do have an option to autocomplete by typing the escape key in csh or tab in bash/tcsh. If your looking to have it go automatically then I don't know off hand. You would probably have to write your own program in C to do this. Also you have to catch all typed characters once the autocomplete feature begins to prevent adding extra, and probably wrong, characters. You also have to deal with partial completions when the program can't disambiguate between choices with the same root of characters. If anyone has something like this I would also be very interested. Cheers, ND  |
|
grega (Programmer) |
24 Apr 02 8:08 |
I would have tended to agree with bulldog on this ... but I've just tried it in ksh. ksh filename autocomplete appears to work when used inside a read command. In ksh, autocomplete is triggered by Esc-\ sequence.
Maybe not exactly what you want, but probably the best you can get without writing something specific yourself.
Greg.
|
|
To enable what they others have said, make sure you have the line set -o vi
in your .profile or .login scripts. Then you can enjoy the vi editor commands (and more) right from the command prompt. To envoke the editor, simply hit the ESC key. Just like going from input mode to command mode inside of vi. Some of the more useful key strokes: ESC+\ = autocomplete, will complete upto the non-unique character. ESC+* = space delimited list of all files that match the pattern you started with. ESC+/str = search the commandline history for str. ESC+n = search for the next occurance of str. ESC+k = go back one in the commandline history. ESC+j = go forward one in the commandline history. ESC+$ = go to the end of the current line ESC+0 = go to the beginning of the current line ESC+i = return to insert mode ESC+A = append to the end of the current line ESC+I = insert from the beginning of the current line ESC+fx = move cursor to the right until the next occurance of x ESC+Fx = move cursor to the left until the next occurance of x ESC+x = delete character under cursor and place it in the buffer ESC+p = place the contents of the buffer after the cursor (combining the last two keystrokes) ESC+xp = transpose two characters (I use this alot)
Good luck, and keep trying diferent combinations, it is amazing the power of the Unix command line. Einstein47 (Love is like PI - natural, irrational, endless, and very important.) |
|
|
 |
|