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

Terminal: Go to Recent Directory #17840

Open
1 task done
tannal opened this issue Sep 15, 2024 · 5 comments
Open
1 task done

Terminal: Go to Recent Directory #17840

tannal opened this issue Sep 15, 2024 · 5 comments
Labels
enhancement [core label] terminal Feedback for terminal integration, shell commands, etc

Comments

@tannal
Copy link

tannal commented Sep 15, 2024

Check for existing issues

  • Completed

Describe the feature

Vscode have a stack which store all the directories user changed.
It is very useful for navigating working directory in the terminal.

If applicable, add mockups / screenshots to help present your vision of the feature

image
Ctrl+g

@tannal tannal added admin read Pending admin review enhancement [core label] triage Maintainer needs to classify the issue labels Sep 15, 2024
@tannal
Copy link
Author

tannal commented Sep 15, 2024

Well, I do want to implement this feature for zed but don't know where to start with.

@notpeter notpeter changed the title Jump to recent directories Terminal: Go to Recent Directory Sep 16, 2024
@notpeter
Copy link
Member

Gotcha, in VSCode "Terminal: Go to Recent Directory" is bound to cmd-g (Mac). For reference, what's the Linux shortcut?

I haven't used the feature, does it just suggest recent folders from your project or does pull out recent directories you've manually entered via typing cd whatever in terminal too?

@notpeter notpeter added terminal Feedback for terminal integration, shell commands, etc and removed triage Maintainer needs to classify the issue admin read Pending admin review labels Sep 16, 2024
@tannal
Copy link
Author

tannal commented Sep 16, 2024

It's ctrl-g on Linux and Windows.
image

does pull out recent directories you've manually entered via typing cd whatever in terminal too?

Yes.

@notpeter
Copy link
Member

does pull out recent directories you've manually entered via typing cd whatever in terminal too?

yes

Interesting. I think Zed would have to monitor the shell subprocess to keep track of this. On Linux this could leverage inotify on /proc/<pid>/cwd but on MacOS I think Zed would have to periodically poll for this info from the child process with proc_pidinfo.

@SomeoneToIgnore
Copy link
Contributor

Zed already does

if self.pty_info.has_changed() {

where AlacTermEvent::Wakeup is an event appearing on new terminal content.

cwd is retrieved via

pub fn get_cwd(&self) -> Option<PathBuf> {
self.pty_info.current.as_ref().map(|info| info.cwd.clone())
}

so all that's needed is to store and update this info somehow.
Similarly, we can reuse this to restore terminals with their current paths.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement [core label] terminal Feedback for terminal integration, shell commands, etc
Projects
None yet
Development

No branches or pull requests

3 participants