.\" Automatically generated by Pod::Man 4.14 (Pod::Simple 3.42) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is >0, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{\ . if \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "Env::PS1 3pm" .TH Env::PS1 3pm "2022-10-13" "perl v5.34.0" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" Env::PS1 \- prompt string formatter .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 5 \& # use the import function \& use Env::PS1 qw/$PS1/; \& $ENV{PS1} = \*(Aq\eu@\eh \e$ \*(Aq; \& print $PS1; \& $readline = ; \& \& # or tie it yourself \& tie $prompt, \*(AqEnv::PS1\*(Aq, \*(AqPS1\*(Aq; \& \& # you can also tie a scalar ref \& $format = \*(Aq\eu@\eh\e$ \*(Aq; \& tie $prompt, \*(AqEnv::PS1\*(Aq, \e$format; .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" This package supplies variables that are \*(L"tied\*(R" to environment variables like \&'\s-1PS1\s0' and '\s-1PS2\s0', if read it takes the contents of the variable as a format string like the ones \fB\fBbash\fB\|(1)\fR uses to format the prompt. .PP It is intended to be used in combination with the various ReadLine packages. .SH "EXPORT" .IX Header "EXPORT" You can request for arbitrary variables to be exported, they will be tied to the environment variables of the same name. .SH "TIE" .IX Header "TIE" When you \f(CW\*(C`tie\*(C'\fR a variable you can supply one argument which can either be the name of an environment variable or a \s-1SCALAR\s0 reference. This argument defaults to '\s-1PS1\s0'. .SH "METHODS" .IX Header "METHODS" .ie n .IP """sprintf($format)""" 4 .el .IP "\f(CWsprintf($format)\fR" 4 .IX Item "sprintf($format)" Returns the formatted string. .Sp Using this method all the time is a lot \fBless\fR efficient then using the tied variable, because the tied variable caches parts of the format that remain the same anyway. .SH "FORMAT" .IX Header "FORMAT" The format is copied mostly from \fBbash\fR\|(1) because that's what it is supposed to be compatible with. We made some private extensions which obviously are not portable. .PP Note that this is not the prompt format as specified by the posix specification, that would only know \*(L"!\*(R" for the history number and \*(L"!!\*(R" for a literal \*(L"!\*(R". .PP Apart from the escape sequences you can also use environment variables in the format string; use \f(CW$VAR\fR or \f(CW\*(C`${VAR}\*(C'\fR. .PP The following escape sequences are recognized: .IP "\ea" 4 .IX Item "a" The bell character, identical to \*(L"\e007\*(R" .IP "\ed" 4 .IX Item "d" The date in \*(L"Weekday Month Date\*(R" format .IP "\eD{format}" 4 .IX Item "D{format}" The date in \fBstrftime\fR\|(3) format, uses \s-1POSIX\s0 .IP "\ee" 4 .IX Item "e" The escape character, identical to \*(L"\e033\*(R" .IP "\en" 4 .IX Item "n" Newline .IP "\er" 4 .IX Item "r" Carriage return .IP "\es" 4 .IX Item "s" The basename of \f(CW$0\fR .IP "\et" 4 .IX Item "t" The current time in 24\-hour format, identical to \*(L"\eD{%H:%M:%S}\*(R" .IP "\eT" 4 .IX Item "T" The current time in 12\-hour format, identical to \*(L"\eD{%I:%M:%S}\*(R" .IP "\e@" 4 .IX Item "@" The current time in 12\-hour am/pm format, identical to \*(L"\eD{%I:%M \f(CW%p\fR}\*(R" .IP "\eA" 4 .IX Item "A" The current time in short 24\-hour format, identical to \*(L"\eD{%H:%M}\*(R" .IP "\eu" 4 .IX Item "u" The username of the current user .IP "\ew" 4 .IX Item "w" The current working directory .IP "\eW" 4 .IX Item "W" The basename of the current working directory .IP "\e$" 4 .IX Item "$" \&\*(L"#\*(R" for effective uid is 0 (root), else \*(L"$\*(R" .IP "\e0dd" 4 .IX Item "0dd" The character corresponding to the octal number 0dd .IP "\e\e" 4 .IX Item "" Literal backslash .IP "\eH" 4 .IX Item "H" Hostname, uses Sys::Hostname .IP "\eh" 4 .IX Item "h" First part of the hostname .IP "\el" 4 .IX Item "l" The basename of the (output) terminal device name, uses \s-1POSIX,\s0 but won't be really portable. .IP "\e[ \e]" 4 .IX Item "[ ]" These are used to encapsulate a sequence of non-printing chars. Since we don't need that, they are removed. .SS "Extensions" .IX Subsection "Extensions" The following escapes are extensions not supported by bash, and are not portable: .IP "\eL" 4 .IX Item "L" The (output) terminal device name, uses \s-1POSIX,\s0 but won't be really portable. .IP "\eC{colour}" 4 .IX Item "C{colour}" Insert the \s-1ANSI\s0 sequence for named colour. Known colours are: black, red, green, yellow, blue, magenta, cyan and white; background colours prefixed with \*(L"on_\*(R". Also known are reset, bold, dark, underline, blink and reverse, although the effect depends on the terminla you use. .Sp Unless you want the whole commandline coloured you should end your prompt with \*(L"\eC{reset}\*(R". .Sp Of course you can still use the \*(L"raw\*(R" ansi escape codes for these colours. .Sp Note that \*(L"bold\*(R" is sometimes also known as \*(L"bright\*(R", so \*(L"\eC{bold,black}\*(R" will on some terminals render dark grey. .Sp If the environment variable \f(CW\*(C`CLICOLOR\*(C'\fR is defined but false colours are switched off automatically. .IP "\eP{format}" 4 .IX Item "P{format}" Proc information. .Sp \&\fIAll of these are unix specific\fR .RS 4 .ie n .IP "%a" 4 .el .IP "\f(CW%a\fR" 4 .IX Item "%a" Acpi \s-1AC\s0 status '+' or '\-' for connected or not, linux specific .ie n .IP "%b" 4 .el .IP "\f(CW%b\fR" 4 .IX Item "%b" Acpi battery status in mWh, linux specific .ie n .IP "%L" 4 .el .IP "\f(CW%L\fR" 4 .IX Item "%L" Load average .ie n .IP "%l" 4 .el .IP "\f(CW%l\fR" 4 .IX Item "%l" First number of the load average .ie n .IP "%t" 4 .el .IP "\f(CW%t\fR" 4 .IX Item "%t" Acpi temperature, linux specific .ie n .IP "%u" 4 .el .IP "\f(CW%u\fR" 4 .IX Item "%u" Uptime .ie n .IP "%w" 4 .el .IP "\f(CW%w\fR" 4 .IX Item "%w" Number of users logged in .RE .RS 4 .RE .SS "Not implemented escapes" .IX Subsection "Not implemented escapes" The following escapes are not implemented, because they are application specific. .IP "\ej" 4 .IX Item "j" The number of jobs currently managed by the application. .IP "\ev" 4 .IX Item "v" The version of the application. .IP "\eV" 4 .IX Item "V" The release number of the application, version + patchelvel .IP "\e!" 4 .IX Item "!" The history number of the next command. .Sp This escape gets replaced by literal '!' while a literal '!' gets replaces by '!!'; this makes the string a posix compatible prompt, thus it will work if your readline module expects a posix prompt. .IP "\e#" 4 .IX Item "#" The command number of the next command (like history number, but minus the lines read from the history file). .SS "Customizing" .IX Subsection "Customizing" If you want to overload escapes or want to supply values for the application specific escapes you can put them in \f(CW%Env::PS1::map\fR, the key is the escape letter, the value either a string or a \s-1CODE\s0 ref. If you map a \s-1CODE\s0 ref it normally is called every time the prompt string is read. When the escape is followed by an argument in the format string (like \f(CW\*(C`\eD{argument}\*(C'\fR) the \s-1CODE\s0 ref is called only once when the string is cached, but in that case it may in turn return a \s-1CODE\s0 ref. .SH "BUGS" .IX Header "BUGS" Please mail the author if you encounter any bugs. .SH "AUTHOR" .IX Header "AUTHOR" Jaap Karssenberg || Pardus [Larus] .PP This module is currently maintained by Ryan Niebur .PP Copyright (c) 2004 Jaap G Karssenberg. All rights reserved. Copyright (c) 2009 Ryan Niebur. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. .SH "SEE ALSO" .IX Header "SEE ALSO" Env, Term::ReadLine::Zoid