home: zsh: refactor tmux auto-launch configuration

Introduce an actual option for this behaviour.
This commit is contained in:
Bruno BELANYI 2023-02-22 16:04:20 +00:00
parent 0bbf522c03
commit 34c13b077f

View file

@ -5,6 +5,10 @@ in
{ {
options.my.home.zsh = with lib; { options.my.home.zsh = with lib; {
enable = my.mkDisableOption "zsh configuration"; enable = my.mkDisableOption "zsh configuration";
launchTmux = mkEnableOption "auto launch tmux at shell start" // {
default = config.my.home.tmux.enable;
};
}; };
config = lib.mkIf cfg.enable { config = lib.mkIf cfg.enable {
@ -44,14 +48,16 @@ in
defaultKeymap = "emacs"; defaultKeymap = "emacs";
# Make those happen early to avoid doing double the work # Make those happen early to avoid doing double the work
initExtraFirst = initExtraFirst = ''
lib.optionalString config.my.home.tmux.enable '' ${
lib.optionalString cfg.launchTmux ''
# Launch tmux unless already inside one # Launch tmux unless already inside one
if [ -z "$TMUX" ]; then if [ -z "$TMUX" ]; then
exec tmux new-session exec tmux new-session
fi fi
'' ''
; }
'';
initExtra = '' initExtra = ''
source ${./completion-styles.zsh} source ${./completion-styles.zsh}