use anyhow::Result;
pub fn run(shell: &str) -> Result<()> {
match shell {
"zsh" | "bash" => print_posix_init(),
"fish" => print_fish_init(),
_ => {
eprintln!("lowfat: unsupported shell: {shell} (supported: bash, zsh, fish)");
}
}
Ok(())
}
fn print_posix_init() {
let commands = [
"git", "docker", "cargo", "go", "npm", "yarn", "pnpm", "pip", "uv",
"pytest", "kubectl", "ls", "curl", "wget",
];
println!("# lowfat shell init — auto-wrap commands for LLM token savings");
println!("# Usage: eval \"$(lowfat shell-init zsh)\"");
println!();
println!("if [[ \"$CLAUDECODE\" == \"1\" ]] || [[ -n \"$CODEX_ENV\" ]] || [[ \"$RUNF_AUTO\" == \"1\" ]]; then");
for cmd in &commands {
println!(" {cmd}() {{ command lowfat \"${{FUNCNAME[0]:-{cmd}}}\" \"$@\"; }}");
}
println!("fi");
println!();
println!("if [[ \"${{RUNF_SESSION:-1}}\" == \"1\" ]]; then");
println!(" _lowfat_session_exit() {{");
println!(" command lowfat status 2>/dev/null || true");
println!(" }}");
println!(" trap '_lowfat_session_exit' EXIT");
println!("fi");
}
fn print_fish_init() {
let commands = [
"git", "docker", "cargo", "go", "npm", "yarn", "pnpm", "pip", "uv",
"pytest", "kubectl", "ls", "curl", "wget",
];
println!("# lowfat shell init for fish");
println!();
println!("if test \"$CLAUDECODE\" = 1; or test -n \"$CODEX_ENV\"; or test \"$RUNF_AUTO\" = 1");
for cmd in &commands {
println!(" function {cmd}; command lowfat {cmd} $argv; end");
}
println!("end");
}