Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Move command line options to start of line



Not sure if anybody actually needs such a thing, but the Austin group
(essentially POSIX) has been worrying about it, so I thought I'd while
away Friday afternoon by writing a zle widget (looks like Chris Johnson
had a similar idea...) Unfortunately zsh is so powerful it was trivial.

See the description at the top.

#top
# This moves an option, possibly with arguments, from before the
# cursor to immediately after the command word.
# Examples (cursor assumed to be at the end of the line):
#    ls file1 file2 -l
# -> ls -l files 1files
#
#    p4 opened -u pws
# -> p4 -u pws opened
#
# In the unlikely event that the argument of an option begins with -,
# repeated application will have the correct effect.

local -a line
integer i

line=(${(z)LBUFFER})
i=${line[(I)-*]}

(( i < 3 )) && return 1

LBUFFER="$line[1] $line[i,-1] $line[2,i-1]"
#bottom

-- 
Peter Stephenson <pws@xxxxxxx>                  Software Engineer
CSR PLC, Churchill House, Cambridge Business Park, Cowley Road
Cambridge, CB4 0WZ, UK                          Tel: +44 (0)1223 692070


To access the latest news from CSR copy this link into a web browser:  http://www.csr.com/email_sig.php



Messages sorted by: Reverse Date, Date, Thread, Author