Skip to content

Instantly share code, notes, and snippets.

@deep5050
Last active August 31, 2023 07:13
Show Gist options
  • Save deep5050/29413ab7d159e493f952c1ecdfc13fc7 to your computer and use it in GitHub Desktop.
Save deep5050/29413ab7d159e493f952c1ecdfc13fc7 to your computer and use it in GitHub Desktop.
Linux shell prompt with last three directories

PS1='\[\033[01;32m\]\u@\[\033[00;33m\]$(dirname "$(dirname "$PWD")" | xargs basename 2>/dev/null || echo "")$(if [[ "$PWD" != "/" ]]; then echo "/$(dirname "$PWD" | xargs basename 2>/dev/null || echo "")/$(basename "$PWD")"; fi)\[\033[00m\]\$ '

example:

deep@/COMMSCOPE/fastiron-10010a/ICX8200$ ll
total 0
drwxrwxrwx 1 deep deep 4096 Aug 30 13:10 ./
drwxrwxrwx 1 deep deep 4096 Aug 30 13:10 ../
drwxrwxrwx 1 deep deep 4096 Aug 31 12:20 Firmware/
drwxrwxrwx 1 deep deep 4096 Aug 30 14:48 Images/
drwxrwxrwx 1 deep deep 4096 Aug 30 13:10 MIBs/
drwxrwxrwx 1 deep deep 4096 Aug 30 13:10 Signatures/
deep@COMMSCOPE/fastiron-10010a/ICX8200$

deep@Dipankar/Desktop/COMMSCOPE$ ll

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment