Skip to main content

tms/
lib.rs

1pub mod cli;
2pub mod configs;
3pub mod dirty_paths;
4pub mod error;
5pub mod keymap;
6pub mod marks;
7pub mod picker;
8pub mod repos;
9pub mod session;
10pub mod tmux;
11
12use configs::Config;
13use std::process;
14
15use crate::{
16    error::{Result, TmsError},
17    picker::{Picker, Preview},
18    tmux::Tmux,
19};
20
21pub fn execute_command(command: &str, args: Vec<String>) -> process::Output {
22    process::Command::new(command)
23        .args(args)
24        .stdin(process::Stdio::inherit())
25        .output()
26        .unwrap_or_else(|_| panic!("Failed to execute command `{command}`"))
27}
28
29pub fn get_single_selection(
30    list: &[String],
31    preview: Option<Preview>,
32    config: &Config,
33    tmux: &Tmux,
34) -> Result<Option<String>> {
35    let mut picker = Picker::new(
36        list,
37        preview,
38        config.shortcuts.as_ref(),
39        config.input_position.unwrap_or_default(),
40        tmux,
41    )
42    .set_colors(config.picker_colors.as_ref());
43
44    picker.run()
45}