import { execOnly, iLoginShell } from '../shell.js';
/** argv that opens a new tmux window running the command in cwd. */
export function tmuxTabArgv(cwd, command) {
    return ['tmux', 'new-window', '-c', cwd, iLoginShell(execOnly(command))];
}
/** argv that splits the current tmux pane, running the command in cwd. */
export function tmuxSplitArgv(cwd, command, direction) {
    const flag = direction === 'right' ? '-h' : '-v';
    return ['tmux', 'split-window', flag, '-c', cwd, iLoginShell(execOnly(command))];
}
export const tmuxBackend = {
    id: 'tmux',
    label: 'tmux',
    isAvailable(ctx) {
        return Boolean(ctx.env.TMUX);
    },
    buildTab(cwd, command) {
        return { argv: tmuxTabArgv(cwd, command) };
    },
    buildSplit(cwd, command, direction) {
        return { argv: tmuxSplitArgv(cwd, command, direction) };
    },
};
