|
myshell 2.0.0
|
Prompt related utilities. More...
Functions | |
| std::string | expand_ps1 (const std::string &ps1) |
| Expand a PS1 (Prompt String 1) format string into its corresponding values. | |
| std::string | generate_prompt () |
| Generate a prompt string. | |
Prompt related utilities.
| std::string expand_ps1 | ( | const std::string & | ps1 | ) |
Expand a PS1 (Prompt String 1) format string into its corresponding values.
This function takes a PS1 format string as input and processes escape sequences to replace them with specific values. The supported escape sequences include:
\d - The current date in YYYY-MM-DD format.
\t - The current time in HH:MM:SS format.
\u - The current user.
\h - The current host.
\w - The current working directory.
\W - The current working directory's basename.
\n - A newline character.
\r - A carriage return character.
\s - The current shell.
\v - The current shell version.
\$ - The prompt character.
| ps1 | The PS1 format string to be expanded. |
| std::string generate_prompt | ( | ) |
Generate a prompt string.
This function generates a prompt string by expanding the PS1 environment variable. If the PS1 environment variable is not set, the default prompt defined in msh_prompt.h is used.