bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

compact-pwd patch for bash


From: Zsban Ambrus
Subject: compact-pwd patch for bash
Date: Sat, 17 Jan 2004 23:19:57 +0100
User-agent: Mutt/1.3.28i

        compact-pwd patch for bash

INTRODUCTION

It is very convenient to display the working directory in the shell prompt.
This, however, can get very annoying as well, when you cd to a directory
with long name.  The prompt gets inconveniently long in this case.

I have written a remedy for this problem.  After rebuilding bash with my
patch, if you replace \w with \S in the PS1 parameter, the working directory
will be displayed abbreviated.  Only the first letter of each directory
component is displayed, and maybe some other letters to distinguish the
directory from other files or directories.  Let's see some examples.
Propose I set PS1='\S\$ '.  If I cd to the directory

/usr/lib/perl5/site_perl/5.005/i586-linux/auto/QRadioButton

the prompt is:

/u/li/pe/s/5/i/aut/QRad$

This means that if filename completion is enabled, you can cd to this
directory by typing:

cd /u<TAB>/l<TAB>i<TAB>/p<TAB>e<TAB>/s<TAB>/5<TAB>/i<TAB>/a<TAB>u<TAB>t<TAB>/
Q<TAB>R<TAB>a<TAB>d<TAB><ENTER>

You can still display the full name of the directory with the pwd command.

There are some special exceptions: the /usr/local and the /usr/share
directories are printed as /u/l and /u/s respectivly, instead of /u/lo and
/u/sh.  Also a tilde (~) is used instead of $HOME, as bash does it already.
For example

/usr/local/Wolfram/Mathematica/5.0/AddOns/JLink/Documentation/JavaDoc/com

is displayed as:

/u/l/W/M/5/A/J/D/J/cm$

And /usr/share/man/man1 is displayed as /u/s/ma/m1.

If you do not have read access for the parent of a directory, the directory
will be spelled out fully.


DETAILS

The patch is written for bash version 2.05b.  It may or may not work for
other versions.  It may also be buggy.

I only tested the patch on i686 Linux, it may not be portable for other
systems.  This is true especially for the readdir call.

Apply the patch with the -p option.  
Do not forget to rerun configure if you apply the patch to an already
configured bash, as the patch adds new #include dependencies.
Here is an example to build bash with
the patch. 

$ tar -xzvf bash-2.05b.tar.gz
$ <compact-pwd/compact-pwd.patch patch -p0
$ cd bash-2.05b
$ ./configure
$ make
$ make install

I include the patch in the message uuencoded.

This patch does not come with any warranty at all.  I am not sure if it
works in all cases or not.  Use at your own risk.


AUTHOR

Zsban Ambrus  <address@hidden>
2004 Jan 17 


PATCH

begin 644 compact-pwd.patch
M9&EF9B`M<D,R("UX('DN=&address@hidden@@*BYI;F9O(&)A<address@hidden,BXP-6(O8G5I
M;'1I;G,O8V0N9&5F(&)A<address@hidden,BXP-6(O8G5I;'1I;G,O8V0N9&5F"BHJ*B!B
M87-H+3(N,#5B+V)U:6QT:address@hidden@8F%S:"TR+C`U8B]B=6EL
M=&EN<R]C9"YD968**BHJ*BHJ*BHJ*BHJ*BHJ"BHJ*B`T,34L-#$X("HJ*BH*
M+2TM(#0Q-2PT,address@hidden@(`D@('1H95]C=7)R96YT7W=O<FMI;F=?9&ER
M96-T;W)Y(address@hidden&1I<CL*("`)?0HK("`@("`@(&-O;7!A8W1?<'=D6S!=/2`P
M.PH@(`H@("`@("`@(')E='5R;B`H,2D["address@hidden@
M-#,T+#0S-R`J*BHJ"BTM+2`T,S4L-#,Y("TM+2T*("`@("`@("!T9&ER(#T@
M<address@hidden"D["B`@("`@("address@hidden)%12`H=&1I<BD["BL@("`@("address@hidden
M<&%C=%]P=V1;,%T](#`["B`@"B`@("`@("`@<F5T=7)N("@Q*3L*9&EF9B`M
M<D,R("UX('DN=&address@hidden@@*BYI;F9O(&)A<address@hidden,BXP-6(O9&]C+V)A<address@hidden
M,2!B87-H+3(N,#5B+V1O8R]B87-H+C$**BHJ(&)A<address@hidden,BXP-6(O9&]C+V)A
M<address@hidden,address@hidden:"TR+C`U8B]D;V,O8F%S:"XQ"BHJ*BHJ*BHJ*BHJ*BHJ
address@hidden@,SDV-BPS.38Y("HJ*BH*+2TM(#,Y-C8L,SDW,B`M+2TM"address@hidden&AE
M(&)A<V5N86UE(&]F('1H92!C=7)R96YT('=O<FMI;F<@9&ER96-T;W)Y"B`@
M+E10"address@hidden(@7&53"address@hidden&AE(&-U<G)E;address@hidden:VEN9R!D:7)E8W1O<GDL
M(&%B8G)E=FEA=&5D('5N86UB:6=U;W5S;'D**R`N5%`*("`N0B!<92$*("!T
M:&4@:&ES=&]R>2!N=6UB97(@;address@hidden&AI<R!C;VUM86YD"address@hidden)#,B`M
M>"!Y+G1A8BX_("UX("HN:6YF;R!B87-H+3(N,#5B+V1O8R]B87-H<F5F+G1E
M>&address@hidden:"TR+C`U8B]D;V,O8F%S:')E9BYT97AI"BHJ*B!B87-H+3(N,#5B
M+V1O8R]B87-H<F5F+G1E>&D*+2TM(&)A<address@hidden,BXP-6(O9&]C+V)A<VAR968N
M=&5X:0HJ*BHJ*BHJ*BHJ*BHJ*BH**BHJ(address@hidden,Y,2`J*BHJ"BTM+2`U
M,address@hidden,@+2TM+0H@($!I=&5M(%Q7"address@hidden&AE(&)A<V5N86UE(&]F($!E
M;G9[)%!71'TN"address@hidden&address@hidden,**R!4:&address@hidden<F5N="!W;W)K:6YG(&1I
M<F5C=&]R>address@hidden)B<F5V:address@hidden;6)I9W5O=7-L>2X*("!`:71E;2!<
M(0H@(%1H92!H:7-T;W)Y(&YU;6)E<B!O9B!T:&ES(&-O;6UA;F0N"F1I9F8@
M+7)#,B`M>"!Y+G1A8BX_("UX("HN:6YF;R!B87-H+3(N,#5B+V=E;F5R86PN
M8R!B87-H+3(N,#5B+V=E;address@hidden:"TR+C`U8B]G96YE<F%L
M+F,*+2TM(&)A<address@hidden,BXP-6(O9V5N97)A;"YC"address@hidden
M*BH@,S`L,S,@address@hidden@,S`L,address@hidden@(",@(&EN8VQU9&4@/'5N
M:7-T9"YH/@H@("-E;address@hidden("-I;F-L=61E(#QD:7)E;G0N:#X*("`*("`C
M:6YC;'5D92`B9FEL96-N=&PN:"(**BHJ*BHJ*BHJ*BHJ*BHJ"BHJ*B`U-CDL
M-3<R("HJ*BH*+2TM(#4W,"PV,S@@+2TM+0H@("address@hidden@("`@("!R971U
M<address@hidden&YA;64I.PHK('T**R`**R`O*B!2971U<address@hidden)B<F5V:6%T960@<&%T
M:&YA;address@hidden(%!3,3TG7%-<)"`G("HO"address@hidden<B`J"address@hidden<&%C=%]D
M:7)E8W1O<GE?9F]R;6%T("AS<F,I"BL@"6-H87(@*G-R8SL**R!["BL@("!S
M=&%T:6,@8VAA<B!B=69;4$%42%]-05A=.PHK("`@<W1A=&EC(&-H87(@;F5E
M9%M.04U%7TU!6"]#2$%27T))5"`K(#%=.PHK("`@:6YT(&(L(&4L('`L(&D[
M"BL@("!C:&%R("IT.PHK("address@hidden<B!C.PHK("address@hidden("ID:7(["BL@("!S
M=')address@hidden&ER96YT("ID96YT.PHK("address@hidden(#`[('`@/2`P.PHK("address@hidden"`]
M(&=E=%]S=')I;address@hidden")(3TU%(BD["BL@("!E(address@hidden"`_('-T<FQE
M;B`H="address@hidden("`@:address@hidden&4@/B`Q("8F("%M96UC;address@hidden'0L('-R8RP@
M92D@)address@hidden"%S<F-;address@hidden'P@<W)C6V5=(#T]("<O)RDI('L**R`@("address@hidden
M(&4["BL@("`@(&)U9EMP*RM=(#T@)WXG.PHK("`@("!]"BL@("!I9B`H(6UE
M;6-M<"`H(B]U<W(O;&]C86PB+"!S<F,L(#$P*2`F)B`H(7-R8ULQ,address@hidden'P@
M<W)C6S$P72`]/2`G+R<I*2!["BL@("`@(&(@*ST@,3`["BL@("`@(&)U9EMP
M*RM=(#T@)R\G.R!B=69;<"LK72`]("=U)address@hidden@/2`G+R<[(&)U
M9EMP*RM=(#T@)VPG.PHK("`@("!]"BL@("!I9B`H(6UE;6-M<"`H(B]U<W(O
M<VAA<F4B+"!S<F,L(#$P*2`F)B`H(7-R8ULQ,address@hidden'P@<W)C6S$P72`]/2`G
M+R<I*2!["BL@("`@(&(@*ST@,3`["BL@("`@(&)U9EMP*RM=(#T@)R\G.R!B
M=69;<"LK72`]("=U)address@hidden@/2`G+R<[(&)U9EMP*RM=(#T@)W,G
M.PHK("`@("!]"BL@("!W:&EL92`H<W)C6V)=("8F('address@hidden,BD*
M*R`@("`@:address@hidden'-R8UMB72`]/2`G+R<@?'P@<W)C6V(K,5T@/3T@)R\G*0HK
M("`@("`@(&)U9EMP*RM=(#T@<W)C6V(K*UT["BL@("`@(&5L<V4@>PHK("`@
M("`@('0@/2!S=')C:'(@*'-R8R`K(&(L("<O)RD["BL@("`@("address@hidden('0@
M/R!T("T@<W)C(#H@<W1R;&5N("AS<F,I.PHK("`@("`@(&EF("AE("address@hidden
M($Y!345?34%8*0HK("`@("`@("address@hidden;R!F86EL.PHK("`@("`@(&,@/2!S
M<F-;8ET[('-R8UMB72`](#`["BL@("`@("address@hidden&ER(#T@;W!E;F1I<B`H<W)C
M*3L**R`@("`@("!S<F-;8ET@/2!C.PHK("`@("`@(&EF("@A9&ER*2`O*B!I
M9B!Y;W4@:&%V92!N;R!R96%D('!E<address@hidden(&$@<&%T:"!C;VUP;VYE;G0@
M*B\**R`@("`@("`)9V]T;R!F86EL.PHK("`@("`@(&UE;7-E="`H;F5E9"P@
M,"P@<VEZ96]F*&YE960I*3L**R`@("`@("!N965D6S!=('P](#$\/#`["BL@
M("`@("address@hidden;&address@hidden"AD96YT(#T@<F5A9&1I<B`H9&ER*2DI('L**R`@("`@
M("`):2`](#`["BL@("`@("`@"7=H:6QE("AS<F-;8BMI72`F)B!D96YT+3YD
M7VYA;65;:5T@)B8@"BL@("`@("`@"2`@<W)C6V(K:5T@/address@hidden&5N="T^9%]N
M86UE6VE=*0HK("`@("`@(`D@(&DK*SL**R`@("`@("`):address@hidden'-R8UMB*VE=
M("$](&1E;G0M/F1?;F%M95MI72D**R`@("`@("`)("!N965D6VDO0TA!4E]"
M251=('P](#$\/"AI)4-(05)?0DE4*3L**R`@("`@("`)?0HK("`@("`@("AV
M;VED*6-L;W-E9&ER("AD:7(I.PHK("`@("`@(&9O<B`H:2`](#`[(&D@/"!E
M("address@hidden@:2LK*0HK("`@("`@("`@:address@hidden&YE961;:2]#2$%27T))5%TF*#$\
M/"AI)4-(05)?0DE4*2DI"BL@("`@("`@("`@(&)U9EMP*RM=(#T@<W)C6V(@
M*R!I73L**R`@("`@("!I9B`H,"D@>PHK("address@hidden;#H**R`@("`@("`@(&UE
M;6-P>2`H8G5F("L@<"P@<W)C("address@hidden@92`M(&(I.PHK("`@("`@("`@<"`K
M/2!E("address@hidden@("`@("`)?0HK("`@("`@(&(@/2!E.PHK("`@("!]"BL@
M("!B=69;<%T@/2`P.PHK("`@<F5T=7)N("AB=68I.PH@('T*("`*9&EF9B`M
M<D,R("UX('DN=&address@hidden@@*BYI;F9O(&)A<address@hidden,BXP-6(O9V5N97)A;"YH
M(&)A<address@hidden,BXP-6(O9V5N97)A;"YH"BHJ*B!B87-H+3(N,#5B+V=E;F5R86PN
M:address@hidden:"TR+C`U8B]G96YE<address@hidden"BHJ
M*B`R.38L,CDY("HJ*BH*+2TM(#(Y-BPS,address@hidden@(&5X=&5R;B!C:&%R
M("IF=6QL7W!A=&AN86UE(%]?4"@H8VAA<B`J*2D["address@hidden)N(&-H87(@
M*G!O;&ET95]D:7)E8W1O<GE?9F]R;6%T(%]?4"@H8VAA<B`J*2D["address@hidden
M97)N(&-H87(@*F-O;7!A8W1?9&ER96-T;W)Y7V9O<FUA="!?7U`H*&-H87(@
M*BDI.PHK(&5X=&5R;B!C:&%R(&-O;7!A8W1?<'=D6U!!5$A?34%873L*("`*
M("!E>'1E<address@hidden<B`J97AT<F%C=%]C;VQO;E]U;FET(%]?4"@H8VAA<B`J
M+"!I;address@hidden:69F("UR0S(@+7@@>2YT86(N/R`M>"address@hidden
M:"TR+C`U8B]P87)S92YY(&)A<address@hidden,BXP-6(O<&%R<V4N>address@hidden:"TR
M+C`U8B]P87)S92YY"BTM+2!B87-H+3(N,#5B+W!A<G-E+GD**BHJ*BHJ*BHJ
M*BHJ*BHJ"BHJ*B`S-S(R+#,W,address@hidden@HM+2T@,S<R,BPS-S(X("TM+2T*
M("!]"B`@"address@hidden@=&AE(&-O;7!A8W1E9"!P871H;F%M92P@<W1O<F5D(&9O
M<B!C86-H:6YG(')E87-O;G,@*B\**R!C:&%R(&-O;7!A8W1?<'=D6U!!5$A?
M34%873T@(B(["BL@"address@hidden@4F5T=7)N(&$@<W1R:6YG('=H:6-H('=I;&P@
M8F4@<')I;G1E9"!A<R!A('!R;VUP="X@(%1H92!S=')I;F<*("`@("!M87D@
M8V]N=&%I;B!S<&5C:6%L(&-H87)A8W1E<G,@=VAI8V@@87)E(&1E8V]D960@
M87,@9F]L;&]W<SH**BHJ*BHJ*BHJ*BHJ*BHJ"BHJ*B`S-S,U+#,W,S@@*BHJ
address@hidden@,S<S."PS-S0R("TM+2T*("`)7'()0U(*("`)7',)=&AE(&YA;64@
M;address@hidden&AE('-H96QL"BL@"5Q3"71H92!C=7)R96YT('=O<FMI;F<@9&ER96-T
M;W)Y+"!A8F)R979I871E9`H@(`E<=`ET:&address@hidden&EM92!I;B`R-"UH;W5R(&AH
M.FUM.G-S(&9O<FUA=`H@(`E<5`ET:&address@hidden&EM92!I;B`Q,BUH;W5R(&AH.FUM
M.G-S(&9O<FUA=`HJ*BHJ*BHJ*BHJ*BHJ*BH**BHJ(#,Y,38L,SDQ.2`J*BHJ
M"BTM+2`S.3(P+#,Y,address@hidden@(`D@("address@hidden<Z"B`@"2`@("!C
M87-E("=7)SH**R`)("`@(&-A<V4@)U,address@hidden@(`D@("`@("!["B`@"0DO*B!5
M<address@hidden&AE('9A;'5E(&]F(%!71"!B96-A=7-E(&ET(&ES(&UU8V@@;6]R92!E
M9F9I8VEE;G0N("HO"address@hidden@,SDU,RPS.38P("HJ
M*BH*("address@hidden/5%]0051("B`@(W5N9&5F($1/54),15]33$%32%]2
M3T]4"B$@"0EE;'-E"B`@"0D@("\J('!O;&ET95]D:7)E8W1O<GE?9F]R;6%T
M(&ES(&=U87)A;address@hidden&\@<F5T=7)N(&$@<W1R:6YG"B`@"0D@("`@(&YO
M(&QO;F=E<B!T:&%N(%!!5$A?34%8("T@,2!C:&%R86-T97)S+B`J+PH@(`D)
M("!S=')C<'address@hidden'1?<W1R:6YG+"!P;VQI=&5?9&ER96-T;W)Y7V9O<FUA="`H
M=%]S=')I;F<I*3L*("`*("`)"2\J($EF('=E)W)E(&=O:6YG('1O(&)E(&5X
M<&%N9&EN9R!T:&4@<')O;7!T('-T<FEN9R!L871E<BP*+2TM(#,address@hidden,SDW
M,B`M+2TM"B`@(W5N9&5F(%)/3U1?4$%42`H@("-U;F1E9B!$3U5"3$5?4TQ!
M4TA?4D]/5`HA(`D)96QS92!I9B`H8R`]/2`G4R<I('L*(2`)"2`@:address@hidden"$J
M8V]M<&%C=%]P=V0I"B$@"0D@("`@<W1R8W!Y("AC;VUP86-T7W!W9"address@hidden
M<&%C=%]D:7)E8W1O<GE?9F]R;6%T("AT7W-T<FEN9RDI.PHA(`D)("!S=')C
M<'address@hidden'1?<W1R:6YG+"!C;VUP86-T7W!W9"D["B$@"0D@('T*(2`)"2`@"B$@
M"0EE;'-E("\J(&,@/3T@)W<G("HO"B`@"0D@("\J('!O;&ET95]D:7)E8W1O
M<GE?9F]R;6%T(&ES(&=U87)A;address@hidden&\@<F5T=7)N(&$@<W1R:6YG"B`@
M"0D@("`@(&YO(&QO;F=E<B!T:&%N(%!!5$A?34%8("T@,2!C:&%R86-T97)S
M+B`J+PH@(`D)("!S=')C<'address@hidden'1?<W1R:6YG+"!P;VQI=&5?9&ER96-T;W)Y
M7V9O<FUA="`H=%]S=')I;F<I*3L**R`)"2`@"B`@"B`@"0DO*B!)9B!W92=R
M92!G;VEN9R!T;R!B92!E>'!A;F1I;F<@=&AE('!R;VUP="!S=')I;F<@;&%T
M97(L"address@hidden)#,B`M>"!Y+G1A8BX_("UX("HN:6YF;R!B87-H+3(N,#5B
M+W9A<FEA8FQE<RYC(&)A<address@hidden,BXP-6(O=F%R:6%B;&5S+F,**BHJ(&)A<address@hidden
M,BXP-6(O=F%R:6%B;&5S+F,*+2TM(&)A<address@hidden,BXP-6(O=F%R:6%B;&5S+F,*
M*BHJ*BHJ*BHJ*BHJ*BHJ"BHJ*B`T-BPT.2`J*BHJ"BTM+2`T-BPU,"`M+2TM
M"B`@(VEN8VQU9&4@(FAA<VAC;60N:"(*("`C:6YC;'5D92`B<&%T:&5X<"YH
M(@HK("-I;F-L=61E(")G96YE<address@hidden"B`@"B`@(VEN8VQU9&4@(F)U:6QT
M:6YS+V=E=&]P="YH(@HJ*BHJ*BHJ*BHJ*BHJ*BH**BHJ(#8Q.2PV,C(@*BHJ
address@hidden@-C(P+#8R-"`M+2TM"B`@"7T*("`@("address@hidden("address@hidden<&%C=%]P
@=V1;,%T](#`["B`@"B`@("!R971U<address@hidden&YA;64I.PH`
`
end







reply via email to

[Prev in Thread] Current Thread [Next in Thread]