Skip to content

Conversation

joshuamegnauth54
Copy link
Contributor

@joshuamegnauth54 joshuamegnauth54 commented Jul 24, 2024

Closes: #251

This patch implements an optional (but enabled by default) feature for opening new terminals using the focused terminal's working directory. The code to retrieve the CWD is largely based on Alacritty's implementation of the same feature.

It works but I have one small change to work on later.

Todo:

  • Add a config option to revert to the old behavior

@joshuamegnauth54 joshuamegnauth54 marked this pull request as ready for review July 25, 2024 05:22
@joshuamegnauth54 joshuamegnauth54 force-pushed the feat-new-tab-open-in-cwd branch 2 times, most recently from b62121c to c261fb2 Compare July 25, 2024 11:12
@bGVia3VjaGVu
Copy link
Contributor

I think this should be under profiles.

@joshuamegnauth54
Copy link
Contributor Author

Do you mean as a per profile setting?

@joshuamegnauth54
Copy link
Contributor Author

Alright, I moved the setting over to Profiles.

@joshuamegnauth54 joshuamegnauth54 force-pushed the feat-new-tab-open-in-cwd branch 2 times, most recently from 7a8f93a to e5bcfac Compare August 6, 2024 06:31
@joshuamegnauth54 joshuamegnauth54 force-pushed the feat-new-tab-open-in-cwd branch from e5bcfac to 3e33977 Compare August 22, 2024 02:30
@joshuamegnauth54 joshuamegnauth54 changed the title feat: Open new terms in last focused term's CWD feat: Profile option to open new terms in last focused term's CWD [rebased 08-21] Aug 22, 2024
@joshuamegnauth54 joshuamegnauth54 force-pushed the feat-new-tab-open-in-cwd branch from 3e33977 to 01e605b Compare August 22, 2024 02:50
@joshuamegnauth54 joshuamegnauth54 changed the title feat: Profile option to open new terms in last focused term's CWD [rebased 08-21] feat: Profile option to open new terms in last focused term's CWD [rebased 2024-09-03] Sep 3, 2024
@joshuamegnauth54 joshuamegnauth54 force-pushed the feat-new-tab-open-in-cwd branch from 369a497 to 6082f3b Compare October 6, 2024 04:16
@joshuamegnauth54 joshuamegnauth54 changed the title feat: Profile option to open new terms in last focused term's CWD [rebased 2024-09-03] feat: Profile option to open new terms in last focused term's CWD [rebased 2024-10-06] Oct 6, 2024
@Daniel-Diaz
Copy link

This option would be great! I really miss it when using the cosmic terminal.

@oscardssmith
Copy link

Is this blocked on anything? It seems like a nice feature.

@jackpot51
Copy link
Member

This needs a rebase

@joshuamegnauth54 joshuamegnauth54 force-pushed the feat-new-tab-open-in-cwd branch from 6082f3b to 35a29cf Compare June 28, 2025 07:02
@joshuamegnauth54 joshuamegnauth54 changed the title feat: Profile option to open new terms in last focused term's CWD [rebased 2024-10-06] feat: Profile option to open new terms in last focused term's CWD [rebased 2025-06-28] Jun 28, 2025
@joshuamegnauth54
Copy link
Contributor Author

joshuamegnauth54 commented Jun 28, 2025

I rebased it. 😸

I force pushed to fix the formatting. While rebasing, I inadvertently added an extra indentation because the brackets were confusing. Code is still the same.

@joshuamegnauth54 joshuamegnauth54 force-pushed the feat-new-tab-open-in-cwd branch from 35a29cf to ed78b73 Compare June 29, 2025 02:06
@joshuamegnauth54 joshuamegnauth54 force-pushed the feat-new-tab-open-in-cwd branch from ed78b73 to 822218e Compare July 26, 2025 06:15
@joshuamegnauth54 joshuamegnauth54 changed the title feat: Profile option to open new terms in last focused term's CWD [rebased 2025-06-28] feat: Profile option to open new terms in last focused term's CWD [rebased 2025-07-26] Jul 26, 2025
Closes: pop-os#251

This patch implements an optional (but enabled by default) feature for
opening new terminals using the focused terminal's working directory.
The code to retrieve the CWD is largely based on Alacritty's
implementation of the same feature.

I added Rustix as a new direct dependency for the working directory
logic. Both libc and Rustix are transitive dependencies of COSMIC Term.
I opted for Rustix over libc to avoid an `unsafe` block as well as for
its stronger type guarantees.

References:
* https://github.com/alacritty/alacritty/blob/6bd1674bd80e73df0d41e4342ad4e34bb7d04f84/alacritty/src/daemon.rs#L85-L108
The option is enabled by default on Unix but settable per profile.

Windows is currently unsupported and defaults to the old behavior.
@joshuamegnauth54 joshuamegnauth54 force-pushed the feat-new-tab-open-in-cwd branch from 822218e to 9f46076 Compare August 14, 2025 03:37
@oscardssmith
Copy link

@jackpot51 now that doesn't have merge conflicts, can it merge?

@jackpot51
Copy link
Member

jackpot51 commented Sep 19, 2025

I think there are too many places with cfg(not(windows)). I can help to simplify this change.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

New tabs should open in the directory of the current tab

5 participants