You can customize the terminal prompt by modifying the shell configuration file. The method varies depending on the shell you are using. Here are examples for two common shells: Bash and Zsh.
For Bash
-
Open the
.bashrcfile in your home directory:nano ~/.bashrc -
Look for the line that starts with
PS1=. This variable defines the primary prompt string. -
Modify the
PS1variable to customize your prompt. For example:PS1='\u@\h:\w\$ '\u- username\h- hostname\w- current working directory\$- shows#for root and$for regular users
-
Save the file and exit the editor.
-
Apply the changes by running:
source ~/.bashrc
For Zsh
-
Open the
.zshrcfile in your home directory:nano ~/.zshrc -
Look for the line that starts with
PROMPT=. This variable defines the prompt. -
Modify the
PROMPTvariable to customize your prompt. For example:PROMPT='%n@%m:%~%# '%n- username%m- hostname%~- current working directory%#- shows#for root and%for regular users
-
Save the file and exit the editor.
-
Apply the changes by running:
source ~/.zshrc
After following these steps, your terminal prompt will reflect the customizations you made.
