Reputation: 43526
In my tmux config, I have a split window command:
bind C-j split-window -v "tmux list-sessions | sed -E 's/:.*$//' | grep -v \"^\"(tmux display-message -p '#S')\"\\\$\" | fzf --reverse | xargs tmux switch-client -t"
It will run all the commands in a shell session as defined in split-window of tmux manual. However, my shell contains lots of init scripts that are not related to this custom tmux key binding. And they are slow. Can I set an env variable before split-window
start a shell session so I can skip some shell init script?
Upvotes: 2
Views: 959
Reputation: 3361
Note: Updated in that tmux environment is used now.
You could set this variable at the beginning of the command pipe. Your shell init scripts could then check its value and act accordingly like skipping some part of the initialisation.
bind C-j set-environment TMUXSPLIT 1 \; split-window -v "tmux list-sessions | sed -E 's/:.*$//' | grep -v \"^\"(tmux display-message -p '#S')\"\\\$\" | fzf --reverse | xargs tmux switch-client -t"
I assume this is running under Ubuntu which utilizes bash. In your bashrc write something like:
if [ "$TMUXSPLIT" = 1 ]; then
...
fi
Upvotes: 1