Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"restart()" Julia and keep activated path and working directory #32129

Open
mschauer opened this issue May 24, 2019 · 2 comments
Open

"restart()" Julia and keep activated path and working directory #32129

mschauer opened this issue May 24, 2019 · 2 comments
Labels
feature Indicates new feature / enhancement requests

Comments

@mschauer
Copy link
Contributor

A feature request of a restart() function which restarts Julia and keeps the current working directory, the activated path and the window. This feature would be independent of a future comeback of the workspace function (#25046).

An almost-implementation by @fredrikekre:

function restart()
    startup = """
        Base.ACTIVE_PROJECT[]=$(repr(Base.ACTIVE_PROJECT[]))
        Base.HOME_PROJECT[]=$(repr(Base.HOME_PROJECT[]))
        cd($(repr(pwd())))
        """
    cmd = `$(Base.julia_cmd()) -ie $startup`
    atexit(()->run(cmd))
    exit(0)
end

This version is nested, so it keeps old display windows open etc. The actual solution would call exec with the right arguments.

@mschauer
Copy link
Contributor Author

Something somewhat similar can be achieved by adding an atexit hook saving state and a startup script as in

https://discourse.julialang.org/t/what-is-in-your-startup-jl/18228/5

@brenhinkeller brenhinkeller added the feature Indicates new feature / enhancement requests label Nov 21, 2022
@matthewelmer-tamu
Copy link

matthewelmer-tamu commented Jul 31, 2024

If this is added as a feature, I would suggest naming it restart_julia() (or not exporting it) so that the user's namespace isn't polluted with a relatively common word.

Fantastic little function, though! Extremely handy for when Revise runs into an edge case.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature Indicates new feature / enhancement requests
Projects
None yet
Development

No branches or pull requests

3 participants