tmux.scm
1 | ;;; Guix Home Manager. |
2 | ;;; |
3 | ;;; Copyright © 2020 Z572 <873216071@qq.com> |
4 | ;;; |
5 | ;;; This program is free software: you can redistribute it and/or modify |
6 | ;;; it under the terms of the GNU General Public License as published by |
7 | ;;; the Free Software Foundation, either version 3 of the License, or |
8 | ;;; (at your option) any later version. |
9 | ;;; |
10 | ;;; This program is distributed in the hope that it will be useful, |
11 | ;;; but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 | ;;; GNU General Public License for more details. |
14 | ;;; |
15 | ;;; You should have received a copy of the GNU General Public License |
16 | ;;; along with this program. If not, see <http://www.gnu.org/licenses/>. |
17 | |
18 | (define-module (home tmux) |
19 | #:use-module (guix build utils) |
20 | #:use-module (guix gexp) |
21 | #:use-module (guix records) |
22 | #:use-module (ice-9 match) |
23 | #:use-module (home) |
24 | #:export (tmux-configuration |
25 | tmux-configuration-terminal |
26 | tmux-configuration-prefix |
27 | tmux-configuration-mode-keys |
28 | tmux-configuration-escapeTime |
29 | tmux-configuration-history-limit |
30 | tmux-configuration-mouse? |
31 | tmux-configuration-clock24? |
32 | tmux-configuration-extra-conf |
33 | tmux-home-type)) |
34 | |
35 | (define-record-type* <tmux-configuration> |
36 | tmux-configuration make-tmux-configuration |
37 | tmux-configuration? |
38 | (terminal tmux-configuration-terminal |
39 | (default "screen-256color")) |
40 | (prefix tmux-configuration-prefix |
41 | (default #f)) |
42 | (mode-keys tmux-configuration-mode-keys |
43 | (default "vi")) |
44 | (escapeTime tmux-configuration-escapeTime |
45 | (default 500)) |
46 | (history-limit tmux-configuration-history-limit |
47 | (default 2000)) |
48 | (mouse? tmux-configuration-mouse? |
49 | (default #f)) |
50 | (clock24? tmux-configuration-clock24? |
51 | (default #f)) |
52 | (extra-conf tmux-configuration-extra-conf |
53 | (default '("")))) |
54 | |
55 | (define tmux-home-type |
56 | (home-type |
57 | (name 'tmux) |
58 | (extensions |
59 | (list |
60 | (home-extension |
61 | (target root-home-type) |
62 | (compute |
63 | (match-lambda |
64 | (($ <tmux-configuration> |
65 | terminal |
66 | prefix |
67 | mode-keys |
68 | escapeTime |
69 | history-limit |
70 | mouse? |
71 | clock24? |
72 | extra-conf) |
73 | (let ((tmux.conf |
74 | (apply mixed-text-file "tmux.conf" |
75 | (cons* (format #f " |
76 | ~{setw -g ~a ~S\n~} |
77 | ~{set -g ~a ~S\n~} |
78 | ~a |
79 | " |
80 | `("clock-mode-style" |
81 | ,(if clock24? "24" "12")) |
82 | `("escape-time" ,escapeTime |
83 | "history-limit" ,history-limit |
84 | "default-terminal" ,terminal |
85 | "status-keys" ,mode-keys |
86 | "mode-keys" ,mode-keys |
87 | "mouse" ,(if mouse? "on" "off")) |
88 | (if (eq? #f prefix) |
89 | "" |
90 | (string-append |
91 | "unbind C-b\n" |
92 | "set -g prefix " prefix))) |
93 | extra-conf)))) |
94 | `((".tmux.conf" ,tmux.conf))))))))))) |
95 |