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

Command Utility Belt



I'm finding that I have a lot of semi-often used commands that aren't
exactly appropriate for aliasing -- they need minor editing each time I
call on them.  Furthermore, they're cryptic enough that it would be nice
to able to recall these commands easily (for editing).  I wonder if
anyone knows a good solution.

Two ideas I've had work okay.  The first is to assign the command to an
alias that does 'print -z' on the command.  For example:

   alias my_command='print -z prog arg1 arg2 arg3 ...'

The drawback to this is that it introduces a superfluous accept-line.

The second is to assign the plain old command to an alias and bind a key
to _expand_alias.  This will of course expand the alias and keep the
line active for editing.  The drawback to this one is that I have to
have the cursor on the alias itself to expand it.  I've fashioned a
widget to allow arbitrary alias expansion:

   expand-alias() {
      zle beginning-of-line
      zle vi-forward-char
      zle _expand_alias
   }
   zle -N expand-alias

A third solution, which I might prefer but haven't yet attempted, is to
prime the history with these commands.  I think 'print -s' would do
this.

Has anyone else implemented such a "command utility belt" and have
recommendations?  Thanks!

-- 
Chris Johnson
cjohnson@xxxxxxxxxx
http://www.cs.utk.edu/~cjohnson



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