Skip to content

Fix: Change copy filepath shortcut from CTRL+Q to CTRL+Y for macOS compatibility (Fixes #617)#692

Closed
AdityaGupta716 wants to merge 4 commits into
neuroinformatics-unit:mainfrom
AdityaGupta716:fix-directorytree-focus
Closed

Fix: Change copy filepath shortcut from CTRL+Q to CTRL+Y for macOS compatibility (Fixes #617)#692
AdityaGupta716 wants to merge 4 commits into
neuroinformatics-unit:mainfrom
AdityaGupta716:fix-directorytree-focus

Conversation

@AdityaGupta716

@AdityaGupta716 AdityaGupta716 commented Feb 24, 2026

Copy link
Copy Markdown
Contributor

closes #617

What is this PR
Bug fix

Why is this PR needed?
Issue #617 reported that CTRL+Q quits the application on macOS, making it impossible to use the copy filepath shortcut on that platform. CTRL+W and CTRL+K were also considered but both have conflicts on macOS (CTRL+W deletes a word, CTRL+K deletes to end of line). CTRL+Y has no conflicts on any platform.

What does this PR do?

  • Changes the key binding from ctrl+q to ctrl+y in custom_widgets.py
  • Updates tooltips in tooltips.py and app.py
  • Updates docs in create-folders.md and getting-started.md
  • Updates tests in test_tui_directorytree.py

Tested locally on macOS — CTRL+Y copies filepath correctly without any conflicts.

@AdityaGupta716

AdityaGupta716 commented Feb 24, 2026

Copy link
Copy Markdown
Contributor Author

Hey @JoeZiminski, just to give some context the previous PR #681 was accidentally closed when I force-pushed main while syncing my fork with upstream, sorry about that. In this PR I also reconsidered the shortcut key CTRL+W deletes a word and CTRL+K deletes to end of line on macOS, so both had the same problem as CTRL+Q. Went with CTRL+Y instead which has no conflicts on macOS. Since textual captures keystrokes internally, OS-level shortcuts like redo on Windows shouldn't interfere either. Tested locally on macOS and it works perfectly.

@JoeZiminski

JoeZiminski commented Feb 25, 2026

Copy link
Copy Markdown
Member

Hi @AdityaGupta716 thanks for this! Really appreciate the testing, I will look into this in the next couple of days and merge as a priority, I think it would be good to include this in the upcoming release.

[EDIT: no worries at all about the PR closing / force push! These issues are very common]

@JoeZiminski

JoeZiminski commented Feb 27, 2026

Copy link
Copy Markdown
Member

Hi @AdityaGupta716 thanks again for this, could you confirm that it is indeed CTRL+Q that quits the application, rather than command (CMD) key, i.e. CMD+Q? (the issue was recently updated). I could not replicate CTRL+Q closing the application on macOS.

Unfortunately, the CMD key in macOS cannot be read by the terminal, or at least is not by default, meaning we cannot use CMD as a shortcut. The CMD key does a lot of default macOS behaviour which is very confusing. At the moment I think there is simply no workaround, which is frustrating.

It might still be worth changing the CTRL+Q to CTRL+Y because even if CTRL+Q does not close the application, people are likely to confuse it with CMD+Q then close the application, which is confusing. In your hands, does it immediately close the application, or do you get a pop-up? I would immediately change it to CTRL+Y, but for backwards compatibility reasons it would be nice to keep with CTRL+Q unless it is prohibitively annoying.

I think at least, we can add a warning to the documentation (maybe the install page, and choosing a terminal page).

@AdityaGupta716

AdityaGupta716 commented Feb 27, 2026

Copy link
Copy Markdown
Contributor Author

Hi @JoeZiminski, CTRL+Q is clean and even if we press CMD+Q by mistake on Mac a popup comes up that tells us "do you want to terminate the terminal" so the user at least knows what happened. CTRL+Y also has no conflicts on macOS or Windows, and since CMD+Q gives a popup the user will know they haven't copied, but CMD+Y won't give anything so the user may get stuck for a few seconds thinking what did they do wrong. Either way Mac people won't get the command key so it's fine to pick anything.
I think the cleanest fix here is to just make ctrl+c the actual copy shortcut and remove the current ctrl+c help notification entirely. The notification only exists because copy wasn't working properly — once ctrl+c copies the filepath directly there's no need for it anymore. ctrl+y is arbitrary and nobody would guess it, ctrl+c is what every user already expects for copy and it works fine in the TUI on both Mac and Windows unlike cmd+c.
I've made the changes — this PR already contains them. ctrl+c now copies, and the old ctrl+c help notification is removed since it's no longer needed. and CTRL Q is not needed since esc is what is normally used to quit the TUI,and the test fail is unrelated .

@JoeZiminski

Copy link
Copy Markdown
Member

Hi @AdityaGupta716 thanks for your thoughts on this and looking into it further with CTRL+C. I'm glad you mentioned about the pop-up reminding users they may have pressed the wrong button, that was my thinking too. In this case, it's good to know CTRL+Q is workable.

Thanks also for investigating CTRL+C. funnily enough we did used to have CTRL+C for the copy behavior, but it lead to some problems. In theory textual should take the CTRL+C event and not let it close the terminal (which can happen on Windows). However in practice this behavior was not consistent, and sometimes on Windows CTRL+C would close the terminal (see #573). This is quite unfortunate, as it would otherwise be a nice solution! Unfortunately handling these shortcuts cross-platform through the terminal is very tricky :(

@AdityaGupta716

Copy link
Copy Markdown
Contributor Author

@JoeZiminski, seems like ctrl+q is actually the best cross-platform choice — works fine on macOS, no issues on Windows either. Unless there's something else you'd like me to look into, I think this PR and issue can be closed!

@JoeZiminski

Copy link
Copy Markdown
Member

Thanks @AdityaGupta716 I agree we can close this, thanks a lot for looking into this, the research and discussing through ideas has been very useful! Cheers

@JoeZiminski JoeZiminski closed this Mar 3, 2026
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.

Macbook keyboard shortcuts

2 participants