![]() You're not limited to setting the color of your text. For a green prompt, use the ANSI code for green before your prompt character and end it with the code representing your normal default color: export PS1=`printf "\033[32m$ \033[39m"` Foreground and background For example, if you regularly SSH into your server, you can set your server prompt to green to help you differentiate it at a glance from your local prompt. For example, typing this code changes the subsequent text to green: $ printf '\033[32m'Īs long as you see color the same way your computer does, you could use color to help you remember what system you're logged into. It doesn't clear your history it just clears up the screen in your terminal emulator, so it's a safe and demonstrative ANSI escape sequence.ĪNSI also has sequences to set the color of your terminal. For instance, this sequence clears the screen up to the next prompt: $ printf `\033[2J` These are special sequences of characters that a terminal interprets as actions instead of characters. Modern terminals have inherited ANSI escape sequences for "meta" features. Save the file, and reload your settings: $ source ~/.bashrc ANSI color codes You can do this by exporting the TERM variable in your ~/.bashrc configuration file: export TERM=xterm-256color If your terminal is set to a profile with very few features, but you know the emulator you use is capable of more, then you can change your setting by defining the TERM environment variable. Most software doesn't care what terminal type you're using in rare instances, you might get a warning or error about an incorrect terminal type when logging into a server that checks for compatible features. These files list features available in different kinds of terminals, many of which are defined by historical hardware: there are definitions for vt100 through vt220, as well as for modern software emulators like xterm and Xfce. The modern version of that is terminfo, located in either /etc or /usr/share, depending on your distribution. The obsolete (but still maintained on some systems in the interest of backward compatibility) /etc/termcap file defined the capabilities of terminals and printers. Free online course: RHEL Technical Overview.You can check your TERM definition with echo: $ echo $TERM The same principle applies today, and it's set by the TERM environment variable. However, developments in technology happened fast even then, and it quickly became apparent that as new video display terminals were designed, they needed new capabilities to be available on an optional basis.įor instance, the fancy new VT100 released in 1978 supported ANSI color, so if a user identified the terminal type as vt100, then a computer could deliver color output, while a basic serial device might not have such an option. CRT monitors were expensive-both to manufacture and to control it was easier to have a computer spit out crude ASCII text than to worry about anti-aliasing and other niceties that modern computerists take for granted. Terminals had CRT monitors built-in, so users could sit at a terminal in their office to interact directly with the mainframe. They were unique from the teletype machines (which is why we still have /dev/tty devices in Linux today) that were often used to issue commands remotely. Historically, Unix terminals were literally that: physical points at the literal endpoint (termination) of a shared computer system where users could type in commands. Modern systems usually default to at least xterm-256color, but if you try to add color to your terminal without success, you should check your TERM setting. This article demonstrates how you can make Linux as colorful (or as monochromatic) as you want. ![]() Either way, the nostalgic green or amber text on a black screen is wholly optional. You can add color to your Linux terminal using special ANSI encoding settings, either dynamically in a terminal command or in configuration files, or you can use ready-made themes in your terminal emulator.
0 Comments
Leave a Reply. |