INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Member Login

HANDLE


PASSWORD
Remember Me
Forgot Password?

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!

E-mail*
Handle

Password
Verify P'word
*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
Partner Button
(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
bigoldbulldog (Programmer)
24 Apr 02 7:07
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
Helpful Member!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.
Helpful Member!Helpful Member!Einstein47 (IS/IT--Management)
29 Apr 02 1:19
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.)

Start A New Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Promoting, selling, recruiting and student posting
are not allowed in the forums.
Posting Policies

LINK TO THIS FORUM!
(Add Stickiness To Your Site By Linking To This Professionally Managed Technical Forum)
TITLE: UNIX Scripting Forum at Tek-Tips
URL: http://www.tek-tips.com/threadminder.cfm?pid=822
DESCRIPTION: UNIX Scripting technical support forum and mutual help system for computer professionals. Selling and recruiting forbidden.

 

Back To Forum