DEV Community

Mariam Reba Alexander
Mariam Reba Alexander

Posted on

1 1 1 1 1

Linux: Bash Prompt Generation

This is my first post since I started learning on HackTheBox. I began with the basics, even though I had a foundation, before moving on to advanced career paths like penetration testing and red teaming to ensure I didn't miss out on anything. I want to journal my daily learnings to keep track of what I’ve learned and to showcase my newfound skills to the world. I will highlight the insights that resonated with me the most and will not go into too much detail. The internet is filled with information, and I do not wish to add to it. So here we go.

Bash prompt generation

To show customized descriptions in the command line prompt, such as the date, git branch name, or username for every new line, one can use special characters and variables in the shell’s configuration file (.bashrc for the Bash shell).

For example

PROMPT_COMMAND='PS1_CMD1=$(ip route get 1.1.1.1 | awk -F"src " '"'"'NR == 1{ split($2, a," ");print a[1]}'"'"')'; PS1='${PS1_CMD1}/\d\t/\w>'

will show in the terminal as

192.168.1.100/Fri Apr 1112:52:54/~/bin>█
Enter fullscreen mode Exit fullscreen mode

As it is hard to remember all of the parameters, one can use bash-prompt-generator and powerline to generate the prompt script for you.

This setup is useful and saves time for a security professional to know the system information each time you use the terminal.

ACI image

ACI.dev: The Only MCP Server Your AI Agents Need

ACI.dev’s open-source tool-use platform and Unified MCP Server turns 600+ functions into two simple MCP tools on one server—search and execute. Comes with multi-tenant auth and natural-language permission scopes. 100% open-source under Apache 2.0.

Star our GitHub!

Top comments (0)

Tiger Data image

🐯 🚀 Timescale is now TigerData: Building the Modern PostgreSQL for the Analytical and Agentic Era

We’ve quietly evolved from a time-series database into the modern PostgreSQL for today’s and tomorrow’s computing, built for performance, scale, and the agentic future.

So we’re changing our name: from Timescale to TigerData. Not to change who we are, but to reflect who we’ve become. TigerData is bold, fast, and built to power the next era of software.

Read more

👋 Kindness is contagious

Dive into this thoughtful piece, beloved in the supportive DEV Community. Coders of every background are invited to share and elevate our collective know-how.

A sincere "thank you" can brighten someone's day—leave your appreciation below!

On DEV, sharing knowledge smooths our journey and tightens our community bonds. Enjoyed this? A quick thank you to the author is hugely appreciated.

Okay