Debian Codegraph @

lib/awful/hotkeys_popup/keys/tmux.lua

raw
1 ---------------------------------------------------------------------------
2 --- tmux hotkeys for awful.hotkeys_widget
3 --
4 -- @author nahsi [email protected]
5 -- @copyright 2017 nahsi
6 -- @submodule awful.hotkeys_popup
7 ---------------------------------------------------------------------------
8
9 local hotkeys_popup = require("awful.hotkeys_popup.widget")
10
11 local tmux = {}
12
13 --- Add rules to match tmux session.
14 --
15 -- For example:
16 --
17 -- tmux.add_rules_for_terminal({ rule = { name = { "tmux" }}})
18 --
19 -- will show tmux hotkeys for any window that has 'tmux' in its title.
20 -- If no rules are provided then tmux hotkeys will be shown always!
21 -- @function add_rules_for_terminal
22 -- @see awful.rules.rules
23 -- @tparam table rule Rules to match a window containing a tmux session.
24 function tmux.add_rules_for_terminal(rule)
25 for group_name, group_data in pairs({
26 ["tmux: sessions"] = rule,
27 ["tmux: windows"] = rule,
28 ["tmux: panes"] = rule,
29 ["tmux: misc"] = rule,
30 }) do
31 hotkeys_popup.add_group_rules(group_name, group_data)
32 end
33 end
34
35 local tmux_keys = {
36 ["tmux: sessions"] = {{
37 modifiers = {},
38 keys = {
39 s = "show all sessions",
40 ['$'] = "rename the current session",
41 ['('] = "move to previous session",
42 [')'] = "move to next session",
43 d = "detach from current session"
44 }
45 }},
46
47 ["tmux: windows"] = {{
48 modifiers = {},
49 keys = {
50 c = "create window",
51 f = "find window",
52 [','] = "rename current window",
53 --['&'] = "close current window",
54 p = "previous window",
55 n = "next window",
56 ['0...9'] = "select window by number"
57 }
58 }},
59
60 ["tmux: panes"] = {{
61 modifiers = {},
62 keys = {
63 [';'] = "toggle last active pane",
64 ['%'] = "split pane vertically",
65 ['"'] = "split pane horizontally",
66 ['{'] = "move the current pane left",
67 ['}'] = "move the current pane right",
68 ['q 0...9'] = "select pane by number",
69 o = "toggle between panes",
70 z = "toggle pane zoom",
71 ['space'] = "toggle between layouts",
72 ['!'] = "convert pane into a window",
73 x = "close current pane"
74 }
75 }},
76
77 ["tmux: misc"] = {{
78 modifiers = {},
79 keys = {
80 [':'] = "enter command mode",
81 ['?'] = "list shortcuts",
82 t = "show clock"
83 }
84 }}
85 }
86
87 hotkeys_popup.add_hotkeys(tmux_keys)
88
89 return tmux
90
91 -- vim: filetype=lua:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:textwidth=80