|
Home > Archive > Unix Shell > April 2004 > zsh prompt
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
|
|
| JoeSmith 2004-04-14, 2:39 pm |
|
I see that one can put a newline in the prompt and set an option to diabled the
carriage return. Is there a way for zsh be smart enough to do a newline if
the cursor is not positioned in the left most column and it can still continue
to do the carriage return?
| |
| Stephane CHAZELAS 2004-04-18, 10:42 am |
| 2004-04-14, 15:23(+00), JoeSmith:
> I see that one can put a newline in the prompt and set an option to diabled the
> carriage return. Is there a way for zsh be smart enough to do a newline if
> the cursor is not positioned in the left most column and it can still continue
> to do the carriage return?
What about $^fpath/promptnl(N)
--
Stéphane ["Stephane.Chazelas" at "free.fr"]
| |
| JoeSmith 2004-04-23, 12:34 pm |
| Stephane CHAZELAS wrote:
> 2004-04-14, 15:23(+00), JoeSmith:
>
>
>
>
> What about $^fpath/promptnl(N)
Thanks for the info. I guess a must be a bit too new to zsh. I am not
familiar with that syntax. It seems very foreign to me. I tried setting my
prmopt to that, but my prompt ending up looking like that string exactly.
Where can I read to learn about that type of syntax?
| |
| Stephane CHAZELAS 2004-04-24, 8:33 am |
| 2004-04-23, 16:35(+00), JoeSmith:
[...]
>
> Thanks for the info. I guess a must be a bit too new to zsh. I am not
> familiar with that syntax. It seems very foreign to me. I tried setting my
> prmopt to that, but my prompt ending up looking like that string exactly.
> Where can I read to learn about that type of syntax?
Sorry, I should have written:
more $^fpath/promptnl(N)
fpath is an array that contains the paths to the shell
functions. Something like:
/usr/share/zsh/site-functions /usr/share/zsh/4.2.0/functions
$^fpath is to sort of do as with brace expansion (think of '^'
rc operator), so that it sorts of expands to
{/usr/share/zsh/site-functions,/usr/share/zsh/4.2.0/functions}/promptnl(N)
which expands to
/usr/share/zsh/site-functions/promptnl(N) /usr/share/zsh/4.2.0/functions/promptnl(N)
(N) is a globbing qualifier. So, it forces globbing (filename
expansion), and that globbing qualifier turns on the "nullglob"
option for that filename expansion, so that when the pattern
doesn't match, it expands to nothing (instead of generating an
error).
So, in short, $^fpath/promptnl(N) expands to all the "promptnl"
files in $fpath, so likely something like:
/usr/share/zsh/4.2.0/functions/promptnl
And, if you read the first lines of that file, you get exactly
what you want:
# Add `autoload promptnl' to your .zshrc, and include a call to promptnl
# near the end of your precmd function.
#
# When promptnl runs, it asks the terminal to send back the current
# position of the cursor. If the cursor is in column 1, it does nothing;
# otherwise it prints a newline. Thus you get a newline exactly when one
# is needed.
--
Stéphane ["Stephane.Chazelas" at "free.fr"]
|
|
|
|
|