fix: create shell once and reuse

This commit is contained in:
Bertrand Chardon 2025-01-25 21:50:58 +01:00
parent 810e32716e
commit d2e51854d8

View File

@ -39,15 +39,16 @@ async fn main() -> Result<()> {
exit(0); exit(0);
} }
television::cli::Command::InitShell { shell } => { television::cli::Command::InitShell { shell } => {
let target_shell = Shell::from(shell);
// the completion scripts for the various shells are templated // the completion scripts for the various shells are templated
// so that it's possible to override the keybindings triggering // so that it's possible to override the keybindings triggering
// shell autocomplete and command history in tv // shell autocomplete and command history in tv
let templated_script = completion_script(Shell::from(shell))?; let templated_script = completion_script(target_shell)?;
let script = templated_script let script = templated_script
.replace( .replace(
"{tv_smart_autocomplete_keybinding}", "{tv_smart_autocomplete_keybinding}",
&ctrl_keybinding( &ctrl_keybinding(
Shell::from(shell), target_shell,
config config
.shell_integration .shell_integration
.get_shell_autocomplete_keybinding_character(), .get_shell_autocomplete_keybinding_character(),
@ -56,7 +57,7 @@ async fn main() -> Result<()> {
.replace( .replace(
"{tv_shell_history_keybinding}", "{tv_shell_history_keybinding}",
&ctrl_keybinding( &ctrl_keybinding(
Shell::from(shell), target_shell,
config config
.shell_integration .shell_integration
.get_command_history_keybinding_character(), .get_command_history_keybinding_character(),