How to Customize Your Bash In Linux

In this tutorial we will explore how to customize your bash terminal using some modifications.

Our new customization will allow us to

  • Get the Total Number of Files in Our Current Directory right in the Terminal
  • Get the Total Size in MB
  • Give us the Detail Path
  • A new line to type long commands

To keep things short, here are some snippets to add to your bashrc file or bash_profile to persist the new modifications

# New Line & Files Size & Full Path Up
PS1="\n\[\e[30;1m\]\[\016\]l\[\017\](\[\e[34;1m\]\u@\h\[\e[30;1m\])-(\[\e[37;1m\]\w\[\e[32;1m\])\n(\[\e[32;1m\]\$(/bin/ls -1 | /usr/bin/wc -l | /bin/sed 's: ::g') files, \$(/bin/ls -lah | /bin/grep -m 1 total | /bin/sed 's/total //')b\[\e[30;1m\])-> \[\e[0m\]"

### New Line &File size, Number of Files, Full Path, Red Gold Green
PS1="\[\e[32m\][\[\e[m\]\[\e[31m\]\u\[\e[m\]\[\e[33m\]@\[\e[m\]\[\e[32m\]\h\[\e[m\]:\[\e[36m\]\w\[\e[m\]\[\e[32m\]]\[\e[m\]\n(\[\e[32;1m\]\$(/bin/ls -1 | /usr/bin/wc -l | /bin/sed 's: ::g') files, \$(/bin/ls -lah | /bin/grep -m 1 total | /bin/sed 's/total //')b\[\e[30;32m\])-> \[\e[0m\]"
How to Persist the Modifications

Once you close your terminal all will be reset to the default unless you add the modifications to your .bashrc file or .bash_profile

sudo nano .bashrc

Save the changes and close and open your terminal to see the changes persisted

You can also check out the video tutorial below.

Thank You For Your Attention
Jesus Saves

By Jesse E.Agbe(JCharis)

Leave a Comment

Your email address will not be published. Required fields are marked *