1
- texinode(Prompt Expansion)(Restricted Shell)(Compatibility )(Top)
1
+ texinode(Prompt Expansion)(Expansion)(Conditional Expressions )(Top)
2
2
chapter(Prompt Expansion)
3
3
ifzman(\
4
4
sect(Prompt Expansion)
@@ -42,21 +42,14 @@ A `tt(RPAR())'.
42
42
)
43
43
xitem(tt(%d))
44
44
item(tt(%/))(
45
- Present working directory (tt($PWD)).
45
+ Present working directory (tt($PWD)). If an integer follows the `tt(%)',
46
+ it specifies a number of trailing components of tt($PWD) to show; zero
47
+ means the whole path.
46
48
)
47
49
item(tt(%~))(
48
- tt($PWD).
49
- If it has a named directory as its prefix, that part is replaced
50
- by a `tt(~)' followed by the name of the directory.
51
- If it starts with tt($HOME), that part is
52
- replaced by a `tt(~)'.
53
- )
54
- xitem(tt(%c))
55
- xitem(tt(%.))
56
- item(tt(%C))(
57
- Trailing component of tt($PWD).
58
- An integer may follow the `tt(%)' to get more than one component.
59
- Unless `tt(%C)' is used, tilde contraction is performed first.
50
+ As tt(%d) and tt(%/), but if tt($PWD) has a named directory as its prefix,
51
+ that part is replaced by a `tt(~)' followed by the name of the directory.
52
+ If it starts with tt($HOME), that part is replaced by a `tt(~)'.
60
53
)
61
54
xitem(tt(%h))
62
55
item(tt(%!))(
@@ -95,6 +88,18 @@ Current time of day in 24-hour format, with seconds.
95
88
item(tt(%n))(
96
89
tt($USERNAME).
97
90
)
91
+ item(tt(%N))(
92
+ The name of the script, sourced file, or shell function that zsh is
93
+ currently executing, whichever was started most recently. If there is
94
+ none, this is equivalent to the parameter tt($0). An integer may follow
95
+ the `tt(%)' to specify a number of trailing path components to show; zero
96
+ means the full path.
97
+ )
98
+ item(tt(%i))(
99
+ The line number currently being executed in the script, sourced file, or
100
+ shell function given by tt(%N). This is most useful for debugging as part
101
+ of tt($PS4).
102
+ )
98
103
item(tt(%w))(
99
104
The date in var(day)tt(-)var(dd) format.
100
105
)
@@ -122,7 +127,9 @@ item(tt(%_))(
122
127
The status of the parser, i.e. the shell constructs (like `tt(if)' and
123
128
`tt(for)') that have been started on the command line. If given an integer
124
129
number that many strings will be printed; zero or no integer means
125
- print as many as there are.
130
+ print as many as there are. This is most useful in prompts tt(PS2) for
131
+ continuation lines and tt(PS4) for debugging with the tt(XTRACE) option; in
132
+ the latter case it will also work non-interactively.
126
133
)
127
134
item(tt(%E))(
128
135
Clears to end of line.
@@ -175,6 +182,8 @@ sitem(tt(w))(True if the day of the week is equal to var(n) (Sunday = 0).)
175
182
sitem(tt(?))(True if the exit status of the last command was var(n).)
176
183
sitem(tt(#))(True if the effective uid of the current process is var(n).)
177
184
sitem(tt(g))(True if the effective gid of the current process is var(n).)
185
+ sitem(tt(l))(True if at least var(n) characters have already been
186
+ printed on the current line.)
178
187
sitem(tt(L))(True if the tt(SHLVL) parameter is at least var(n).)
179
188
sitem(tt(S))(True if the tt(SECONDS) parameter is at least var(n).)
180
189
sitem(tt(v))(True if the array tt(psvar) has at least var(n) elements.)
@@ -185,25 +194,50 @@ endsitem()
185
194
xitem(tt(%<)var(string)tt(<))
186
195
xitem(tt(%>)var(string)tt(>))
187
196
item(tt(%[)var(xstring)tt(]))(
188
- Specifies truncation behaviour.
197
+ Specifies truncation behaviour for the remainder of the prompt string .
189
198
The third, deprecated, form is equivalent to `tt(%)var(xstringx)',
190
199
i.e. var(x) may be `tt(<)' or `tt(>)'.
191
200
The numeric argument, which in the third form may appear immediately
192
201
after the `tt([)', specifies the maximum permitted length of
193
- the various strings that can be displayed in the prompt. If this
194
- integer is zero, or missing, truncation is disabled. Truncation is
195
- initially disabled.
202
+ the various strings that can be displayed in the prompt.
196
203
The var(string) will be displayed in
197
- place of the truncated portion of any string.
204
+ place of the truncated portion of any string; note this does not
205
+ undergo prompt expansion.
198
206
199
207
The forms with `tt(<)' truncate at the left of the string,
200
208
and the forms with `tt(>)' truncate at the right of the string.
201
209
For example, if the current directory is `tt(/home/pike)',
202
210
the prompt `tt(%8<..<%/)' will expand to `tt(..e/pike)'.
203
211
In this string, the terminating character (`tt(<)', `tt(>)' or `tt(])'),
204
- or in fact any character, may be quoted by a preceding `tt(\)'.
205
- % escapes are em(not) recognised.
212
+ or in fact any character, may be quoted by a preceding `tt(\)'; note
213
+ when using tt(print -P), however, that this must be doubled as the
214
+ string is also subject to standard tt(print) processing, in addition
215
+ to any backslashes removed by a double quoted string: the worst case
216
+ is therefore `tt(print -P "%<\\\\<<...")'.
217
+
206
218
If the var(string) is longer than the specified truncation length,
207
219
it will appear in full, completely replacing the truncated string.
220
+
221
+ The part of the prompt string to be truncated runs to the end of the
222
+ string, or to the end of the next enclosing group of the `tt(%LPAR())'
223
+ construct, or to the next truncation encountered at the same grouping
224
+ level (i.e. truncations inside a `tt(%LPAR())' are separate), which
225
+ ever comes first. In particular, a truncation with argument zero
226
+ (e.g. `tt(%<<)') marks the end of the range of the string to be
227
+ truncated while turning off truncation from there on. For example, the
228
+ prompt '%10<...<%~%<<%# ' will print a truncated representation of the
229
+ current directory, followed by a `tt(%)' or `tt(#)', followed by a
230
+ space. Without the `tt(%<<)', those two characters would be included
231
+ in the string to be truncated.
232
+ )
233
+ xitem(tt(%c))
234
+ xitem(tt(%.))
235
+ item(tt(%C))(
236
+ Trailing component of tt($PWD).
237
+ An integer may follow the `tt(%)' to get more than one component.
238
+ Unless `tt(%C)' is used, tilde contraction is performed first. These are
239
+ deprecated as tt(%c) and tt(%C) are equivalent to tt(%1~) and tt(%1/),
240
+ respectively, while explicit positive integers have the same effect as for
241
+ the latter two sequences.
208
242
)
209
243
enditem()
0 commit comments