Make Byobu open new screens in the home directory

I do not know if this has changed in a recent version of byobu, but now when I create a new screen, the new screen is in the same directory as my current window. At first it wasn't too annoying, a simple "cd ~" would take me where I wanted to. But I noticed strange things. During gem installation, if I create a new window, I get into the directory where gem is installed (when using rbenv).

I just want it to stop. How to configure byobu / tmux so that it opens all new windows in my home directory?

I looked through several files, but I do not see any commands (such as errant 'chdir') that could cause this.

+4
source share
1 answer

In Ubuntu, I can get the desired behavior by adding the following line to $ {HOME} /. byobu / .tmuxrc:

set-option -g default-path $HOME

This parameter is a document on the tmux man page:

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.

I tried with at first set-option -g default-path ~, but it looks like tmux does not understand this alias.

Update: the above does not work with byobu 5.92 (possibly other versions) and tmux 1.9, since tmux removed the parameter default-path. It looks like byobu dev used this to get a behavior in which new windows open in CWD, while I and the poll wanted it to be open in the default HOME directory. In the new default bindings in /usr/share/byobu/keybindings/f-keys.tmuxI found this:

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}"

To get the desired behavior, always making byobu open new screens in your home directory, add the following to ~/.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"
+5

All Articles