How to change the return-value of homedir()

So I want to change the starting location in my file-tree when I use Jupyter. From what I understand, Jupiter opens up the file tree at the location returned by homedir(). So my question is, how can I change this value permanently, so that my default location in the file tree when opening Jupyter is wherever I set it to? From the documentation for homedir(), I can see that I am supposed to check out “Miscellaneous utilities — libuv documentation”, but that description does not at all help me understand how to change the return-value.

Or, alternativly, some other solution for how to change the default file tree location for Jupyter.

Do IJulia.notebook(dir="...some other directory..."), since it sounds like you are launching Jupyter with IJulia.jupyter.

(Or run the jupyter program yourself in a terminal, in whatever directory you want.)

2 Likes

If I’m in the directory where the notebook(s) is(are), then the relevant special case of @stevengj 's advice is (using IJulia is in my startup.jl file) from the REPL

julia> notebook(;dir=pwd())

which keeps me from having to hunt things down in my file system.

1 Like

I feel like that is a bit too long a peice of code to write every time, so it does not quite scratch my itch.

I don’t want to have using IJulia in my startup, as it adds to the startup-time and I will not allways want to use it. Sometimes I just want to open the REPL for some quick one-off calculation.

But here is what I ended up doing, which I am very happy with:
I have added the following into my .julia/config/startup.jl file:

function jupyter()
    local jupyter_launch = quote
        using IJulia
        notebook(dir=raw"C:\Users\densb\AllMaStuff\Skule\03_Programming\Julia\Notebooks")
    end
    eval(jupyter_launch)
end

This means that I can now just call jupyter() in the terminal, and everything launches just perfect :smiley:

Note: I edited to comand so that I don’t define jupyter_launch as a global, whoops :sweat_smile:

Why do you need to type the whole line every time? Type notebook and press the up arrow to go back in history, I always use this for IJulia notebooks for exactly this reason

3 Likes

I had no idea! That is pretty neat :smiley:

However, I like my final solution better, where I don’t have to do using IJulia manually, and then the notebook-command, or alternatively add it to my startup.jl file and load it even when I don’t use it. Now I use the jupyter() command once in any script to load and launch the notebook with custom launch-settings :sunglasses:

(How often do you launch Jupyter? I usually leave it running for weeks at a time.)

I am just getting into using Jupyter for day-to-day use, and I did not realize that leaving it for weeks was okay practice. With Pluto, I had to relaunch every time I closed my laptop, which was often. I actually just discovered that Jupiter was running just fine after closing and reopening. But I turn my computer completely off every at least once a day, so fast and convenient launch is pretty important.