Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Aug 1, 2025

This PR adds automatic light/dark mode switching for Ghostty terminal, Neovim editor, and Zellij terminal multiplexer based on the current time of day, providing a more comfortable user experience that adapts to natural lighting patterns across all development tools.

Features

Time-based Theme Switching:

  • Light mode: 7:00 AM - 6:59 PM (tokyonight-day for Neovim, GitHub-Light-High-Contrast for Ghostty, default for Zellij)
  • Dark mode: 7:00 PM - 6:59 AM (tokyonight-night for Neovim, dracula for Ghostty and Zellij)

Ghostty Integration:

  • Automatic theme switching on new shell launches via .bashrc
  • Seamless integration with existing Ghostty shell integration
  • Preserves existing configuration options (window padding, etc.)

Neovim Integration:

  • Uses tokyonight.nvim plugin for both light and dark modes with Tokyo Night Day/Night themes
  • Automatic colorscheme detection on Neovim startup via VimEnter autocmd
  • Fallback logic for environments where scripts aren't available

Zellij Integration:

  • Automatic theme switching on new shell launches via .bashrc
  • Seamless integration with existing Zellij session management
  • Uses default theme for light mode and dracula theme for dark mode

Implementation

Core Scripts

  • bin/theme-mode: Time detection utility that returns current mode and theme names for all tools
  • bin/set-ghostty-theme: Ghostty configuration updater with atomic file operations
  • bin/set-zellij-theme: Zellij configuration updater with atomic file operations

Integration Points

  • .bashrc: Automatic theme switching when launching new shells in Ghostty and Zellij
  • Neovim plugins: Enhanced colorscheme configuration with time-based selection using Tokyo Night themes
  • Neovim autocmds: Automatic theme application on editor startup

Usage Examples

# Check current theme mode
~/.dotfiles/bin/theme-mode                    # Returns: light|dark

# Get theme names for different tools  
~/.dotfiles/bin/theme-mode ghostty-light      # Returns: GitHub-Light-High-Contrast
~/.dotfiles/bin/theme-mode nvim-dark          # Returns: tokyonight-night
~/.dotfiles/bin/theme-mode nvim-light         # Returns: tokyonight-day
~/.dotfiles/bin/theme-mode zellij-light       # Returns: default
~/.dotfiles/bin/theme-mode zellij-dark        # Returns: dracula

# Manually trigger theme switching
~/.dotfiles/bin/set-ghostty-theme
~/.dotfiles/bin/set-zellij-theme

Theme Consistency

The implementation uses modern, popular themes for optimal readability:

  • Light mode: tokyonight-day for Neovim, GitHub-Light-High-Contrast for Ghostty, default for Zellij
  • Dark mode: tokyonight-night for Neovim, dracula for Ghostty and Zellij

Compatibility

  • Portable: Works on both Linux and macOS
  • Non-intrusive: Doesn't modify Alacritty configuration as requested
  • Robust: Includes fallback logic and error handling for all tools
  • Existing workflow: Integrates seamlessly with current dotfiles structure using GNU Stow

The implementation automatically adapts to the user's daily routine, switching to comfortable themes during both daylight and evening hours across all terminal multiplexers and editors for optimal readability and reduced eye strain.


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Co-authored-by: bdossantos <245284+bdossantos@users.noreply.github.com>
Copilot AI changed the title [WIP] Automatic Light/Dark Mode Switch for Ghostty, Bash, and Neovim by Hour Implement automatic light/dark mode switching for Ghostty and Neovim based on time of day Aug 1, 2025
Copilot AI requested a review from bdossantos August 1, 2025 09:43
if mode == "light" then
return "github_light"
else
return "dracula"
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot could you replace Dracula by github_dark_high_contrast ? thx

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done! I've replaced Dracula with github_dark_high_contrast for all Neovim configurations. The changes include:

  • Updated theme detection in autocmds.lua (lines 138 and 149)
  • Updated theme-mode script for nvim-dark output
  • Updated colorscheme plugin configuration to use github_dark_high_contrast
  • Removed Dracula plugin dependency since we now use github-nvim-theme for both light and dark modes
  • Updated lazy.lua fallback colorschemes

Commit: eb70ff6

Copy link
Owner

@bdossantos bdossantos Aug 1, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot Is possible to also switch Zellij theme from dark to light ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes! I've added automatic light/dark mode switching for Zellij theme. The implementation includes:

  • Extended theme-mode script to support zellij-light (returns "default") and zellij-dark (returns "dracula")
  • Created bin/set-zellij-theme script for automatic theme switching
  • Integrated theme switching into .bashrc before Zellij session attachment
  • Uses "default" theme for light mode and "dracula" theme for dark mode

The theme switching now works automatically when starting new shells, just like Ghostty. You can also manually trigger it with ~/.dotfiles/bin/set-zellij-theme.

Commit: 53314ae

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot could you replace github_dark_high_contrast by Tokyo night dark and GitHub light high contrast by Tokyo night light ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done! I've replaced the GitHub themes with Tokyo Night themes for Neovim:

  • github_dark_high_contrasttokyonight-night
  • github_light_high_contrasttokyonight-day

The changes include:

  • Updated colorscheme plugin from github-nvim-theme to tokyonight.nvim
  • Updated theme-mode script to return Tokyo Night theme names
  • Updated autocmds.lua and colorscheme.lua with new theme names
  • Updated lazy.lua fallback colorschemes

All automatic theme switching functionality remains the same, now using Tokyo Night themes.

Commit: e237db7

Co-authored-by: bdossantos <245284+bdossantos@users.noreply.github.com>
Copilot AI changed the title Implement automatic light/dark mode switching for Ghostty and Neovim based on time of day Implement automatic light/dark mode switching for Ghostty and Neovim with GitHub themes Aug 1, 2025
Copilot AI requested a review from bdossantos August 1, 2025 09:51
handle:close()

if mode == "light" then
return "github_light"
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot could you please use github_light_high_contrast ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done! I've updated all references from github_light to github_light_high_contrast throughout the codebase. The changes include:

  • Updated theme-mode script to return the correct theme name
  • Updated Neovim configuration files (colorscheme.lua, autocmds.lua, lazy.lua)
  • Updated README documentation

Commit: 89e38e4

Co-authored-by: bdossantos <245284+bdossantos@users.noreply.github.com>
Copilot AI requested a review from bdossantos August 1, 2025 09:58
@@ -1,2 +1,2 @@
theme = "dracula"
theme = "github-light"
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot replace this line by GitHub-Light-High-Contrast

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done! I've replaced the theme with "GitHub-Light-High-Contrast" in both the Ghostty config file and the theme-mode script to maintain consistency. The change ensures that automatic theme switching will use the correct theme name.

Commit: 34a5e6e

Co-authored-by: bdossantos <245284+bdossantos@users.noreply.github.com>
Co-authored-by: bdossantos <245284+bdossantos@users.noreply.github.com>
Copilot AI changed the title Implement automatic light/dark mode switching for Ghostty and Neovim with GitHub themes Implement automatic light/dark mode switching for Ghostty, Neovim, and Zellij with GitHub themes Aug 1, 2025
Co-authored-by: bdossantos <245284+bdossantos@users.noreply.github.com>
Copilot AI changed the title Implement automatic light/dark mode switching for Ghostty, Neovim, and Zellij with GitHub themes Implement automatic light/dark mode switching for Ghostty, Neovim, and Zellij with Tokyo Night and GitHub themes Aug 1, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants