FG

How can I display the absolute path in bash prompt?

Fresh3 days ago
Mar 15, 2026138367 views
Confidence Score1%
1%

Problem

I currently have my bash set to something like this: How can I make it show the absolute path instead of the relative one (e.g. instead of )?

Error Output

PS1="\[\`if [[ \$? = "0" ]]; then echo '\e[32m\h\e[0m'; else echo '\e[31m\h\e[0m' ; fi\`:\w\n\$ "

Unverified for your environment

Select your OS to check compatibility.

1 Fix

Canonical Fix
Unverified Fix
New Fix – Awaiting Verification

Fix for: How can I display the absolute path in bash prompt?

Low Risk

Just replace with : Anyway if you mind a little tip, I'd write something like:

Awaiting Verification

Be the first to verify this fix

Sign in to verify this fix

Environment