def list_selection(prefix, argv, list_func, callback): prefix_cmd = prefix + " %s" if argv: if argv[0] == "-s": res = list_func(*argv[1:]) list_show(res) tmux_cmd("copy-mode") set_bindings(prefix_cmd, callback.keys()) tmux_send_keys("M-R C-a C-Space C-e") raw_input() elif argv[0] == "-c": with_selection(callback[argv[1]], callback.keys()) elif argv[0] == "-k": if argv[1] == "Up": jump_prev() elif argv[1] == "Down": jump_next() elif argv[1] == "Escape": tmux_send_keys("Enter") else: start_list_selection(prefix_cmd, argv) else: start_list_selection(prefix_cmd, argv)
def jump_prev(): tmux_send_keys("C-g Up C-a C-Space C-e")
def with_selection(func, keys): tmux_send_keys("Enter") selection = raw_input() unset_bindings(keys) func(selection)
def jump_next(): tmux_send_keys("C-g Down C-a C-Space C-e")