Skip to content
This repository has been archived by the owner on Aug 10, 2020. It is now read-only.

set working directory automatically #54

Closed
smartinsightsfromdata opened this issue Sep 2, 2015 · 5 comments
Closed

set working directory automatically #54

smartinsightsfromdata opened this issue Sep 2, 2015 · 5 comments

Comments

@smartinsightsfromdata
Copy link

When I use SublimeREPL: R ("driven" by R-BOX of course), I manage to tell it to use the current folder as home folder. It saves a lot of confusion. The setting is "cwd": "$folder",.

Sadly I haven't found how to do the same in RBox when using the R app (I'm using OS X).

Is it possible, and if yes, how?

@hafen
Copy link

hafen commented Sep 2, 2015

This is something I've wanted as well. I have a fork that does something like this. It sets the working directory to the project directory every time you send a command.

https://github.com/hafen/R-Box

You can see the relevant changes in rbox/send_text.py at the bottom of here:

master...hafen:master

The way you activate it is to set a project variable "R_box_setwd" to true. So your x.sublime-project file might look something like this:

{
    "folders":
    [
        {
            "follow_symlinks": true,
            "path": "."
        }
    ],
  "settings":
  {
     "R_box_setwd": true
  }
}

This is pretty unobtrusive but I haven't gotten around to doing a PR for it.

@rsaporta
Copy link
Contributor

rsaporta commented Oct 2, 2015

Not sure if I follow, but is what you are looking for different than CMD+\ ?

@smartinsightsfromdata
Copy link
Author

First create a project in Sublime Text in a folder foo.
Open a file, as R extended (even without saving the file).

In REPL R, thanks to the setting that I mentioned above, by default the current working directory (cdw) is set to the level of the folder foo.

It makes Sublime Text work with projects in the same way as Studio does.
The setting of wd is totally transparent to the user and I can refer to any subfolder with indirect addressing, e.g. ./data/somefile.csv without ever having to use setwd("a/very/long/directory/name"), which is not portable etc.

@hafen code (that I confess I haven't tried yet but is on my todo list!) should be doing something similar for R terminal (i.e. when we send the code to the R UI): automagically the wd is set to the folder level.

I have never used CMD+\ but it seems to be trying to save a file?

@dschneiderch
Copy link

@smartinsightsfromdata
where did you add that pref? and at what point does it change directory? when ou open a project?
I modified my R-box user setting to:
{
"prog": "SublimeREPL",
"cwd": "$folder",
}
i'm not getting anything different.

The problem with CMD+\ is it uses the source files directory. I usually keep my project-template file in projectdir, in the below structure. in fact, is there a way to turn it off because I hit \ accidentally all the time.
projectdir/
src/
data/

@randy3k randy3k closed this as completed Dec 3, 2016
@randy3k
Copy link
Owner

randy3k commented Dec 3, 2016

Sending code feature is exported to SendREPL.
Please open an issue there at your will.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants