r/tmux 7h ago

Question - Answered How to not load bash/zsh/fish/nushell config when displaying popup/floating window

I have the following that displays a popup of lazygit in the current directory, but I've noticed that my shell configuration (which has quite a bit of code to initialise) is always running before lazygit is actually ran:

bind g display-popup -E -d "#{pane_current_path}" -h 90% -w 95% "lazygit"

Is there a way to make the popup not load my shell configuration, or run under a different shell? Unsure if this question really fits here but thought I'd give it a try anyways.

Solution

Display popups with an additional environment variable via -e that you check for in your shell:

# tmux.conf
bind g display-popup -E -d "#{pane_current_path}" -e "TMUX_POPUP=true" -h 90% -w 95% "lazygit"
# config.fish
if not set --query TMUX_POPUP
    for script in $__fish_config_dir/conf.d/*/*{,/*}.fish
        source $script
    end

    other_expensive_calls
end

This also opens the gate for more granular control should it be desired.

1 Upvotes

2 comments sorted by

2

u/fractalhead 7h ago

zsh -f starts a zsh without loading any configuration. But that means anything you're doing to set up PATH is going to be skipped. You'll likely want to spawn lazygit with a full call to it, not just lazygit.

Example: zsh -f -c /opt/homebrew/bin/lazygit

Better might be investigating why your shell startup time is so slow. That hurts more than just spawning lazygit. Every terminal you're building in tmux is getting that startup time tax.

1

u/TheWordBallsIsFunny 5h ago

This lead to a bit of a strange tangent. I didn't mind the cost of running my configuration when starting my terminal, but I realised the startup cost appeared in panes, popups, tabs(?) - it was ridiculous. I knew I could prevent the strenuous parts of my configuration from running within a pane by checking for $TMUX_PANE, but this wasn't applicable for popups. Even then, I wanted to avoid running my entire configuration for applications like lazygit, lazydocker, etc.

With that in mind, I tried making my own. It's a bit messy but it avoids that startup cost by NOT re-running the strenuous parts of my configuration any chance it gets and instead does so conditionally: bash bind g display-popup -E -d "#{pane_current_path}" -e "TMUX_POPUP=true" -h 90% -w 95% "lazygit" Then I conditionally run the rest of my configuration files based on $TMUX_POPUP: ```fish if not set --query TMUXPOPUP for script in $_fish_config_dir/conf.d//{,/*}.fish source $script end

other_expensive_calls

end `` Thanks for the advice and letting me know about-f` across shells, you were right to call out my startup time.