#!/bin/bash # Define the new PS1 string # Example: [User@Host CurrentDir]$ # This example uses colors: green for user@host, blue for directory. # \u: username # \h: hostname (short) # \w: current working directory (basename only) # \$: # if root, $ otherwise NEW_PS1='\[\e[1m\]\[\e[90m\]0\[\e[0;32m\]\u@\[\e[36m\]\h\[\e[90m\]:\[\e[33m\]\w\[\e[90m\]$ \[\e[m\]' # The line to be added to .bashrc PS1_LINE="PS1='${NEW_PS1}'" # Check if the line already exists in .bashrc to prevent duplicates if grep -qF "${PS1}" ~/.bashrc; then echo "PS1 setting already exists in ~/.bashrc. No changes made." else # Append the PS1 line to .bashrc echo "${PS1_LINE}" >> ~/.bashrc echo "PS1 setting has been added to ~/.bashrc." echo "Please open a new terminal or run 'source ~/.bashrc' for changes to take effect." fi