예제 #1
0
파일: operations.py 프로젝트: LarryKX/Mcx
def paste_to_local():
    uid = current_host().uid
    tmux_cmd("send-keys -t LOCAL -l", " "+uid)
    tmux_cmd("select-window -t LOCAL")
    tmux_send_keys("C-a")
예제 #2
0
파일: operations.py 프로젝트: LarryKX/Mcx
def current_host():
    for l in tmux_cmd("list-windows -F",
                      "#{window_name} #{window_active}").splitlines():
        name, active = l.strip().split()
        if active == "1":
            return Host.get_by_name(name.decode("utf-8"))
예제 #3
0
파일: operations.py 프로젝트: LarryKX/Mcx
def kill_conn(name):
    tmux_cmd("kill-window -t", name.split(":")[0])
    switch_conns()
예제 #4
0
파일: operations.py 프로젝트: LarryKX/Mcx
#!/usr/bin/env python
import os.path

from tmux.selection import list_selection
from tmux.helper import tmux_cmd, tmux_send_keys
from hosts import Host

search_hosts = lambda *argv:[h.name for h in Host.all_hosts(*argv)]
create_conn = lambda name:tmux_cmd("new-window -n %s" % name, "%s new_conn '%s'" % (__file__, name))
list_conns = lambda:[l.decode("utf-8") for l in tmux_cmd("list-windows -F", "#I:#W").splitlines()]
select_conn = lambda name:tmux_cmd("select-window -t %s", name.split(":")[0])

def current_host():
    for l in tmux_cmd("list-windows -F",
                      "#{window_name} #{window_active}").splitlines():
        name, active = l.strip().split()
        if active == "1":
            return Host.get_by_name(name.decode("utf-8"))

def new_conn(name):
    Host.get_by_name(name.decode("utf-8")).connect()

def search_and_list(*argv):
    prefix_cmd = "%s %s" % (__file__, "search_and_list")
    list_selection(prefix_cmd, argv, search_hosts, {"Enter":create_conn})

def clone_conn():
    current_host().connect()

def extern_ftp():
    current_host().ftp()
예제 #5
0
def paste_to_local():
    uid = current_host().uid
    tmux_cmd("send-keys -t LOCAL -l", " " + uid)
    tmux_cmd("select-window -t LOCAL")
    tmux_send_keys("C-a")
예제 #6
0
def kill_conn(name):
    tmux_cmd("kill-window -t", name.split(":")[0])
    switch_conns()
예제 #7
0
def current_host():
    for l in tmux_cmd("list-windows -F",
                      "#{window_name} #{window_active}").splitlines():
        name, active = l.strip().split()
        if active == "1":
            return Host.get_by_name(name.decode("utf-8"))
예제 #8
0
#!/usr/bin/env python
import os.path

from tmux.selection import list_selection
from tmux.helper import tmux_cmd, tmux_send_keys
from hosts import Host

search_hosts = lambda *argv: [h.name for h in Host.all_hosts(*argv)]
create_conn = lambda name: tmux_cmd("new-window -n %s" % name,
                                    "%s new_conn '%s'" % (__file__, name))
list_conns = lambda: [
    l.decode("utf-8")
    for l in tmux_cmd("list-windows -F", "#I:#W").splitlines()
]
select_conn = lambda name: tmux_cmd("select-window -t %s", name.split(":")[0])


def current_host():
    for l in tmux_cmd("list-windows -F",
                      "#{window_name} #{window_active}").splitlines():
        name, active = l.strip().split()
        if active == "1":
            return Host.get_by_name(name.decode("utf-8"))


def new_conn(name):
    Host.get_by_name(name.decode("utf-8")).connect()


def search_and_list(*argv):
    prefix_cmd = "%s %s" % (__file__, "search_and_list")