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

Option to %cd relative to current file #7575

Open
thewh1teagle opened this issue Feb 2, 2025 · 3 comments
Open

Option to %cd relative to current file #7575

thewh1teagle opened this issue Feb 2, 2025 · 3 comments

Comments

@thewh1teagle
Copy link

It will be useful to be able to %cd relative the current file.
eg. %cdr ..
will always cd to the parent folder of the folder of the current jupyter notebook.
Why it's important? because if we want to re-run the cells currently it will cd into wrong upper directory.

@thewh1teagle thewh1teagle added enhancement status:Needs Triage Applied to issues that need triage labels Feb 2, 2025
@minrk
Copy link
Member

minrk commented Feb 3, 2025

You can do this relative to $JPY_SESSION_NAME, which is the notebook path if the kernel was started for a notebook

from pathlib import Path
nb = Path(os.environ["JPY_SESSION_NAME"])
%cd {nb.parent}/..

@RRosio
Copy link
Collaborator

RRosio commented Feb 4, 2025

@thewh1teagle does @minrk's suggestion address your issue?

@thewh1teagle
Copy link
Author

@thewh1teagle does @minrk's suggestion address your issue?

Can we add %cd_relative shortcut?

@RRosio RRosio added status:Needs Discussion and removed status:Needs Info status:Needs Triage Applied to issues that need triage labels Feb 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants