useful bashrc configuration file

Useful bashrc configuration file

Hello Linux users!

When I’m doing my job I’m trying to set my working place as efficient and useful as it’s possible. Bash terminal is my main everyday program I’m using that’s why I decided to improve it a little.

Let’s start from the list directory contents (ls) command. As you know simple ls command is just showing us files without any additional information like privileges or types.

useful bashrc 001

After that kind of output it’s often needed to repeat ls with the keys, for instance ls –lh.

useful bashrc 002
ls -lh

It’s quite annoying to do it every time that’s why I propose to automate it. Let’s make an alias.

There are two ways. The first one (not so good) – just write an alias in the bash.

useful bashrc 003
alias ls="ls -lh --color"

The second one (and is more preferred) is to change the .bashrc file. Open the file, find the aliases strings and uncomment/write the command.

useful bashrc 004
alias ls="ls -lh --color"

The next stuff I’d like to add is splitting. What do I mean? Every time you are executing a command, an output is placed on the next string.

useful bashrc 005
cd; ls; echo; cat

It’s not as convenient as I want. So let’s add one empty string between the last output and the upcoming command. All we have to do is to add “\n” (new string) before kali@kali in the .bashrc file.

useful bashrc 006

And try it out…

useful bashrc 007
cd; ls; cat

Yeah, that’s much easier to read.

Ok, what’s next? I propose to add a time stamp (HH:MM:SS). It’s useful because it’s all about the logging and if you’ve launched something big and time consuming you will always know how long has it took.

“\t” will help us in that case.

useful bashrc 008
useful bashrc 009

Good one… but not excellent 🙂 Let’s move further.

Take a look at the Parrot Linux bash output – it’s colorful, multistring and … unfortunately useless (to me*). It was a good idea, but the author did not extend it. I like an idea about multistring, so let’s use it in our case. To do that I will use Box-drawing character which you can easily find via the link -> Let’s draw a little 🙂

useful bashrc 010
useful bashrc 011

Yeah, almost what I wanted. By the way, I gave a whole string for the working directory on purpose. As you can see there may be a long path and it’s better to change a line to avoid a mess in the one string.


There are plenty of room so let’s use it mindfully. I would suggest to add ip-addresses: inter- and intranet. How can we do that? Bashrc allows to insert scripts into itself with the further exploitation. So let’s add the scripts.

For the intranet we will use the “ip a” command with a filters:

useful bashrc 012
ip a | grep 'inet' | grep -v '\|:' | cut -d " " -f6 | tr "\n\r" " "

For the internet address we will curl the site.

useful bashrc 013
curl -s

Let’s combine it and add to our script:

useful bashrc 014

I added some checks if the machine is out of the internet.

The last thing we have to do is to update the PS string. The full string is:

useful bashrc 015
PS1='${debian_chroot:+($debian_chroot)}\n\[\033[01;32m\]┌─╼ [ \t ] - [ $IP_ext $IP] - [ \u@\h ]\n├─╼\[\033[00m\]\[\033[01;34m\] [ \w ]\[\033[00m\]\[\033[01;32m\]\n│\n└─╼ \[\033[00m\]\$ '

The GitHub repository is via the link –