Skip to content

Conversation

@kud
Copy link
Contributor

@kud kud commented Nov 26, 2025

Summary

This PR enhances the Current Directory widget in iTerm2's status bar with an interactive popover interface, similar to the existing Job Name widget functionality.

Changes

When clicking on the Current Directory status bar widget, users now see a popover with 5 useful actions:

  1. Copy Full Path - Copies the complete directory path to clipboard
  2. Copy Directory Name - Copies just the directory name (basename) to clipboard
  3. Reveal in Finder - Opens Finder and shows the directory
  4. Open in New Window - Opens a new iTerm2 window in that directory
  5. Open in New Tab - Opens a new tab in the current window in that directory

Implementation Details

  • Created iTermDirectoryActionsViewController for the popover UI
  • Updated iTermStatusBarWorkingDirectoryComponent to show popover on click
  • Proper dark mode support using effectiveAppearance
  • Leverages iTermSessionLauncher for opening new windows/tabs
  • Follows existing code patterns from the Job Name widget

Testing

The feature has been implemented following iTerm2's existing patterns and should work seamlessly with both light and dark modes.

Screenshots

The popover provides a clean, native macOS interface that matches iTerm2's visual style and adapts to the current appearance mode.

@kud kud changed the title feat: Add interactive directory actions popover to status bar Add interactive directory actions popover to status bar Nov 26, 2025
@gnachman
Copy link
Owner

gnachman commented Dec 1, 2025

If you want to change only Current Directory then you should modify iTermStatusBarWorkingDirectoryComponent, not iTermStatusBarVariableBaseComponent. I don't think these actions make sense for other subclasses of iTermStatusBarVariableBaseComponent like username and hostname.

Also, why not stick with the existing NSMenu? It has the benefit of allowing mouse-down+drag and is a more consistent look with other components that show menus on click (git, actions, and snippets).

@kud
Copy link
Contributor Author

kud commented Dec 1, 2025

@gnachman Like this?

@kud
Copy link
Contributor Author

kud commented Dec 2, 2025

@gnachman Thanks, I will check this.

I'm not sure what I'm doing here, but I do feel it's frustrating not having any action on that widget. We are missing an opportunity here.

If you have any good idea, happy to implement it.

kud added 2 commits December 3, 2025 22:33
Introduce iTermDirectoryActionsViewController to provide a popover with directory actions (copy path, copy basename, open in Finder, open in new window/tab) when clicking the working directory status bar component. Implements delegate protocol for action handling and integrates with status bar UI. Updates iTermStatusBarVariableBaseComponent to use the new popover and delegate methods.
… command

Refactor session launch logic in iTermStatusBarVariableBaseComponent.m to set the working directory and custom directory directly in the profile dictionary, replacing the previous approach of passing a shell command. This ensures the session starts in the intended directory and improves reliability when launching bookmarks.
@kud kud force-pushed the feat/directory-widget-actions branch from 012c84a to 3acdc50 Compare December 3, 2025 22:43
@kud
Copy link
Contributor Author

kud commented Dec 3, 2025

Done! Changed both methods to use the mutable profile copy pattern with KEY_WORKING_DIRECTORY and KEY_CUSTOM_DIRECTORY. Thanks for the feedback!

@kud kud requested a review from gnachman December 3, 2025 22:44
@gnachman
Copy link
Owner

gnachman commented Dec 5, 2025

I would just put this in an NSMenu instead of creating a whole new view controller by adding it to the existing openMenuWithView: method.

@kud kud marked this pull request as draft December 17, 2025 22:13
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.

2 participants