Skip to content

feat: Add WorkingDirectory property to control terminal process startup directory (WPF)#2

Open
hetima wants to merge 2 commits intomitchcapper:masterfrom
hetima:feat-workingdir
Open

feat: Add WorkingDirectory property to control terminal process startup directory (WPF)#2
hetima wants to merge 2 commits intomitchcapper:masterfrom
hetima:feat-workingdir

Conversation

@hetima
Copy link

@hetima hetima commented Mar 5, 2026

Summary

This PR adds a WorkingDirectory property to the EasyTerminalControl class, allowing users to specify the working directory for the terminal process. This feature enables terminal sessions to start in a specific directory instead of inheriting the current process's working directory.

Changes

  • Added WorkingDirectory dependency property to EasyTerminalControl
  • Updated IProcessFactory.Start() interface to accept an optional workingDirectory parameter
  • Updated ProcessFactory.Start() and RunProcess() to pass working directory to CreateProcess()
  • Updated TermPTY.Start() method to accept and pass through the working directory parameter
  • Updated example application (TermExample) to demonstrate the new property

Details

The implementation includes fallback logic:

  • If the specified directory does not exist, set it to null.
  • If WorkingDirectory is null, the process inherits the current process's working directory (default behavior)

Usage Example

<term:EasyTerminalControl 
    StartupCommandLine="pwsh.exe" 
    WorkingDirectory="{Binding WorkingDirectory}" />
public string WorkingDirectory => Environment.GetFolderPath(Environment.SpecialFolder.UserProfile);

@mitchcapper
Copy link
Owner

@hetima thanks this PR looks clean. I think if the WD doesn't exist or isn't specified we should just make sure it is set to null so the behavior is the default. Let me know your thoughts.

@hetima
Copy link
Author

hetima commented Mar 6, 2026

I have no objection. Changes committed.

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