-
Notifications
You must be signed in to change notification settings - Fork 105
feat: Add terminal shell selection to settings #603
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Also in here, lots of the unnecessary changes.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yep, my bad. Will fix. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -595,6 +595,9 @@ export interface SettingsData { | |
| }; | ||
| memory: MemoryConfig; | ||
| taskSettings: TaskSettings; | ||
| terminal: { | ||
| shell: string; | ||
| }; | ||
| hotkeyConfig?: HotkeyConfig; | ||
| } | ||
|
|
||
|
|
@@ -898,3 +901,9 @@ export interface BranchInfo { | |
| isCurrent: boolean; | ||
| hasWorktree: boolean; | ||
| } | ||
|
|
||
| export interface ShellInfo { | ||
| path: string; | ||
| name: string; | ||
| args?: string[]; | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The |
||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| import { SettingsData } from '@common/types'; | ||
|
|
||
| export const migrateSettingsV17toV18 = async (settings: SettingsData): Promise<SettingsData> => { | ||
| if (!settings.terminal) { | ||
| settings.terminal = { | ||
| shell: '', | ||
| }; | ||
| } | ||
| return settings; | ||
| }; |
| Original file line number | Diff line number | Diff line change | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -12,7 +12,7 @@ const execAsync = promisify(exec); | |||||||||||||
| let cachedPath: string | null = null; | ||||||||||||||
| let isFirstCall: boolean = true; | ||||||||||||||
|
|
||||||||||||||
| interface ShellInfo { | ||||||||||||||
| export interface ShellInfo { | ||||||||||||||
| path: string; | ||||||||||||||
| name: string; | ||||||||||||||
| args?: string[]; | ||||||||||||||
|
|
@@ -205,6 +205,72 @@ class ShellDetector { | |||||||||||||
| return false; | ||||||||||||||
| } | ||||||||||||||
| } | ||||||||||||||
|
|
||||||||||||||
| /** | ||||||||||||||
| * Get all available shells on the system | ||||||||||||||
| * @returns Array of available shells | ||||||||||||||
| */ | ||||||||||||||
| static getAvailableShells(): ShellInfo[] { | ||||||||||||||
| const shells: ShellInfo[] = []; | ||||||||||||||
| const platform = process.platform; | ||||||||||||||
|
|
||||||||||||||
| if (platform === 'win32') { | ||||||||||||||
| const pwshPath = this.findExecutable('pwsh.exe'); | ||||||||||||||
| if (pwshPath) shells.push({ path: pwshPath, name: 'pwsh' }); | ||||||||||||||
|
|
||||||||||||||
| const powershellPath = this.findExecutable('powershell.exe'); | ||||||||||||||
| if (powershellPath) shells.push({ path: powershellPath, name: 'powershell' }); | ||||||||||||||
|
|
||||||||||||||
| const cmdPath = path.join(process.env.SYSTEMROOT || 'C:\\Windows', 'System32', 'cmd.exe'); | ||||||||||||||
| if (fs.existsSync(cmdPath)) shells.push({ path: cmdPath, name: 'cmd' }); | ||||||||||||||
|
|
||||||||||||||
| // Git Bash | ||||||||||||||
| const gitBashPath = path.join(process.env.PROGRAMFILES || 'C:\\Program Files', 'Git', 'bin', 'bash.exe'); | ||||||||||||||
| if (fs.existsSync(gitBashPath)) shells.push({ path: gitBashPath, name: 'git-bash' }); | ||||||||||||||
| } else { | ||||||||||||||
| const commonShells = [ | ||||||||||||||
| '/usr/local/bin/zsh', | ||||||||||||||
| '/bin/zsh', | ||||||||||||||
| '/usr/bin/zsh', | ||||||||||||||
| '/usr/local/bin/fish', | ||||||||||||||
| '/usr/bin/fish', | ||||||||||||||
| '/usr/local/bin/bash', | ||||||||||||||
| '/bin/bash', | ||||||||||||||
| '/usr/bin/bash', | ||||||||||||||
| '/bin/sh', | ||||||||||||||
| '/usr/bin/sh', | ||||||||||||||
| ]; | ||||||||||||||
|
|
||||||||||||||
| const seen = new Set<string>(); | ||||||||||||||
| for (const shellPath of commonShells) { | ||||||||||||||
| if (fs.existsSync(shellPath) && !seen.has(shellPath)) { | ||||||||||||||
| const name = path.basename(shellPath); | ||||||||||||||
| shells.push({ path: shellPath, name, args: this.getShellArgs(name) }); | ||||||||||||||
| seen.add(shellPath); | ||||||||||||||
| } | ||||||||||||||
| } | ||||||||||||||
|
|
||||||||||||||
| // Also check /etc/shells | ||||||||||||||
| try { | ||||||||||||||
| if (fs.existsSync('/etc/shells')) { | ||||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||||||||||||||
| const content = fs.readFileSync('/etc/shells', 'utf8'); | ||||||||||||||
| const lines = content.split('\n'); | ||||||||||||||
| for (const line of lines) { | ||||||||||||||
| const trimmed = line.trim(); | ||||||||||||||
| if (trimmed && !trimmed.startsWith('#') && fs.existsSync(trimmed) && !seen.has(trimmed)) { | ||||||||||||||
| const name = path.basename(trimmed); | ||||||||||||||
| shells.push({ path: trimmed, name, args: this.getShellArgs(name) }); | ||||||||||||||
| seen.add(trimmed); | ||||||||||||||
| } | ||||||||||||||
| } | ||||||||||||||
| } | ||||||||||||||
| } catch { | ||||||||||||||
| // Ignore | ||||||||||||||
| } | ||||||||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Swallowing errors without logging can hide potential issues and make debugging harder. For instance, if reading
Suggested change
|
||||||||||||||
| } | ||||||||||||||
|
|
||||||||||||||
| return shells; | ||||||||||||||
| } | ||||||||||||||
| } | ||||||||||||||
|
|
||||||||||||||
| /** | ||||||||||||||
|
|
@@ -629,6 +695,10 @@ export const findExecutableInPath = (executable: string): string | null => { | |||||||||||||
| return null; | ||||||||||||||
| }; | ||||||||||||||
|
|
||||||||||||||
| export const getAvailableShells = (): ShellInfo[] => { | ||||||||||||||
| return ShellDetector.getAvailableShells(); | ||||||||||||||
| }; | ||||||||||||||
|
|
||||||||||||||
| // Wrapper for execAsync that includes enhanced PATH | ||||||||||||||
| export const execWithShellPath = async (command: string, options?: { cwd?: string; env?: NodeJS.ProcessEnv }): Promise<{ stdout: string; stderr: string }> => { | ||||||||||||||
| const shellPath = getShellPath(); | ||||||||||||||
|
|
||||||||||||||

There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems like there has been unwanted changes in the file.