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

Re: st: defining current working directory permanently

From   Phil Schumm <>
Subject   Re: st: defining current working directory permanently
Date   Sun, 22 Feb 2009 14:44:58 -0600

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 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

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 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 This would accomplish the same thing as your original approach, but would address (2).

-- Phil

*   For searches and help try:

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