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](https://www.ivanglinkin.com/wp-content/uploads/2020/12/001-1.png)
After that kind of output it’s often needed to repeat ls with the keys, for instance ls –lh.
![useful bashrc 002](https://www.ivanglinkin.com/wp-content/uploads/2020/12/002-1.png)
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](https://www.ivanglinkin.com/wp-content/uploads/2020/12/003-1.png)
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](https://www.ivanglinkin.com/wp-content/uploads/2020/12/004-1.png)
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](https://www.ivanglinkin.com/wp-content/uploads/2020/12/005-1.png)
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](https://www.ivanglinkin.com/wp-content/uploads/2020/12/006-1.png)
And try it out…
![useful bashrc 007](https://www.ivanglinkin.com/wp-content/uploads/2020/12/007-1.png)
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](https://www.ivanglinkin.com/wp-content/uploads/2020/12/008-1.png)
![useful bashrc 009](https://www.ivanglinkin.com/wp-content/uploads/2020/12/009-1.png)
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 -> https://en.wikipedia.org/wiki/Box-drawing_character. Let’s draw a little 🙂
![useful bashrc 010](https://www.ivanglinkin.com/wp-content/uploads/2020/12/010.png)
![useful bashrc 011](https://www.ivanglinkin.com/wp-content/uploads/2020/12/011.png)
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](https://www.ivanglinkin.com/wp-content/uploads/2020/12/012.png)
Let’s combine it and add to our script:
![useful bashrc 014](https://www.ivanglinkin.com/wp-content/uploads/2020/12/014.png)
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](https://www.ivanglinkin.com/wp-content/uploads/2020/12/015.png)