Statalist


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

Re: st: defining current working directory permanently


From   Jeph Herrin <[email protected]>
To   [email protected]
Subject   Re: st: defining current working directory permanently
Date   Mon, 23 Feb 2009 08:12:33 -0500


Another solution along these lines is the -fastcd-
package.  It creates and maintains a list of directories,
associating a brief mnemonic with each. Sort of like
automating Phil's solution below.

hth,
Jeph


Phil Schumm wrote:
On Feb 22, 2009, at 11:01 AM, Dragutin Culinovic wrote:
I would like to change current working direcrory permanently, so I don't have to invoke command:

-cd somedir- in STATA prompt.

I tried putting -cd somedir- in profile.do in my home directory on linux, but noting has changed.



I presume you want to do this because you tend to work in a particular location on your filesystem, and want to make it easy to get there. I do too; in my case, I do most of my work on my desktop (or in a subdirectory located on it). Although the approach you describe above will ensure that Stata automatically switches to your preferred directory immediately after launch, it has two limitations:

1) Occasionally, you may want Stata to start up with a different working directory. For example, if you double-click on a .dta file, you often want Stata to open where that file is located. There are lots of other examples.

2) Occasionally while working, you may do something that causes Stata to switch to another working directory, and, in that case, you want to be able to get back to your preferred working directory easily.

Note that on Unix/Linux/OS X, if you work in your home directory, you don't need to do anything special. Simply typing -cd- will take you right (back) to your home directory from anywhere. However, if you work somewhere else (e.g., your desktop), then you can use a one-line program like this:


program desktop
    cd ~/Desktop
end


This allows me to type -desktop- from wherever I am and immediately return to my desktop. Therefore, it addresses (2) above, and using this strategy (rather than inserting -cd ~/Desktop- in my profile.do) means that when I do want Stata to start somewhere else, I don't have to do anything special (i.e., it also addresses (1)).

Note that if you really never want Stata to start anywhere other than your preferred directory, you could still call your one-line program from the bottom of your profile.do. This would accomplish the same thing as your original approach, but would address (2).


-- Phil

*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/

*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/



© Copyright 1996–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index