home: Add tmux home type. * home/tmux.scm: New file. * doc/tmux.md: New file. * doc/README.md: Add it. Signed-off-by: Julien Lepiller <julien@lepiller.eu>
doc/README.md
| 64 | 64 | ||
| 65 | 65 | * [Bash](doc/bash.md) | |
| 66 | 66 | * [Neovim](doc/neovim.md) | |
| 67 | + | * [Tmux](doc/tmux.md) | |
| 67 | 68 | * [Zsh](doc/zsh.md) | |
| 68 | 69 | ||
| 69 | 70 | ### Reproducible builds |
doc/tmux.md unknown status 1
| 1 | + | Tmux | |
| 2 | + | ==== | |
| 3 | + | ||
| 4 | + | tmux is a terminal multiplexer. It lets you switch easily between | |
| 5 | + | several programs in one terminal, detach them (they keep running in | |
| 6 | + | the background) and reattach them to a different terminal. | |
| 7 | + | ||
| 8 | + | Main Configuration | |
| 9 | + | ------------------ | |
| 10 | + | ||
| 11 | + | Tmux is configured by using the `tmux-home-type` service type. | |
| 12 | + | ||
| 13 | + | **Scheme Procedure**: tmux-home-type | |
| 14 | + | ||
| 15 | + | The type of service that generates configuration files for tmux. Its value | |
| 16 | + | is a tmux-configuration object. | |
| 17 | + | ||
| 18 | + | **Data Type**: tmux-configuration | |
| 19 | + | ||
| 20 | + | Data type that represents the Tmux configuration. This data type has the | |
| 21 | + | following fields: | |
| 22 | + | ||
| 23 | + | * **terminal** (default "screen-256color"): set environment variable | |
| 24 | + | `TERM`. | |
| 25 | + | * **prefix** (default #f): For keys that control tmux itself. if `#f` | |
| 26 | + | use default prefix. | |
| 27 | + | * **mode-keys** (default "vi"): VI or Emacs style shortcuts. | |
| 28 | + | * **escapeTime** (default 500): Time in milliseconds for which tmux | |
| 29 | + | waits after an escape is input. | |
| 30 | + | * **history-limit** (default 2000): Maximum number of lines held in | |
| 31 | + | window history. | |
| 32 | + | * **mouse?** (default #f): Whether to use mouse. | |
| 33 | + | * **clock24?** (default #f): Whether to use 24 hour clock. | |
| 34 | + | * **extra-conf** (default '("")): This is a list of strings and | |
| 35 | + | file-like objects. | |
| 36 | + | ||
| 37 | + | Example Configuration | |
| 38 | + | --------------------- | |
| 39 | + | ||
| 40 | + | ```scheme | |
| 41 | + | (user-home | |
| 42 | + | tmux-home-type | |
| 43 | + | (tmux-configuration | |
| 44 | + | (terminal "xterm-256color") | |
| 45 | + | (prefix "F12") | |
| 46 | + | (mode-keys "emacs") | |
| 47 | + | (escapeTime 700) | |
| 48 | + | (history-limit 5000) | |
| 49 | + | (mouse? #t) | |
| 50 | + | (clock24? #t) | |
| 51 | + | (extra-conf (list "set -g set-titles on\n"))) | |
| 52 | + | ``` |
home/tmux.scm unknown status 1
| 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))))))))))) |