Directory name completion

JD jd1008 at gmail.com
Tue Jun 21 16:12:34 UTC 2011


On 06/21/2011 08:52 AM, g wrote:
> On 06/21/2011 12:14 PM, Patrick O'Callaghan wrote:
>> There's a specific directory on my system, let's call
>> it /some/long/path/foobar, that I visit a lot, so it's a bore to have to
>> type the full pathname so often. The parent directory (/some/long/path)
>> is a component in CDPATH so I can just type 'cd foobar' and all is good.
> <snip>
>
> then consider an alias;
>
>    alias cdfb='cd  /some/long/path/foobar'
>
> now, a simple cdfb will put you there.
>
> i have used such aliases for long path directories for years and it has
> always worked.
>
>
> hth.
>
I solved this problem by using  a feature of Kshell ( /bin/ksh)
It lets you create functions which you source at login (via .profile).
I have set up a large collection of such long directory path
names in a file I call ~/_dirs
This list is augmented (in memory) with pathnames that are used
(i.e. cd <pathname>) during the lifetime of the shell, which are not
already in ~/_dirs.
I have created a few aliases such as
alias cd=dchg , among others.
The funcion dchg (which is sourced by the .profile file)
examines  it's argument and if the arg pattern is found among
the list of dirs  in cached in memory, then it cd's to that dir.
The match occurs on a first fit basis, in case the pattern would
match other unique pathnames, but which contain the same
pattern.
This has saved me millions of key strokes during rapid (i.e. high pressure)
SW development cycles.
I inherited this scheme from a friend while working at a company.



More information about the users mailing list