Customize Bash Prompt

Change Hostname, Server Name, and Current Directory via .bashrc

adom@dirty-pipe:~ change hostname and server name and current working directory using ./.bashrc

To customize your prompt, you can open the `.bashrc` file in your home directory using a text editor like `nano` or `vim`. Here's a simple example:

nano ~/.bashrc

Look for a line that starts with PS1=. If it's not there, you can add it. Here's an example of a custom prompt that includes username, hostname, and current working directory:

PS1='\[\033[01;32m\]adom@\h:\[\033[01;34m\]\w\[\033[00m\]\$ '
PS1='\[\033[01;31m\]root@\h:\[\033[01;34m\]\w\[\033[00m\]\$ '  --> red colour 

Save the file, and then apply the changes:

source ~/.bashrc

Your prompt should now display as "adom@dirty-pipe:~" in your terminal. Feel free to adjust the colors or any other aspects of the prompt to suit your preferences.

Last updated