Linux Today: Linux News On Internet Time.

More on LinuxToday Shell Prompt Customization

Nov 28, 2000, 23:30 (5 Talkback[s])
(Other stories by Jose)

WEBINAR: On-demand webcast

How to Boost Database Development Productivity on Linux, Docker, and Kubernetes with Microsoft SQL Server 2017 REGISTER >

[ Thanks to Jonny5 for this link. ]

"First, you might be thinking, "why customize my prompt?" Well, there are many reasons. ... You can display information such as the machine you are working on, the current directory, how many users there are in the system, date, time, etc. You can also add ANSI color to the display making it easier to read for some people. In this article I'm going to show you how to customize the prompt for a BASH shell. I picked BASH since it's the shell that most users use and is the shell that every distribution picks as its default shell."

"The BASH uses different variables for its prompt. The main variable, and the one we are going to focus the most on is PS1. BASH has 4 different prompts PS1-4. PS1 is the normal prompt that you see each time you run the shell. PS2 is the extension of PS1 since it is displayed each time you continue a command form the original prompt. PS3 is used when you execute the select command, and PS4 is displayed when you trace and execution."

"What I mean about globally or locally is that you might just want to edit the prompt for your regular user but leave all the rest of the users with the normal prompt. Now this usually deals with the file called "profile". A copy of the file is usually kept in /etc which is the global file that means if a user doesn't have a copy of the file in their home directory that file will be used each time you execute the shell. Now you can copy that file to your home directory and saving it as .profile (cp /etc/profile ~/.profile) that will give you all the options than before but it also gives you the chance to edit it to your likings and it will only affect your user."

Complete Story

Related Stories: