The OpenNET Project / Index page

[ новости /+++ | форум | теги | ]

Поиск:  Каталог документации

Chapter 11. Prompt Code Snippets

Table of Contents
11.1. Built-in Escape Sequences
11.2. Date and Time
11.3. Counting Files in the Current Directory
11.4. Total Bytes in the Current Directory
11.5. Checking the Current TTY
11.6. Stopped Jobs Count
11.7. Load
11.8. Uptime
11.9. Number of Processes
11.10. Controlling the Size and Appearance of $PWD
11.11. Laptop Power
11.12. Having the Prompt Ignored on Cut and Paste
11.13. New Mail

This section shows how to put various pieces of information into the Bash prompt. There are an infinite number of things that could be put in your prompt. Feel free to send me examples, I'll try to include what I think will be most widely used. If you have an alternate way to retrieve a piece of information here, and feel your method is more efficient, please contact me. It's easy to write bad code, I do it often, but it's great to write elegant code, and a pleasure to read it. I manage it every once in a while, and would love to have more of it to put in here.

To incorporate shell code in prompts, it has to be escaped. Usually, this will mean putting it inside \$(<command>) so that the output of command is substituted each time the prompt is generated.

Please keep in mind that I develop and test this code on a single user 900 MHz Athlon with 256 meg of RAM, so the delay generated by these code snippets doesn't usually mean much to me. To help with this, I recently assembled a 25 MHz 486 SX with 16 meg of RAM, and you will see the output of the "time" command for each snippet to indicate how much of a delay it causes on a slower machine.




Партнёры:
PostgresPro
Inferno Solutions
Hosting by Hoster.ru
Хостинг:

Закладки на сайте
Проследить за страницей
Created 1996-2024 by Maxim Chirkov
Добавить, Поддержать, Вебмастеру