Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!


Click here to return to the 'Or use a shell prompt' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Or use a shell prompt
Authored by: gidds on Sep 02, '11 12:13:49PM

Another way to distinguish shells/machines is by the prompt. My prompts are in reverse video, and so a different colour stands out.

(It's not that hard: add something like "\[`tput setaf N; tput rev`\]" to the start of your PS1 prompt, where N is 0 for black, 1 for red, etc; and "\[`tput sgr0`\]" at the end to reset. tput generates the right escape codes, and \[...\] ensures the shell doesn't get the cursor position confused. That's in bash; other shells may do it differently.)

Advantages are that it works whichever OS and terminal program you log in from; and it adapts as you log in and out of different machines, so as you scroll back it's clear which machines you were on.

---
Andy/



[ Reply to This | # ]