Discussion on:

2
Comments

Join the conversation!

Follow via:
RSS
Email Alert
Thanks to Jack Wallen for prompt info!
Ever since SuSE said "bash$" I realized Unixy OSs were their own world. Linuxmag started w a Newbies column then gave up on the mass of Windose haters, leaving Linux opaque.

Jack's goofs.
1. Typo ERR: 2nd section "\[" (Not\]) starts.
2. A little colorful explaination, please? What IS the ColorCode?!
Your Primaries Color Codes suffix m :
R= 31m= 1F= 0001 1111
G= 32m= 20= 0010 0001
R= 34m= 22= 0010 0010

Huh? Sometimes I see iirrggbb 8-bit string. That gives 2^2= 4 levels of each primary and 4 intensities.
I use bash command windows for my daily work and I would like to customise the shell prompt to solve a problem I am facing. The issue is that I tend to create a lot of folders and subfolders and as I go "deeper and deeper" in the hierarchy tree, the shell prompt increases in length up to a point where it exceeds the window width and it jumps to the next line. I find this a bit annoying and I would like to know if I can customise the prompt so that it displays the last 3 directories for any place nested in more than 3 directories.

example:
% cd dir1
dir1 % cd dir1.1
dir1/dir1.1 % cd dir1.1.1
dir1/dir1.1/dir1.1.1 % cd dir1.1.1.1
dir1.1/dir1.1.1/dir1.1.1.1 %

I did use in the past tcsh command window and the command looked like:

alias setbar 'set d = $cwd;
set a = (`echo $cwd | tr "/" " "`);
@ n = $#a;
@ nn = 0;
@ nnn = 0;
if ( $n > 3 ) @ nn = $n - 1;
if ( $n > 3 ) @ nnn = $n - 2;
if ( $n > 3 ) set d = "${a[$nnn]}/${a[$nn]}/${a[$n]}";
set prompt = "${hostname}: $d % ";
unset n nn nnn a d'
Keyboard Shortcuts:
Prev
Next
Toggle
Join the conversation
Formatting +
BB Codes - Note: HTML is not supported in forums
  • [b] Bold [/b]
  • [i] Italic [/i]
  • [u] Underline [/u]
  • [s] Strikethrough [/s]
  • [q] "Quote" [/q]
  • [ol][*] 1. Ordered List [/ol]
  • [ul][*] · Unordered List [/ul]
  • [pre] Preformat [/pre]
  • [quote] "Blockquote" [/quote]

Join the TechRepublic Community and join the conversation! Signing-up is free and quick, Do it now, we want to hear your opinion.