tmux to home-manager #2

Closed
opened 2023-07-17 21:31:31 +00:00 by credmp · 1 comment
credmp commented 2023-07-17 21:31:31 +00:00 (Migrated from github.com)

In homemanager the plugins can be dealt with by nix. See also:

https://github.com/srid/nixos-config/blob/master/home/tmux.nix

In homemanager the plugins can be dealt with by nix. See also: https://github.com/srid/nixos-config/blob/master/home/tmux.nix
credmp commented 2023-07-17 21:32:15 +00:00 (Migrated from github.com)
{ pkgs, config, ... }:
{
  programs.tmux = {
    enable = true;
    shortcut = "a";
    # aggressiveResize = true; -- Disabled to be iTerm-friendly
    baseIndex = 1;
    newSession = true;
    # Stop tmux+escape craziness.
    escapeTime = 0;
    # Force tmux to use /tmp for sockets (WSL2 compat)
    secureSocket = false;

    plugins = with pkgs; [
      tmuxPlugins.better-mouse-mode
    ];

    extraConfig = ''
      # https://old.reddit.com/r/tmux/comments/mesrci/tmux_2_doesnt_seem_to_use_256_colors/
      set -g default-terminal "xterm-256color"
      set -ga terminal-overrides ",*256col*:Tc"
      set -ga terminal-overrides '*:Ss=\E[%p1%d q:Se=\E[ q'
      set-environment -g COLORTERM "truecolor"

      # Mouse works as expected
      set-option -g mouse on
      # easy-to-remember split pane commands
      bind | split-window -h -c "#{pane_current_path}"
      bind - split-window -v -c "#{pane_current_path}"
      bind c new-window -c "#{pane_current_path}"
    '';
  };

  programs.tmate = {
    enable = true;
    # FIXME: This causes tmate to hang.
    # extraConfig = config.xdg.configFile."tmux/tmux.conf".text;
  };

  home.packages = [
    # Open tmux for current project.
    (pkgs.writeShellApplication {
      name = "pux";
      runtimeInputs = [ pkgs.tmux ];
      text = ''
        PRJ="''$(zoxide query -i)"
        echo "Launching tmux for ''$PRJ"
        set -x
        cd "''$PRJ" && \
          exec tmux -S "''$PRJ".tmux attach
      '';
    })
  ];
}
```nix { pkgs, config, ... }: { programs.tmux = { enable = true; shortcut = "a"; # aggressiveResize = true; -- Disabled to be iTerm-friendly baseIndex = 1; newSession = true; # Stop tmux+escape craziness. escapeTime = 0; # Force tmux to use /tmp for sockets (WSL2 compat) secureSocket = false; plugins = with pkgs; [ tmuxPlugins.better-mouse-mode ]; extraConfig = '' # https://old.reddit.com/r/tmux/comments/mesrci/tmux_2_doesnt_seem_to_use_256_colors/ set -g default-terminal "xterm-256color" set -ga terminal-overrides ",*256col*:Tc" set -ga terminal-overrides '*:Ss=\E[%p1%d q:Se=\E[ q' set-environment -g COLORTERM "truecolor" # Mouse works as expected set-option -g mouse on # easy-to-remember split pane commands bind | split-window -h -c "#{pane_current_path}" bind - split-window -v -c "#{pane_current_path}" bind c new-window -c "#{pane_current_path}" ''; }; programs.tmate = { enable = true; # FIXME: This causes tmate to hang. # extraConfig = config.xdg.configFile."tmux/tmux.conf".text; }; home.packages = [ # Open tmux for current project. (pkgs.writeShellApplication { name = "pux"; runtimeInputs = [ pkgs.tmux ]; text = '' PRJ="''$(zoxide query -i)" echo "Launching tmux for ''$PRJ" set -x cd "''$PRJ" && \ exec tmux -S "''$PRJ".tmux attach ''; }) ]; } ```
Sign in to join this conversation.
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
arjen/nixos-dotfiles#2
No description provided.