使用 nix 定义的 tmux 插件会导致 127 个错误

问题描述 投票:0回答:1

概述

我正在尝试在 macOS 上使用 nix 和 home-manager 设置 tmux。

但是,每当我刷新 tmux 配置时,都会收到以下错误:

'/nix/store/6iq9z3wnacxqhja3r93b7lsdl1kvcp11-tmuxplugin-sensible-unstable-2017-09-05/share/tmux-plugins/sensible/sensible.tmux' returned 127                                                                                                                            [0/0]
'/nix/store/6iq9z3wnacxqhja3r93b7lsdl1kvcp11-tmuxplugin-sensible-unstable-2017-09-05/share/tmux-plugins/sensible/sensible.tmux' returned 127
'/nix/store/8cqfwlqfxp21fwbcvl8dyyahdm4klmxj-tmuxplugin-catppuccin-unstable-2024-05-15/share/tmux-plugins/catppuccin/catppuccin.tmux' returned 127
'/nix/store/87czlf8i2q2bzk1xikhx20d80g9kpdi9-tmuxplugin-resurrect-unstable-2022-05-01/share/tmux-plugins/resurrect/resurrect.tmux' returned 127
'/nix/store/aqs7gq94wd4ldbbsnrrm232jifbywwjy-tmuxplugin-continuum-unstable-2022-01-25/share/tmux-plugins/continuum/continuum.tmux' returned 127
'/nix/store/ixmqzdn5yck23fi1d824a04mvxkb7jk6-tmuxplugin-yank-unstable-2021-06-20/share/tmux-plugins/yank/yank.tmux' returned 127

调试

我查看了生成的

tmux.conf
文件,发现有几个
run-shell
命令,如下所示:

# ============================================= #
# Start with defaults from the Sensible plugin  #
# --------------------------------------------- #
run-shell /nix/store/6iq9z3wnacxqhja3r93b7lsdl1kvcp11-tmuxplugin-sensible-unstable-2017-09-05/share/tmux-plugins/sensible/sensible.tmux
# ============================================= #

这些

run-shell
命令与 tmux 日志中存在 127 个错误的程序相匹配。

根据这个GitHub问题,127错误意味着找不到程序。然而,当我明确尝试运行这些程序或

cat
它们时,我看到了它们。

所以这告诉我,由于某种原因我可以手动运行生成的程序,但 tmux 不能。

我找到了这篇文章:tmux run Fish shell 函数返回错误 127。因此,我还尝试使用

.tmux
运行生成的
/bin/sh
程序,并且可以在那里成功运行它们。

文件

这是我的 tmux 的整个 nix 配置。

{ pkgs, ... }:
{
  programs.tmux = {
    enable = true;
    terminal = "tmux-256color";
    historyLimit = 100000;
    shell = "${pkgs.zsh}/bin/zsh";
    plugins = with pkgs;
      [
        tmuxPlugins.sensible
        {
          plugin = tmuxPlugins.catppuccin;
          extraConfig = ''
            set-option -sa terminal-features "screen-256color,:RGB"
            set -g @catppuccin_flavour 'mocha'
            set -g @catppuccin_status_modules_right "session"
            set -g @catppuccin_status_modules_left " "
            set -g @catppuccin_status_fill "icon"
            set -g @catppuccin_window_number_position "right"
            set -g @catppuccin_window_left_separator ""
            set -g @catppuccin_window_right_separator " "
            set -g @catppuccin_window_middle_separator " █"
            set -g @catppuccin_window_number_position "right"
            set -g @catppuccin_window_default_fill "none"
            set -g @catppuccin_window_default_text "#W"
            set -g @catppuccin_window_current_fill "number"
            set -g @catppuccin_window_current_text "#W"
            set -g @catppuccin_pane_active_border_style "fg=#313244"
            set -g status-bg "#11111b" # also duplicated at the bottom of the file
          '';
        }
        {
          plugin = tmuxPlugins.resurrect;
          extraConfig = ''
            set -g @resurrect-strategy-nvim 'session'
            set -g @resurrect-capture-pane-contents 'on'
          '';
        }
        {
          plugin = tmuxPlugins.continuum;
          extraConfig = ''
            set -g @continuum-restore 'on'
            set -g @continuum-boot 'on'
            set -g @continuum-boot-options 'alacritty,fullscreen'
            set -g @continuum-save-interval '5' # save every 5 minutes
          '';
        }
        tmuxPlugins.yank
      ];
    extraConfig = ''
      #
      # Keyboard shortcuts
      #

      # set the leader to control-a
      set -g prefix C-a
      unbind C-b
      bind-key C-a send-prefix

      # use \ to create horizontal panes
      unbind %
      bind '\' split-window -h

      # use - to split the window horizontally
      unbind '"'
      bind - split-window -v

      # resize panes
      bind -r j resize-pane -D 5
      bind -r k resize-pane -U 5
      bind -r l resize-pane -R 5
      bind -r h resize-pane -L 5

      # Smart pane switching with awareness of Vim splits.
      # See: https://github.com/christoomey/vim-tmux-navigator
      is_vim="ps -o state= -o comm= -t '#{pane_tty}' \
          | grep -iqE '^[^TXZ ]+ +(\\S+\\/)?g?(view|l?n?vim?x?|fzf)(diff)?$'"
      bind-key -n 'C-h' if-shell "$is_vim" 'send-keys C-h'  'select-pane -L'
      bind-key -n 'C-j' if-shell "$is_vim" 'send-keys C-j'  'select-pane -D'
      bind-key -n 'C-k' if-shell "$is_vim" 'send-keys C-k'  'select-pane -U'
      bind-key -n 'C-l' if-shell "$is_vim" 'send-keys C-l'  'select-pane -R'
      tmux_version='$(tmux -V | sed -En "s/^tmux ([0-9]+(.[0-9]+)?).*/\1/p")'
      if-shell -b '[ "$(echo "$tmux_version < 3.0" | bc)" = 1 ]' \
          "bind-key -n 'C-\\' if-shell \"$is_vim\" 'send-keys C-\\'  'select-pane -l'"
      if-shell -b '[ "$(echo "$tmux_version >= 3.0" | bc)" = 1 ]' \
          "bind-key -n 'C-\\' if-shell \"$is_vim\" 'send-keys C-\\\\'  'select-pane -l'"

      bind-key -T copy-mode-vi 'C-h' select-pane -L
      bind-key -T copy-mode-vi 'C-j' select-pane -D
      bind-key -T copy-mode-vi 'C-k' select-pane -U
      bind-key -T copy-mode-vi 'C-l' select-pane -R
      bind-key -T copy-mode-vi 'C-\' select-pane -l

      # set visual styling
      set-option -sa terminal-features "screen-256color,:RGB"
      set-option -g status-position top

      # easily refresh tmux configuration
      unbind r
      bind r source-file ~/.config/tmux/tmux.conf

      set -g status-bg "#11111b"
    '';
  };
}
tmux nix
1个回答
0
投票

听起来像是您用来启动 tmux 会话的 shell 环境的问题。如果您使用其他程序(例如 kitty)自动启动 tmux 会话,请使用交互式登录 shell 来启动它。类似的东西

${pkgs.zsh}/bin/zsh -l -i -c "${pkgs.tmux}/bin/tmux new-session -s local-tmux-session"
© www.soinside.com 2019 - 2024. All rights reserved.