use libc::system;
use std::ffi::CString;

static TMUX_NAME: &'static str = "tmux";

fn call(command: String) {
    let system_call = CString::new(format!("{} {}", TMUX_NAME, command)).unwrap();
    unsafe { system(system_call.as_ptr()); };
}

pub fn open(session_name: String) {
    let open_command = format!("new -s {} -n {}", session_name, "hello");
    call(open_command);
}

static SELECT_LAYOUT: &'static str = "select-layout";
pub fn select_layout(window: String, layout: String) {
    let command = format!("{} -t {} {}", SELECT_LAYOUT, window, layout);
    call(command);
}

use libc::system;
use std::ffi::CString;

static TMUX_NAME: &'static str = "tmux";
static NEW_SESSION: &'static str = "new -s";

pub fn open(session_name: String) {
    let system_call = CString::new(format!("{} {} {}", TMUX_NAME, NEW_SESSION, session_name)).unwrap();
    unsafe { system(system_call.as_ptr()); };
}

--- 
+++ 
@@ -2,9 +2,19 @@
 use std::ffi::CString;
 
 static TMUX_NAME: &'static str = "tmux";
-static NEW_SESSION: &'static str = "new -s";
+
+fn call(command: String) {
+    let system_call = CString::new(format!("{} {}", TMUX_NAME, command)).unwrap();
+    unsafe { system(system_call.as_ptr()); };
+}
 
 pub fn open(session_name: String) {
-    let system_call = CString::new(format!("{} {} {}", TMUX_NAME, NEW_SESSION, session_name)).unwrap();
-    unsafe { system(system_call.as_ptr()); };
+    let open_command = format!("new -s {} -n {}", session_name, "hello");
+    call(open_command);
 }
+
+static SELECT_LAYOUT: &'static str = "select-layout";
+pub fn select_layout(window: String, layout: String) {
+    let command = format!("{} -t {} {}", SELECT_LAYOUT, window, layout);
+    call(command);
+}
Send all methods through a common call interface.

Here we could consider logging if we want. It also only requires creating a cstring in one place.
