-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathhere.hlp
72 lines (47 loc) · 1.88 KB
/
here.hlp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
.-
help for ^here^
.-
A Simpler Way to Find Your Files
--------------------------------
^here^ [, ^set^ ^nogit^ ]
Installation
------------
^net install here, from("https://raw.githubusercontent.com/korenmiklos/here/master/")^
Usage
-----
Type the command ^here^ anywhere inside a project folder and it will put the *root* of the project folder into a global macro called ^here^.
. pwd
/Users/koren/projects/social-distancing/analysis/counterfactual
. here
/Users/koren/projects/social-distancing/
. display "${here}"
/Users/koren/projects/social-distancing/
. import delimited "${here}/data/raw/bls/employment.csv"
To fix the root folder, use ^here, set^.
. cd "/Users/koren/projects/social-distancing/analysis"
/Users/koren/projects/social-distancing/analysis
. here, set
/Users/koren/projects/social-distancing/analysis/
. display ${here}
/Users/koren/projects/social-distancing/analysis/
Under the hood
--------------
With the basic usage, ^here^ looks for a parent folder with the (empty) file ".here" in it. Suppose you have the following folder structure.
.
├── .here
├── analysis
│ ├── counterfactual
│ │ └── simulate.do
│ └── regress.do
└── data
└── raw
└── employment.csv
Whether you call ^here^ from "analysis/regress.do" or from "analysis/counterfactual/simulate.do", the value of ^${here}^ will be absolute path of the folder containing the file ".here". Whevener you issue
^here, set^
here will put a file called ".here" in your current folder.
^here^ will also stop if it finds a ".git" folder, with the understanding that git repositories are typically in the root of a project folder. But if this is not case for your project, you can turn off this behavior with the otion
^here, nogit^
Options
-------
^set^ sets the root folder of the project.
^nogit^ ignores .git folders when finding the root folder.