Site icon New Generation Enterprise Linux

Stop guessing which directory you are actually in when your prompt gets cluttered

Environment & Shell Customization (Aliases/Functions/.Bashrc)

Stop guessing which directory you are actually in when your prompt gets cluttered

🧩 The Challenge

Dealing with a deep-nested directory structure while hopping between projects is a nightmare. I hate staring at a prompt that is basically a paragraph long and tells me nothing useful about where I am.

💡 The Fix

Shrink your prompt to show only the last two path segments and color-code the user info. It keeps your terminal clean so you can actually read the command output.

export PS1='\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]$(basename $(dirname $PWD))/$(basename $PWD)\[\033[00m\]\$ '

⚙️ Why It Works

Bash lets you embed command substitutions directly into the PS1 string, which evaluates that logic every time you hit enter. You get dynamic context without the usual visual noise.

🚀 Pro-Tip: Add a custom function to your .bashrc that toggles between full and short paths for when you really need to see the absolute directory structure.

Linux Tips & Tricks | © ngelinux.com | 8/17/2026

0 0 votes
Article Rating
Exit mobile version