Skip to content

Improve theme reset and light / dark customization capabilities #591

Description

@andreihh

Is there an existing issue outlining your improvement?

  • I have searched the existing issues and my improvement has not been raised yet.

What would you like to see added and/or changed?

#500 introduced the @catppuccin_reset option, which would reset most theme options. This is especially useful with the new tmux client-light-theme and client-dark-theme hooks.

However, with the current capabilities, users are not able to override any theme options if they wish to use the new tmux hooks: any user-defined options would be wiped by the @catppuccin_reset instruction.

Proposal: if @catppuccin_reset is enabled, the plugin resets all catppuccin_* and @thm_* options, and nothing else. This allows users to customize options as follows:

set-hook -g client-dark-theme {
  # First, reset all options.
  set -g @catppuccin_reset "true"
  run ~/code/github.com/catppuccin/tmux/catppuccin.tmux

  set -g @catppuccin_flavor "frappe"
  set -g @thm_red "red"
  set -g @catppuccin_host_icon " H "
  # etc.
  run ~/code/github.com/catppuccin/tmux/catppuccin.tmux
}
set-hook -g client-light-theme {
  # First, reset all options.
  set -g @catppuccin_reset "true"
  run ~/code/github.com/catppuccin/tmux/catppuccin.tmux

  set -g @catppuccin_flavor "latte"
  set -g @thm_red "red"
  set -g @catppuccin_host_icon " H "
  # etc.
  run ~/code/github.com/catppuccin/tmux/catppuccin.tmux
}

The plugin entry script could be updated as follows:

#!/usr/bin/env bash

# Set path of script
PLUGIN_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"

if [[ "$(tmux show -gvq @catppuccin_reset)" == 'true' ]]; then
  # Reset all options.
  opts="$(tmux show -gq | cut -d ' ' -f 1 | grep -E '@catppuccin|@thm')"
  for opt in ${opts}; do
    tmux set -Ugq "${opt}"
  done
else
  # Otherwise, load the plugin.
  tmux source "${PLUGIN_DIR}/catppuccin_options_tmux.conf"
  tmux source "${PLUGIN_DIR}/catppuccin_tmux.conf"
fi

This additionally provides a complete plugin reset, so users no longer need to visually inspect tmux to find stale colors or options that need explicit resetting.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions