Skip to content

Commit

Permalink
fix(plugins): respect default shell when configured in the $SHELL env…
Browse files Browse the repository at this point in the history
… variable (#3296)

* fix(plugins): respect $SHELL alias for default shell

* style(fmt): rustfmt

* fix tests
  • Loading branch information
imsnif committed Apr 24, 2024
1 parent fca7a20 commit 5e58733
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 19 deletions.
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
---
source: zellij-server/src/plugins/./unit/plugin_tests.rs
assertion_line: 4246
assertion_line: 4390
expression: "format!(\"{:#?}\", new_tab_event)"
---
Some(
SpawnTerminal(
Some(
RunCommand(
RunCommand {
command: "",
command: ".",
args: [],
cwd: Some(
"/path/to/my/file.rs",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
---
source: zellij-server/src/plugins/./unit/plugin_tests.rs
assertion_line: 4169
assertion_line: 4312
expression: "format!(\"{:#?}\", new_tab_event)"
---
Some(
SpawnTerminal(
Some(
RunCommand(
RunCommand {
command: "",
command: ".",
args: [],
cwd: Some(
"/path/to/my/file.rs",
Expand Down
33 changes: 18 additions & 15 deletions zellij-server/src/plugins/zellij_exports.rs
Original file line number Diff line number Diff line change
Expand Up @@ -515,11 +515,12 @@ fn open_file_in_place(env: &ForeignFunctionEnv, file_to_open: FileToOpen) {
fn open_terminal(env: &ForeignFunctionEnv, cwd: PathBuf) {
let error_msg = || format!("failed to open file in plugin {}", env.plugin_env.name());
let cwd = env.plugin_env.plugin_cwd.join(cwd);
let mut default_shell = env
.plugin_env
.default_shell
.clone()
.unwrap_or_else(|| TerminalAction::RunCommand(RunCommand::default()));
let mut default_shell = env.plugin_env.default_shell.clone().unwrap_or_else(|| {
TerminalAction::RunCommand(RunCommand {
command: env.plugin_env.path_to_default_shell.clone(),
..Default::default()
})
});
default_shell.change_cwd(cwd);
let run_command_action: Option<RunCommandAction> = match default_shell {
TerminalAction::RunCommand(run_command) => Some(run_command.into()),
Expand All @@ -536,11 +537,12 @@ fn open_terminal_floating(
) {
let error_msg = || format!("failed to open file in plugin {}", env.plugin_env.name());
let cwd = env.plugin_env.plugin_cwd.join(cwd);
let mut default_shell = env
.plugin_env
.default_shell
.clone()
.unwrap_or_else(|| TerminalAction::RunCommand(RunCommand::default()));
let mut default_shell = env.plugin_env.default_shell.clone().unwrap_or_else(|| {
TerminalAction::RunCommand(RunCommand {
command: env.plugin_env.path_to_default_shell.clone(),
..Default::default()
})
});
default_shell.change_cwd(cwd);
let run_command_action: Option<RunCommandAction> = match default_shell {
TerminalAction::RunCommand(run_command) => Some(run_command.into()),
Expand All @@ -553,11 +555,12 @@ fn open_terminal_floating(
fn open_terminal_in_place(env: &ForeignFunctionEnv, cwd: PathBuf) {
let error_msg = || format!("failed to open file in plugin {}", env.plugin_env.name());
let cwd = env.plugin_env.plugin_cwd.join(cwd);
let mut default_shell = env
.plugin_env
.default_shell
.clone()
.unwrap_or_else(|| TerminalAction::RunCommand(RunCommand::default()));
let mut default_shell = env.plugin_env.default_shell.clone().unwrap_or_else(|| {
TerminalAction::RunCommand(RunCommand {
command: env.plugin_env.path_to_default_shell.clone(),
..Default::default()
})
});
default_shell.change_cwd(cwd);
let run_command_action: Option<RunCommandAction> = match default_shell {
TerminalAction::RunCommand(run_command) => Some(run_command.into()),
Expand Down

0 comments on commit 5e58733

Please sign in to comment.