ubuntu - 让 Byobu 在主目录中打开新屏幕

标签 ubuntu tmux byobu

我不知道这是否在最近版本的 byobu 中发生了变化,但现在当我创建一个新屏幕时,新屏幕与我当前的窗口位于同一目录中。起初这并不太烦人,一个简单的“cd ~”就能让我到达我想要的地方。但我一直注意到奇怪的事情。在 gem 安装过程中,如果我创建一个新窗口,我最终会进入安装 gem 的目录(使用 rbenv 时)。

我只是想让这一切停止。如何设置 byobu/tmux 以便它在我的主目录中打开所有新窗口?

我查看了几个文件,但我似乎看不到任何导致此问题的命令(例如错误的“chdir”)。

最佳答案

在 Ubuntu 中,我可以通过将以下行添加到 ${HOME}/.byobu/.tmuxrc 来获得所需的行为:

set-option -g default-path $HOME

这个选项是 tmux 手册页中的文档:

set-option [-agoqsuw] [-t target-session | target-window] option value
              (alias: set)
        Set a window option with -w (equivalent to the set-window-option
        command), a server option with -s, otherwise a session option.

        If -g is specified, the global session or window option is set.
        With -a, and if the option expects a string, value is appended
        to the existing setting.  The -u flag unsets an option, so a session
        inherits the option from the global options.  It is not possible to
        unset a global option.

        The -o flag prevents setting an option that is already set.

        The -q flag suppresses the informational message (as if the quiet
        server option was set).

        Available window options are listed under set-window-option.

        value depends on the option and may be a number, a string, or a flag
        (on, off, or omitted to toggle).

        Available server options are:

        <snip>

        default-path path

        Set the default working directory for new panes.  If empty (the
        default), the working directory is determined from the process running
        in the active pane, from the command line environment or from the
        working directory where the session was created.  Otherwise the same
        options are available as for the -c flag to new-window.

我最初尝试使用 set-option -g default-path ~,但 tmux 似乎不理解该别名。

更新:以上不适用于 byobu 5.92(可能是其他版本)和 tmux 1.9,因为 tmux 已删除 default-path 选项。似乎 byobu 开发人员正在使用它来获得在 CWD 中打开新窗口的行为,而我和发问者希望它默认在 HOME 目录中打开。在 /usr/share/byobu/keybindings/f-keys.tmux 中的新默认绑定(bind)中,我发现了这个:

bind-key -n F2 new-window -c "#{pane_current_path}" \; rename-window "-"
bind-key -n C-F2 display-panes \; split-window -h -c "#{pane_current_path}"
bind-key -n S-F2 display-panes \; split-window -v -c "#{pane_current_path}"

要获得始终使 byobu 在您的主目录中打开新屏幕的所需行为,请将以下内容添加到 ~/.byobu/keybindings.tmux:

bind-key -n F2 new-window -c "$HOME" \; rename-window "-"
bind-key -n C-F2 display-panes \; split-window -h -c "$HOME"
bind-key -n S-F2 display-panes \; split-window -v -c "$HOME"

关于ubuntu - 让 Byobu 在主目录中打开新屏幕,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20713314/

相关文章:

ubuntu - 如何在 Ubuntu 中注册文件关联

terminal - 更改 tmux 保存 session 的位置?

tmux - 我可以在 tmux 中双击选择并复制吗?

byobu 命令的 shell 脚本

python-2.7 - Spyder 不会在 Ubuntu 16.10 上启动

Linux平台: Enlarge video screen size N times

java - 在 UBUNTU 中添加 JAR 类路径

linux - Tmux: Pane 标题 (#T) 报告为 "fg",而不是提供更多信息的内容

tmux - 如何使用 bash 命令在 byobu 中创建 byobu session

centos - 在centos上使用byobu在窗口标题中显示当前路径