[comp.unix.shell] set filec in the KSH?

mcover@magnus.acs.ohio-state.edu (Mark Coverdill) (04/15/91)

Having used the csh for many months I find myself having to switch to
the ksh. I really miss the ability to complete a filename by hitting
the ESC key aka the 'set filec' command in the csh. Is there such a
command in the ksh? Efforts to find the appropriate magic words have
been fruitless to this point.

BTW Assuming not all ksh's are created equal the machine is a RS6000
running AIX 3.1 3002.

-- 
Mark Coverdill                                  The Ohio State University
Internet: mcover@magnus.acs.ohio-state.edu             Columbus, Ohio
        It's a dog eat dog world and I'm wearing milkbone underwear
                                -- Norman in an opening scene of _Cheers_

lvc@cbnews.att.com (lawrence.v.cipriani) (04/15/91)

In article <1991Apr14.175109.10183@magnus.acs.ohio-state.edu> mcover@magnus.acs.ohio-state.edu (Mark Coverdill) writes:
>
>Having used the csh for many months I find myself having to switch to
>the ksh. I really miss the ability to complete a filename by hitting
>the ESC key aka the 'set filec' command in the csh. Is there such a
>command in the ksh?

You can use <ESC> followed by * for filename completion.  For example,
suppose in my home directory is:

	$ ls $HOME
	psycho
	loopy

Then I can enter:

	$ vi $HOME/p<ESC>*

and the command completes to:

	$ vi $HOME/psycho_

the _ marking the cursor position.
-- 
Larry Cipriani, att!cbvox!lvc or lvc@cbvox.att.com
"Offensive is in the eye of the beholder." -- me

lvc@cbnews.cb.att.com (lawrence.v.cipriani) (04/15/91)

In article <1991Apr14.222646.29794@cbnews.att.com>, lvc@cbnews.att.com (lawrence.v.cipriani) writes:
> In article <1991Apr14.175109.10183@magnus.acs.ohio-state.edu> mcover@magnus.acs.ohio-state.edu (Mark Coverdill) writes:
> >
> >Having used the csh for many months I find myself having to switch to
> >the ksh. I really miss the ability to complete a filename by hitting
> >the ESC key aka the 'set filec' command in the csh. Is there such a
> >command in the ksh?
> 
> You can use <ESC> followed by * for filename completion.

I got a correction to this:

+ Yes, but the equivalent to ESC on the csh is ESC \ in ksh. ie,
+ it will expand only to the common prefix if there is more than
+ 1 match. If you have files "psycho" and "psyllium", then hitting
+ ESC * after a p will expand to "psycho psyllium_" while ESC \
+ will expand only to "psy_" ...
+ -- 
+     
+ Eduardo Krell                   AT&T Bell Laboratories, Murray Hill, NJ
+ 
+ UUCP: {att,decvax,ucbvax}!ulysses!ekrell  Internet: ekrell@ulysses.att.com

> For example, suppose in my home directory is:
> 
> 	$ ls $HOME
> 	psycho
> 	loopy
> 
> Then I can enter:
> 
> 	$ vi $HOME/p<ESC>*
> 
> and the command completes to:
> 
> 	$ vi $HOME/psycho_
> 
> the _ marking the cursor position.

That's what I get for not testing out every post.  What it really expands
to is:
	$ vi /u/lvc/p_

If you give a complete path and enter <ESC> * you'll get:

	$ vi /u/lvc/psycho_

Probably what you want to use is <ESC> \.  Also, if you enter <ESC> =
you'll get a list of filenames that match the pattern.  So in Edward's
example, typing:

	$vi /u/lvc/p<ESC>=

gives you:

	1) psycho
	2) psyllium
	$ vi /u/lvc/p_
-- 
Larry Cipriani, att!cbvox!lvc or lvc@cbvox.att.com
"Offensive is in the eye of the beholder." -- me

crissl@rulcvx.LeidenUniv.nl (Stefan Linnemann) (04/15/91)

From the manual page ksh(1):

--- start of man page selections ---

[ ... ]

     Emacs Editing Mode

[ ... ]

     The notation for escape sequences is M- followed by a char-
     acter.  For example, M-f (pronounced Meta f) is entered by
     depressing ESC (ascii 033) followed by `f'.  (M-F would be
     the notation for ESC followed by `SHIFT' (capital) `F'.)

[ ... ]

     M-*       Attempt file name generation on the current word.
               An asterisk is appended if the word doesn't match
               any file or contain any special pattern charac-
               ters.
     M-ESC     File name completion.  Replaces the current word
               with the longest common prefix of all filenames
               matching the current word with an asterisk
               appended.  If the match is unique, a / is appended
               if the file is a directory and a space is appended
               if the file is not a directory.
     M-=       List files matching current word pattern if an
               asterisk were appended.

[ ... ]

     Vi Editing Mode

[ ... ]

          Text Modification Edit Commands
          These commands will modify the line.

[ ... ]

          *         Causes an * to be appended to the current
                    word and file name generation attempted.  If
                    no match is found, it rings the bell.  Other-
                    wise, the word is replaced by the matching
                    pattern and input mode is entered.
          \         Filename completion.  Replaces the current
                    word with the longest common prefix of all
                    filenames matching the current word with an
                    asterisk appended.  If the match is unique, a
                    / is appended if the file is a directory and
                    a space is appended if the file is not a
                    directory.

[ ... ]

          Other Edit Commands
          Miscellaneous commands.

[ ... ]

          =         List the file names that match the current
                    word if an asterisk were appended it.

--- end of man page selections ---

All the vi inputline editing commands mentioned work only in command
mode, of course.

Another case of RTFM, so I guess you don't have them, poor sod. ;-)

Good luck!
Greetings from below sealevel,
Stefan.

Stefan M. Linnemann, System programmer; Leiden University, the Netherlands.
crissl@rulcvx.LeidenUniv.nl

krk@cs.purdue.EDU (Kevin Kuehl) (04/16/91)

In article <1991Apr15.141632.3138@cbnews.cb.att.com> lvc@cbnews.cb.att.com (lawrence.v.cipriani) writes:
   + Yes, but the equivalent to ESC on the csh is ESC \ in ksh. ie,
   + it will expand only to the common prefix if there is more than
   + 1 match.

Or if you like emacs mode editing, type ESC-ESC for csh ESC file
completion.
-- 
Kevin Kuehl
krk@cs.purdue.edu
kuehlkr@mentor.cc.purude.edu

ed@lvw6.lvw.loral.com (Ed Allen) (04/22/91)

In article <1991Apr15.141632.3138@cbnews.cb.att.com> lvc@cbnews.cb.att.com (lawrence.v.cipriani) writes:

   Probably what you want to use is <ESC> \.  Also, if you enter <ESC> =
   you'll get a list of filenames that match the pattern.  So in Edward's
   example, typing:

	   $vi /u/lvc/p<ESC>=

   gives you:

	   1) psycho
	   2) psyllium
	   $ vi /u/lvc/p_
   -- 
This brings up the question of what the numbers are for.

Can I get ksh to expand to a particular match by somehow using
its number ?

If the numbers cannot be used for anything why are they there ?
--
Never trust a man who wears white shoes.           | Ed Allen
Vote Libertarian...     Scare the Hell out of 'em. | Loral Command & Contr. Sys.