Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Redirection Symbol After Completion
- X-seq: zsh-users 10497
- From: Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>
- To: zsh-users@xxxxxxxxxx
- Subject: Re: Redirection Symbol After Completion
- Date: Sat, 08 Jul 2006 10:56:11 -0700
- In-reply-to: <200607081145.k68BiwEY023823@xxxxxxxxxxxxxxxxx>
- Mailing-list: contact zsh-users-help@xxxxxxxxxx; run by ezmlm
- References: <200607081145.k68BiwEY023823@xxxxxxxxxxxxxxxxx>
On Jul 8, 12:44pm, Peter Stephenson wrote:
} Subject: Re: Redirection Symbol After Completion
}
} Chris Johnson wrote:
} > I personally find commands easier to parse with my eye when the space
} > remains before the redirection symbol:
} >
} > cat file.txt |
} >
} > Is there any way to force this space to persist even if I type a
} > redirection operator?
}
} It's a perfectly reasonable thing to want to configure, but
} unfortunately I don't think it's possible to do this without some
} tweaking of the completion system.
Skipping ahead a bit ...
} echo testdir/
}
} and now type "|". The slash isn't removed, as it usually would be.
} That's because the same mechanism controls the characters removed when
} you have a suffix, including an automatically added /, and when you
} don't, i.e. you get the space in your original question.
Presumably he wants the slash replaced by a space in that instance. I
think you're going about this the wrong way -- rather than revamping
how autoremoval occurs in the general case, adjust the way redirection
ops are inserted.
self-insert-redir() {
integer l=$#LBUFFER
zle self-insert
(( $l >= $#LBUFFER )) && LBUFFER[-1]=" $LBUFFER[-1]"
}
zle -N self-insert-redir
for op in \| \< \> \&
do bindkey "$op" self-insert-redir
done
I like that so much I might even keep it.
It'd be nice if it were possible to test whether a suffix removal is
pending rather than checking the length of LBUFFER before and after
the self-insert, but I think this suffices (no pun intended).
One could go so far as to actually replace self-insert and also check
with a style for what constitutes a redirection operator, but that
gets a bit uglier. I believe there was a discussion several months
ago about the problems caused by not being able to instruct zsh when
to use the ZLE_KEEPSUFFIX internal flag on a user-defined widget.
(Hmm, maybe that problem doesn't apply here anyway.)
--
Messages sorted by:
Reverse Date,
Date,
Thread,
Author