Last active
September 26, 2024 04:50
-
-
Save Tekunogosu/781ed5d45b95c42aa1f5dd1d15fc7d63 to your computer and use it in GitHub Desktop.
Small cli program to open a new tab in kitty. There are no options here; this was an exercise in rust and optimizations for release builds. The binary is 363k on my system when built.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| [package] | |
| name = "ktab" | |
| version = "0.1.0" | |
| edition = "2021" | |
| [dependencies] | |
| [profile.release] | |
| opt-level = 3 | |
| lto = "fat" | |
| codegen-units = 1 | |
| panic = "abort" | |
| debug = false | |
| strip = "symbols" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| use std::env; | |
| use std::process::Command; | |
| fn main() { | |
| let args: Vec<String> = env::args().collect(); | |
| let args = &args[1..].join(" "); // strip the file name from the list | |
| let mut kitty_command = Command::new("kitty"); | |
| kitty_command | |
| .arg("@launch") | |
| .arg("--type") | |
| .arg("tab") | |
| .arg("--tab-title") | |
| .arg(args); | |
| let process = kitty_command.spawn(); | |
| match process { | |
| Ok(mut child) => match child.wait() { | |
| // Ok(status) => exit(status.code().unwrap()), | |
| Ok(_status) => (), | |
| Err(e) => eprintln!("faild: {e}"), | |
| }, | |
| Err(e) => eprintln!("faild: {e}"), | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment