![]() ![]() This helps Bash ignore non-printable characters so that it correctly calculates the size of the prompt. Note: Wrapping the tput output in \ is recommended by the Bash man page. Prints the escape sequence to set the foreground color to green. To get the escape code for a capability, you can use the tput command. For example, setaf sets the foreground color of whatever text is printed after it. The capability names (the part before the =) can be looked up in terminfo(5) for a description of what they do. To see what capabilities your terminal supports, run These escape sequences can be somewhat illegible and can vary from terminal to terminal, so they are documented in the terminfo database. For example they might change the color of subsequent printed characters, move the cursor to an arbitrary location, or clear the screen. See the man page bash(1) § PROMPTING or the Bash reference manual for a complete list of escape sequences.Īside from the escape characters recognized by Bash, most terminals recognize special escape sequences that affect the terminal itself rather than printing characters. So a PS1 of '\A \u $ ' would be printed like 17:35 username $. For example, \u is expanded into the current username and \A is expanded to the current time. When printing the prompt string, Bash looks for certain backslash-escaped characters and will expand them into special strings. ![]() While one can simply set their prompt to a plain string, there are a variety of techniques for making the prompt more dynamic and useful. ![]() The first character is repeated to indicate deeper levels.Īll of the prompts are customized by setting the corresponding variable to the desired string (usually in ~/.bashrc), for example It is displayed when debugging bash scripts to indicate levels of indirection. Usually you would customize it in the script where the select is used rather than in your. Unlike the other prompts, it does not expand Bash escape sequences. It is the prompt displayed for Bash's select built-in which displays interactive menus.
0 Comments
Leave a Reply. |