{ inputs, config, pkgs, ... }:

let
tmux-themepack = pkgs.tmuxPlugins.mkTmuxPlugin {
    pluginName = "tmux-themepack";
    rtpFilePath = "themepack.tmux";
    version = "unstable-2019-12-22";
    src = pkgs.fetchFromGitHub {
        owner = "jimeh";
        repo = "tmux-themepack";
        rev = "7c59902f64dcd7ea356e891274b21144d1ea5948";
        sha256 = "sha256-c5EGBrKcrqHWTKpCEhxYfxPeERFrbTuDfcQhsUAbic4=";
    };
  };

in
{
    programs.tmux = {
        shell = "${pkgs.zsh}/bin/zsh";
        terminal = "screen-256color";
        enable = true;
        clock24 = true;
        shortcut = "a";
        escapeTime = 0;
        newSession = true;
        mouse = true;
        keyMode = "vi";
        plugins = [
            pkgs.tmuxPlugins.vim-tmux-navigator
            pkgs.tmuxPlugins.better-mouse-mode
            pkgs.tmuxPlugins.yank
            {
                plugin = tmux-themepack;
                extraConfig = ''
                    set -g @themepack "powerline/double/blue"
                    set-window-option -g status-left " #S "
                    set-window-option -g status-right " #{prefix_highlight} \"#(hostname)\" %H:%M %d-%b-%y "
                    set-window-option -g window-status-format " #I: #W "
                    set-window-option -g window-status-current-format " #I: #W "
                '';

            }
        ];
        extraConfig = ''
            set-window-option -g mode-keys vi
            bind-key -T copy-mode-vi 'v' send -X begin-selection
            bind-key -T copy-mode-vi 'y' send -X copy-selection

            bind | split-window -h -c "#{pane_current_path}"
            bind - split-window -v -c "#{pane_current_path}"
            bind c new-window -c "#{pane_current_path}"
            unbind '"'
            unbind %

            set-option -g xterm-keys on
        '';
    };
}