Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions src/Widgets/TerminalView.vala
Original file line number Diff line number Diff line change
Expand Up @@ -195,15 +195,15 @@ public class Terminal.TerminalView : Granite.Bin {

selected_page = tab;

if (program.length == 0) {
/* Set up the virtual terminal */
if (location == "") {
terminal_widget.active_shell ();
} else {
terminal_widget.active_shell (location);
}
/* Set up the virtual terminal */
if (location == "") {
terminal_widget.active_shell ();
} else {
terminal_widget.run_program (program, location);
terminal_widget.active_shell (location);
}

if (program.length > 0) {
terminal_widget.run_program (program);
}

main_window.save_opened_terminals (true, true);
Expand Down
38 changes: 8 additions & 30 deletions src/Widgets/TerminalWidget.vala
Original file line number Diff line number Diff line change
Expand Up @@ -896,37 +896,15 @@ namespace Terminal {
);
}

public void run_program (string _program_string, string? working_directory) {
string[]? program_with_args = null;
this.program_string = _program_string;
try {
Shell.parse_argv (program_string, out program_with_args);
} catch (Error e) {
warning (e.message);
feed ((e.message + "\r\n\r\n").data);
active_shell (working_directory);
return;
}
// Only used when command launched from command lines
// We do not send SIGINT or reset the shell as we know the shell has only
// just been created and we may need to run e.g. `conda` which sets the environment
public void run_program (string program) {
Idle.add (() => {
feed_child ((program + "\n").data);
return Source.REMOVE;
});

this.spawn_async (
Vte.PtyFlags.DEFAULT,
working_directory,
program_with_args,
null,
SpawnFlags.SEARCH_PATH,
null,
-1,
null,
(terminal, pid, error) => {
if (error == null) {
this.child_pid = pid;
} else {
warning (error.message);
feed ((error.message + "\r\n\r\n").data);
active_shell (working_directory);
}
}
);
}

private bool try_get_foreground_pid (out int pid) {
Expand Down