Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add custom titles & colours #1

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

sgoudham
Copy link

@sgoudham sgoudham commented May 19, 2023

Hiya 👋

This PR introduces 2 new changes to the behaviour of the plugin, which can be optionally configured.

  1. The default colours/rainbow of the tabs can be overridden by the user
  2. The titles can be overridden by the user (and additionally, the colours of specific tabs can be overridden based on arbitrary conditions defined by the user)

Code quality and semantics aside, I'd like to clarify the intended behaviour of the new functionality with some examples below. If you agree, I can update the documentation with some examples and switch the status of this PR to ready for review.

Examples

Case 1: Overriding Default Colours

Config:

tabs = {
	colours = {
		2,
		3,
		"#FFFFFF"
	}
}

Intended Behaviour:
The above config would result in all tabs cycling through 3 colours that the user has defined. The first 2 colours are indices to be retrieved from Wezterm's palette via ANSI colours. The 3rd is a hex colour and should be directly passed to the configuration.

Case 2: Overriding Colours Based On Tab Title

Config:

tabs = {
	overrides = {
		nvim = {
			background = 4
		},
		ssh = {
			foreground = "#1e1e2e"
			background = "#ffffff"
		}	
	}
}

Intended Behaviour:
All tabs should follow the default colours defined. However, on tabs that contain the string nvim or ssh in their titles, the colours should be overridden as per the foreground and background values. In this example, nvim tabs should have a background of the 4th ANSI colour and ssh tabs should have a white background with a dark foreground.

Case 3: Modifying Title Based On Tab

Config:

tabs = {
	overrides = {
		ssh = {
			title = function(title)
				return "🐎 " .. title
			end
		}	
	}
}

Intended Behaviour:
All tabs should follow the default colours defined. On tabs that contain the string ssh in their titles, the title of the tab should always be pre-pended with the string "🐎 "

Case 4: Modifying Title Based On Some Abitrary Condition

Config:

tabs = {
	overrides = {
		ssh = {
			matcher = function(override, title) 
				return tab.active_pane.foreground_process_name:find(override)
			end,
			title = function(title)
				return "🐎 " .. title
			end
		}	
	}
}

Intended Behaviour:
All tabs should follow the default colours defined. The definition of the matcher() function allows the user to define their own custom condition on when the override should be applied. In this particular example, on all tabs that have the foreground process ssh running - the title of the tab should always be pre-pended with the string "🐎 "

There are, of course, more permutations that can be showcased but I think these cases cover the majority of them. Let me know what you think!

This commit introduces the functionality
to override titles and colours based on
arbitrary conditions and customise the
default colours that are used for all
tabs.
@sgoudham sgoudham force-pushed the feat/custom-titles-and-colours branch from 64ac603 to 60c79c3 Compare May 19, 2023 08:10
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.

1 participant