Skip to content

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

Open
hetima wants to merge 1 commit intomitchcapper:masterfrom
hetima:feat-workingdir
Open

feat: Add WorkingDirectory property to control terminal process startup directory (WPF)#2
hetima wants to merge 1 commit 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 or is "%USERPROFILE%", the system falls back to the user's profile directory
  • 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);

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.

1 participant