Prompt magic分析和总结分析和总结.docxVIP

  • 0
  • 0
  • 约1.15万字
  • 约 8页
  • 2023-04-24 发布于上海
  • 举报
Disclaimer : Disclaimer : The original version of this article was first published on IBM developerWorks, and is property of Westtech Information Services. This document is an updated version of the original article, and contains various improvements made by the Gentoo Linux Documentation team. This document is not actively maintained. Prompt magic 1. Enhancing the system prompt As Linux/UNIX people, we spend a lot of time working in the shell, and in many cases, this is what we have staring back at us: Code Listing 1.1: The normal user prompt bash-2.04$ Code Listing 1.1: The normal user prompt bash-2.04$ If you happen to be root, youre entitled to the prestige version of this beautiful prompt: Code Listing 1.2: The root prompt bash-2.04# Code Listing 1.2: The root prompt bash-2.04# These prompts are not exactly pretty. Its no wonder that several Linux distributions have upgraded their default prompts that add color and additional information to boot. However, even if you happen to have a modern distribution that comes with a nice, colorful prompt, it may not be perfect. Maybe youd like to add or change some colors, or add (or remove) information from the prompt itself. It isnt hard to design your own colorized, tricked-out prompt from scratch. Prompt basics Under bash, you can set your prompt by changing the value of the PS1 environment variable, as follows: Code Listing 1.3: Altering the environment variable Code Listing 1.3: Altering the environment variable $ export PS1= Changes take effect immediately, and can be made permanent by placing the export definition in your ~/.bashrc file. PS1 can contain any amount of plain text that youd like: Code Listing 1.4: A custom prompt Code Listing 1.4: A custom prompt $ export PS1=This is my super prompt This is my super prompt While this is, um,interesting, its not exactly useful to have a prompt that contains lots of static text. Most custom prompts contain information like the current username, working directory,

您可能关注的文档

文档评论(0)

1亿VIP精品文档

相关文档