feat(shell): add Nushell support
This commit is contained in:
@@ -628,6 +628,12 @@ fn build_shell_env_command(shell: &str) -> Vec<String> {
|
|||||||
.unwrap_or("sh");
|
.unwrap_or("sh");
|
||||||
|
|
||||||
match shell_name {
|
match shell_name {
|
||||||
|
"nu" | "nushell" => vec![
|
||||||
|
"-l".to_string(),
|
||||||
|
"-i".to_string(),
|
||||||
|
"-c".to_string(),
|
||||||
|
"echo $\"__PATH__=($env.PATH | str join (char esep))\"; echo $\"__OPENCODE_BINARY__=($env.OPENCODE_BINARY? | default '')\"".to_string(),
|
||||||
|
],
|
||||||
"bash" => vec![
|
"bash" => vec![
|
||||||
"-lic".to_string(),
|
"-lic".to_string(),
|
||||||
"source ~/.bashrc 2>/dev/null; echo \"__PATH__=$PATH\"; echo \"__OPENCODE_BINARY__=$OPENCODE_BINARY\"".to_string(),
|
"source ~/.bashrc 2>/dev/null; echo \"__PATH__=$PATH\"; echo \"__OPENCODE_BINARY__=$OPENCODE_BINARY\"".to_string(),
|
||||||
|
|||||||
@@ -78,8 +78,16 @@ function getLoginShellPath(): string | null {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const shell = process.env.SHELL || '/bin/zsh';
|
const shell = process.env.SHELL || '/bin/zsh';
|
||||||
|
const shellName = path.basename(shell);
|
||||||
|
|
||||||
|
// Nushell requires different flag syntax and PATH access
|
||||||
|
const isNushell = shellName === 'nu' || shellName === 'nushell';
|
||||||
|
const args = isNushell
|
||||||
|
? ['-l', '-i', '-c', '$env.PATH | str join (char esep)']
|
||||||
|
: ['-lic', 'echo -n "$PATH"'];
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const result = spawnSync(shell, ['-lic', 'echo -n "$PATH"'], {
|
const result = spawnSync(shell, args, {
|
||||||
encoding: 'utf8',
|
encoding: 'utf8',
|
||||||
stdio: ['ignore', 'pipe', 'pipe'],
|
stdio: ['ignore', 'pipe', 'pipe'],
|
||||||
});
|
});
|
||||||
@@ -144,7 +152,13 @@ function resolveCliPath(): string | null {
|
|||||||
for (const shellPath of shellCandidates) {
|
for (const shellPath of shellCandidates) {
|
||||||
if (!isExecutable(shellPath)) continue;
|
if (!isExecutable(shellPath)) continue;
|
||||||
try {
|
try {
|
||||||
const result = spawnSync(shellPath, ['-lic', 'command -v opencode'], {
|
const shellName = path.basename(shellPath);
|
||||||
|
const isNushell = shellName === 'nu' || shellName === 'nushell';
|
||||||
|
const args = isNushell
|
||||||
|
? ['-l', '-i', '-c', 'which opencode']
|
||||||
|
: ['-lic', 'command -v opencode'];
|
||||||
|
|
||||||
|
const result = spawnSync(shellPath, args, {
|
||||||
encoding: 'utf8',
|
encoding: 'utf8',
|
||||||
stdio: ['ignore', 'pipe', 'pipe'],
|
stdio: ['ignore', 'pipe', 'pipe'],
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -552,8 +552,16 @@ function getLoginShellPath() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const shell = process.env.SHELL || '/bin/zsh';
|
const shell = process.env.SHELL || '/bin/zsh';
|
||||||
|
const shellName = path.basename(shell);
|
||||||
|
|
||||||
|
// Nushell requires different flag syntax and PATH access
|
||||||
|
const isNushell = shellName === 'nu' || shellName === 'nushell';
|
||||||
|
const args = isNushell
|
||||||
|
? ['-l', '-i', '-c', '$env.PATH | str join (char esep)']
|
||||||
|
: ['-lic', 'echo -n "$PATH"'];
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const result = spawnSync(shell, ['-lic', 'echo -n "$PATH"'], { encoding: 'utf8', stdio: ['ignore', 'pipe', 'pipe'] });
|
const result = spawnSync(shell, args, { encoding: 'utf8', stdio: ['ignore', 'pipe', 'pipe'] });
|
||||||
if (result.status === 0 && typeof result.stdout === 'string') {
|
if (result.status === 0 && typeof result.stdout === 'string') {
|
||||||
const value = result.stdout.trim();
|
const value = result.stdout.trim();
|
||||||
if (value) {
|
if (value) {
|
||||||
|
|||||||
Reference in New Issue
Block a user