mirror of
https://github.com/LnL7/nix-darwin.git
synced 2025-03-16 13:28:16 +00:00
add basic options for programs.tmux
This commit is contained in:
parent
e968db6224
commit
4a7514f2ea
3 changed files with 92 additions and 12 deletions
17
config.nix
17
config.nix
|
@ -9,6 +9,7 @@ let
|
||||||
[ config
|
[ config
|
||||||
./modules/system.nix
|
./modules/system.nix
|
||||||
./modules/environment.nix
|
./modules/environment.nix
|
||||||
|
./modules/tmux.nix
|
||||||
<nixpkgs/nixos/modules/system/etc/etc.nix>
|
<nixpkgs/nixos/modules/system/etc/etc.nix>
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
|
@ -48,21 +49,15 @@ let
|
||||||
environment.shellAliases.ls = "ls -G";
|
environment.shellAliases.ls = "ls -G";
|
||||||
|
|
||||||
environment.etc."tmux.conf".text = ''
|
environment.etc."tmux.conf".text = ''
|
||||||
set -g default-command "reattach-to-user-namespace -l $SHELL"
|
source-file ${config.system.build.setTmuxOptions}
|
||||||
set -g default-terminal "screen-256color"
|
|
||||||
set -g status-bg black
|
set -g status-bg black
|
||||||
set -g status-fg white
|
set -g status-fg white
|
||||||
|
|
||||||
set -g base-index 1
|
|
||||||
set -g renumber-windows on
|
|
||||||
|
|
||||||
setw -g mode-keys vi
|
|
||||||
|
|
||||||
bind c new-window -c '#{pane_current_path}'
|
|
||||||
bind % split-window -v -c '#{pane_current_path}'
|
|
||||||
bind '"' split-window -h -c '#{pane_current_path}'
|
|
||||||
'';
|
'';
|
||||||
|
|
||||||
|
programs.tmux.enableSensible = true;
|
||||||
|
programs.tmux.enableVim = true;
|
||||||
|
|
||||||
environment.etc."zshrc".text = ''
|
environment.etc."zshrc".text = ''
|
||||||
autoload -U compinit && compinit
|
autoload -U compinit && compinit
|
||||||
autoload -U promptinit && promptinit
|
autoload -U promptinit && promptinit
|
||||||
|
|
|
@ -39,6 +39,7 @@ in {
|
||||||
};
|
};
|
||||||
|
|
||||||
environment.variables = mkOption {
|
environment.variables = mkOption {
|
||||||
|
type = types.attrsOf (types.loeOf types.str);
|
||||||
default = {};
|
default = {};
|
||||||
description = ''
|
description = ''
|
||||||
A set of environment variables used in the global environment.
|
A set of environment variables used in the global environment.
|
||||||
|
@ -47,7 +48,6 @@ in {
|
||||||
strings. The latter is concatenated, interspersed with colon
|
strings. The latter is concatenated, interspersed with colon
|
||||||
characters.
|
characters.
|
||||||
'';
|
'';
|
||||||
type = types.attrsOf (types.loeOf types.str);
|
|
||||||
apply = mapAttrs (n: v: if isList v then concatStringsSep ":" v else v);
|
apply = mapAttrs (n: v: if isList v then concatStringsSep ":" v else v);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
85
modules/tmux.nix
Normal file
85
modules/tmux.nix
Normal file
|
@ -0,0 +1,85 @@
|
||||||
|
{ config, lib, pkgs, ... }:
|
||||||
|
|
||||||
|
with lib;
|
||||||
|
|
||||||
|
let
|
||||||
|
|
||||||
|
inherit (pkgs) stdenv;
|
||||||
|
|
||||||
|
cfg = config.programs.tmux;
|
||||||
|
|
||||||
|
tmuxConfigs =
|
||||||
|
mapAttrsToList (n: v: "${v}") cfg.text;
|
||||||
|
|
||||||
|
in {
|
||||||
|
options = {
|
||||||
|
|
||||||
|
programs.tmux.enableSensible = mkOption {
|
||||||
|
type = types.bool;
|
||||||
|
default = false;
|
||||||
|
example = true;
|
||||||
|
description = ''
|
||||||
|
Enable sensible configuration options.
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
|
||||||
|
programs.tmux.enableVim = mkOption {
|
||||||
|
type = types.bool;
|
||||||
|
default = false;
|
||||||
|
example = true;
|
||||||
|
description = ''
|
||||||
|
Enable vim style keybindings for copy mode, and navigation of panes.
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
|
||||||
|
programs.tmux.text = mkOption {
|
||||||
|
internal = true;
|
||||||
|
type = types.attrsOf types.str;
|
||||||
|
default = {};
|
||||||
|
};
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
config = {
|
||||||
|
|
||||||
|
system.build.setTmuxOptions = pkgs.writeText "set-tmux-options"
|
||||||
|
(concatStringsSep "\n" tmuxConfigs);
|
||||||
|
|
||||||
|
programs.tmux.text.sensible = mkIf cfg.enableSensible (''
|
||||||
|
set -g default-terminal "screen-256color"
|
||||||
|
setw -g aggressive-resize on
|
||||||
|
|
||||||
|
set -g base-index 1
|
||||||
|
set -g renumber-windows on
|
||||||
|
bind 0 set -g status
|
||||||
|
|
||||||
|
set -g status-keys emacs
|
||||||
|
set -s escape-time 0
|
||||||
|
|
||||||
|
bind c new-window -c '#{pane_current_path}'
|
||||||
|
bind % split-window -v -c '#{pane_current_path}'
|
||||||
|
bind '"' split-window -h -c '#{pane_current_path}'
|
||||||
|
|
||||||
|
# TODO: make these interactive
|
||||||
|
bind C new-session
|
||||||
|
bind S switch-client -l
|
||||||
|
|
||||||
|
# set -g status-utf8 on
|
||||||
|
# set -g utf8 on
|
||||||
|
'' + optionalString stdenv.isDarwin ''
|
||||||
|
set -g default-command "reattach-to-user-namespace -l $SHELL"
|
||||||
|
'');
|
||||||
|
|
||||||
|
programs.tmux.text.vim = mkIf cfg.enableVim ''
|
||||||
|
setw -g mode-keys vi
|
||||||
|
|
||||||
|
bind h select-pane -L
|
||||||
|
bind j select-pane -D
|
||||||
|
bind k select-pane -U
|
||||||
|
bind l select-pane -R
|
||||||
|
bind s split-window -v -c '#{pane_current_path}'
|
||||||
|
bind v split-window -h -c '#{pane_current_path}'
|
||||||
|
'';
|
||||||
|
|
||||||
|
};
|
||||||
|
}
|
Loading…
Add table
Reference in a new issue