David Korn wrote:
> cc: ksh93-integration-discuss at opensolaris.org
> Subject: Re: [ksh93-integration-discuss] migrating from tcsh to ksh93
> --------
>
>   
>> However, there are a couple of behaviors of tcsh that I don't know how 
>> to make ksh93 reproduce.
>>
>> 1) bindkey ' ' magic-space
>>
>>     What this does on tcsh is let me enter a command, say !! (as a 
>> history command), and when I press the space bar, it expands the !! (or 
>> whatever other history reference I have) so that I can then edit the 
>> command.  (This is useful when I want the last argument, but need to 
>> make a change, or somesuch.)  I rely on this a lot in tcsh, and it saves 
>> me a lot of time.
>>
>>
>>     
>
> What key does tcsh use for this?  Where does the cursor get positioned?
>   

space bar (why it is called "magic space") immediately after a 
non-whitespace expands everything on the command line before it.  The 
cursor remains at its current position -- normally the end of the line 
just after the space.  (It still inserts the space, of course.)

> When compiled with the BASH option, ksh93 has the histverify option
> which sends any command that has a csh history expansion back to
> the editor for editing.  Would this be the equivalent?
>   

Maybe, I can't see how to use it with ksh93 on Solaris right now.

I've just discovered the "hist" command -- yeah, I'm an old-time tcsh 
user (originally csh, but that was several decades ago!) so some of this 
is new to me.

I still wish I had magic space though.

As an example:

% ls /some/really/longfile/name
[ I might have got that long name using tab-completion
% mv !$
[      ^cursor is here, and press space bar
[ command prompt changes ....
% mv /some/really/longfile/name
[ cursor is here ---------------^
[ enter more command text... ]
% mv /some/really/longfile/name !$
[ cursor is here -----------------^
[ press space bar, and you get ...
% mv /some/really/longfile/name /some/really/longfile/name
[ cursor is now here --------------------------------------^
[ press ESC-b twice in a row.... ]
% mv /some/really/longfile/name /some/really/longfile/name
[ cursor is now here ------------------------^
[ press ESC-d to delete "longfile"
% mv /some/really/longfile/name /some/really//name
[ cursor is now here ------------------------^
[ now change the directory name to "new"
% mv /some/really/longfile/name /some/really/new/name
[ cursor is now here ---------------------------^


While the example is fabricated, I only had to type the hideous long 
file name once (and with tab completion, maybe not even once), and I was 
able to quickly change one component of the path name while preserving 
the rest of the file name.  And, I was able to see the results while I 
did the edit (WYSIWYG), so I was unlikely to make a stupid mistake (or 
at least less likely) using some regex tweaking of the component.

It looks like something small, but I use this more often than you might 
guess.  It is a really powerful feature.  Especially when you deal with 
files that have really awkward or long names (such as tarball images 
where the date is encoded in the file name.)

Thanks.

    -- Garrett
> David Korn
> dgk at research.att.com
>   


Reply via email to