[CentOS] Scripting a directory change on CentOS
johnny at centos.org
Mon Jul 30 17:02:04 UTC 2007
James B. Byrne wrote:
> This is probably a FAQ item but despite searching extensively with google
> I am unable to find an answerer to this question. Perhaps I am using the
> wrong words. In any case, at the risk of inducing some mirth at my
> ignorance, how can one script a cd command so that that the user remains
> in that directory when the script exits?
> I have to work with a long path to a project working directory and I would
> like to have a simple script called "current" which would produce the same
> effect as issuing this from the shell:
> cd ./very/long/path/to/obscurely/titled/project/directory
> I cannot seem to find anything that directly addresses this, other than to
> point out that shell scripts run in their own copy of the shell
> interpreter and so anything done to the PWD therein is local to the
> duration of the script. I could create a logical link from my home
> directory I suppose, but I desire a scripted solution.
> I really do not wish to program a utility to do this and I cannot believe
> that many people have not already addressed this desire with a straight
> forward answer. So if any of you have a simple to implement solution then
> could you share your answer with me?
> As I am a digest subscriber in addition to your answer to the list the
> favour of a direct reply is requested
In this case the use of an alias is probably what you want ...
alias current='cd /path'
You can then type current at the command prompt can go there.
You can put that command in your .bashrc with your other aliases as well
to make it persistent across reboots.
-------------- next part --------------
A non-text attachment was scrubbed...
Size: 252 bytes
Desc: OpenPGP digital signature
Url : http://lists.centos.org/pipermail/centos/attachments/20070730/1169c29a/signature.bin
More information about the CentOS