about summary refs log tree commit diff stats
path: root/core/tmux.html
blob: a2a7d9c9c37df8f6e9d27419f76df0474eb74e82 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
<!DOCTYPE html>
<html dir="ltr" lang="en">
    <head>
        <meta charset='utf-8'>
        <title>6. Tmux</title>
    </head>

    <body>

        <a href="index.html">Systools Index</a>
        <h1 id="tmux">6. Tmux</h1>

        <p>Install tmux, improves cli work efficiency;</p> 

        <pre>
        $ sudo prt-get depinst tmux
        </pre>

        <p>Create skeleton configuration file for users;</p>

        <pre>
        $ sudo vim /etc/skel/.tumx.conf
        </pre>

        <pre>
        set -g default-terminal "screen-256color"

        set-window-option -g mode-keys vi

        # Vim style
        # copy tmux's selection buffer into the primary X selection with PREFIX+CTRL+Y
        bind-key u run "tmux save-buffer - | xsel -ib"
        # copy primary X selection into tmux's selection buffer with PREFIX+CTRL+P
        bind-key e run "xsel -o | tmux load-buffer -"

        bind-key -t vi-copy 'v' begin-selection
        bind-key -t vi-copy 'y' copy-selection

        set-option -g set-titles on
        set-option -g set-titles-string '#S> #I.#P #W'

        set -g visual-activity on
        set -g monitor-activity on
        set -g visual-bell on
        set -g bell-action any

        ## Join windows: <prefix> s, <prefix> j
        bind-key j command-prompt -p "join pane from:"  "join-pane -s '%%'"
        bind-key s command-prompt -p "send pane to:"  "join-pane -t '%%'"
        </pre>

        <p>Copy to your current home and start tmux;</p>

        <pre>
        $ cp /etc/skel/.tmux.conf ~/
        $ tmux
        </pre>

        <p>Get help;</p>

        <pre>
        ctrl + b ?
        </pre>

        <pre>
        key = bind-key (default ctrl + b)

        Window
        key	c   new window
        key	" 	split-window
        key	n	next window
        key	p	previous window

        Panes
        key	; 	last-pane
        key	space	next-layout
        key	!	break-pane
        key	{	swap pane
        key	}	swap pane
        </pre>

        <h2 id="cpypst">6.1. Copy paste</h2>

        <p>This instructions are valid if tmux.conf file discribed 
        in this document is used;</p>

        <pre>
        1) enter copy mode using Control+b [
        2) navigate to beginning of text, you want to select and hit v
        3) move around using arrow keys to select region
        4) when you reach end of region simply hit y to copy the region
        5) now Control+b ] will paste the selection
        </pre> 

        <p>Paste in X with xsel;</p>

        <pre>
        6) update buffer of xsel using Control+b u
        <pre>

        <p>Copy from X with xsel;</p>

        <pre>
        0) update tmux buffer Control+b e
        </pre>

        <p>Before pasting on vim, set paste mode and then set nopaste.</p>

        <a href="index.html">Systools Index</a>
        <p>
        This is part of the SysDoc Manual.
        Copyright (C) 2016
        Silvino Silva.
        See the file <a href="../fdl-1.3-standalone.html">Gnu Free Documentation License</a>
        for copying conditions.</p>

    </body>
</html>
span>) { gchar* xdg_config = _files_get_xdg_config_home(); gchar* xdg_data = _files_get_xdg_data_home(); GString* themes_dir = g_string_new(xdg_config); g_string_append(themes_dir, "/profanity/themes"); GString* icons_dir = g_string_new(xdg_config); g_string_append(icons_dir, "/profanity/icons"); GString* chatlogs_dir = g_string_new(xdg_data); g_string_append(chatlogs_dir, "/profanity/chatlogs"); GString* logs_dir = g_string_new(xdg_data); g_string_append(logs_dir, "/profanity/logs"); GString* plugins_dir = g_string_new(xdg_data); g_string_append(plugins_dir, "/profanity/plugins"); if (!mkdir_recursive(themes_dir->str)) { log_error("Error while creating directory %s", themes_dir->str); } if (!mkdir_recursive(icons_dir->str)) { log_error("Error while creating directory %s", icons_dir->str); } if (!mkdir_recursive(chatlogs_dir->str)) { log_error("Error while creating directory %s", chatlogs_dir->str); } if (!mkdir_recursive(logs_dir->str)) { log_error("Error while creating directory %s", logs_dir->str); } if (!mkdir_recursive(plugins_dir->str)) { log_error("Error while creating directory %s", plugins_dir->str); } g_string_free(themes_dir, TRUE); g_string_free(icons_dir, TRUE); g_string_free(chatlogs_dir, TRUE); g_string_free(logs_dir, TRUE); g_string_free(plugins_dir, TRUE); g_free(xdg_config); g_free(xdg_data); } gchar* files_get_inputrc_file(void) { gchar* xdg_config = _files_get_xdg_config_home(); GString* inputrc_file = g_string_new(xdg_config); g_free(xdg_config); g_string_append(inputrc_file, "/profanity/inputrc"); if (g_file_test(inputrc_file->str, G_FILE_TEST_IS_REGULAR)) { gchar* result = g_strdup(inputrc_file->str); g_string_free(inputrc_file, TRUE); return result; } g_string_free(inputrc_file, TRUE); return NULL; } char* files_get_log_file(const char* const log_file) { gchar* xdg_data = _files_get_xdg_data_home(); GString* logfile; if (log_file) { gchar *log_path = g_path_get_dirname(log_file); if (!mkdir_recursive(log_path)) { log_error("Error while creating directory %s", log_path); } g_free(log_path); logfile = g_string_new(log_file); } else { logfile = g_string_new(xdg_data); g_string_append(logfile, "/profanity/logs/profanity"); if (!prefs_get_boolean(PREF_LOG_SHARED)) { g_string_append_printf(logfile, "%d", getpid()); } g_string_append(logfile, ".log"); } char* result = g_strdup(logfile->str); free(xdg_data); g_string_free(logfile, TRUE); return result; } gchar* files_get_config_path(const char* const config_base) { gchar* xdg_config = _files_get_xdg_config_home(); GString* file_str = g_string_new(xdg_config); g_string_append(file_str, "/profanity/"); g_string_append(file_str, config_base); gchar* result = g_strdup(file_str->str); g_free(xdg_config); g_string_free(file_str, TRUE); return result; } gchar* files_get_data_path(const char* const data_base) { gchar* xdg_data = _files_get_xdg_data_home(); GString* file_str = g_string_new(xdg_data); g_string_append(file_str, "/profanity/"); g_string_append(file_str, data_base); gchar* result = g_strdup(file_str->str); g_free(xdg_data); g_string_free(file_str, TRUE); return result; } gchar* files_get_account_data_path(const char* const specific_dir, const char* const jid) { gchar* data_dir = files_get_data_path(specific_dir); GString* result_dir = g_string_new(data_dir); g_free(data_dir); gchar* account_dir = str_replace(jid, "@", "_at_"); g_string_append(result_dir, "/"); g_string_append(result_dir, account_dir); g_free(account_dir); gchar* result = g_strdup(result_dir->str); g_string_free(result_dir, TRUE); return result; } static char* _files_get_xdg_config_home(void) { gchar* xdg_config_home_env = getenv("XDG_CONFIG_HOME"); gchar* xdg_config_home = NULL; if (xdg_config_home_env) { xdg_config_home = strdup(xdg_config_home_env); g_strstrip(xdg_config_home); } if (xdg_config_home && (strcmp(xdg_config_home, "") != 0)) { return xdg_config_home; } else { GString* default_path = g_string_new(getenv("HOME")); g_string_append(default_path, "/.config"); char* result = strdup(default_path->str); g_string_free(default_path, TRUE); return result; } } static char* _files_get_xdg_data_home(void) { gchar* xdg_data_home_env = getenv("XDG_DATA_HOME"); gchar* xdg_data_home = NULL; if (xdg_data_home_env) { xdg_data_home = strdup(xdg_data_home_env); g_strstrip(xdg_data_home); } if (xdg_data_home && (strcmp(xdg_data_home, "") != 0)) { return xdg_data_home; } else { GString* default_path = g_string_new(getenv("HOME")); g_string_append(default_path, "/.local/share"); gchar* result = strdup(default_path->str); g_string_free(default_path, TRUE); return result; } }