Skip to content

Feature: add option for alternate shell icon #4

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

Merged

Conversation

zatchheems
Copy link
Contributor

@zatchheems zatchheems commented Mar 23, 2023

Alternate Shell Icon Feature

For some odd reason, the NerdFont icon nf-dev-terminal renders strangely when windows running shells are focused. It could be Kitty, it could be my theme; I've tried several different NerdFont options to no avail. Not sure what the problem is or if it's repeatable. I've added an option to change this icon from black-on-white to white-on-black, which renders correctly and looks quite a bit better on my machine, regardless of the weird focus problem.

I'm also thinking about adding a small preview for the icon difference in the README but I'm not sure if that's necessary. Please advise!

Demo:

icon-behavior

Detail:

image

Copy link
Owner

@joshmedeski joshmedeski left a comment

Choose a reason for hiding this comment

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

Thanks for doing this! I'm thinking of offering a yml file or something so people can map whatever icons they want to whatever values, but this is helpful for now.

I've made a couple of suggestions to make it more flexible and cleanup the code.

README.md Outdated
To show a reverse white-on-black NerdFont icon for shells, set the following:

```sh
set -g @tmux-nerd-font-window-name-alterate-shell-icon true
Copy link
Owner

Choose a reason for hiding this comment

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

How about we accept a string to let people pick whatever icon they want?

Suggested change
set -g @tmux-nerd-font-window-name-alterate-shell-icon true
set -g @tmux-nerd-font-window-name-shell-icon ""

ALTERNATE_SHELL_ICON="$(tmux show -gqv '@tmux-nerd-font-window-name-alterate-shell-icon')"
SHELL_ICON=""

if [ "$ALTERNATE_SHELL_ICON" = true ]; then
Copy link
Owner

Choose a reason for hiding this comment

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

I prefer we use a function to scope the data.

get_shell_icon() {
	local default_shell_icon=''
	local shell_icon="$(tmux show -gqv '@tmux-nerd-font-window-name-shell-icon')"
	[ -n "$shell_icon" ] && echo "$shell_icon" || echo "$default_shell_icon"
}

SHELL_ICON=$(get_shell_icon)

Please test this and clean it up as you see fit.

@zatchheems
Copy link
Contributor Author

zatchheems commented Mar 23, 2023

thanks for the suggestions! I appreciate them especially because tmux config and plugins can get spaghetti-like without constant vigilance 🙂

I'll make those changes and test sometime today or tomorrow scratch that, found some time.

echo "$shell_icon"
else
echo "$default_shell_icon"
fi
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This differs from your suggestion, but I usually prefer verbosity over shorthand—it's a holdover from a few years in Rescript I think. I can use shorthand if preferred.

Copy link
Owner

@joshmedeski joshmedeski left a comment

Choose a reason for hiding this comment

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

Looks good to me 👍

@joshmedeski joshmedeski merged commit 575f452 into joshmedeski:main Mar 24, 2023
@zatchheems
Copy link
Contributor Author

This is already merged, but just for future reference: applying bold styling to NerdFonts can cause them to behave unexpectedly. That's what caused the weird behavior in my screenshots.

The more you know!

@zatchheems zatchheems deleted the feature/add-alternate-shell-icon branch March 24, 2023 18:56
@joshmedeski
Copy link
Owner

Good to know, I might add some info to the README to let people know.

jlangston pushed a commit to jlangston/tmux-nerd-font-window-name that referenced this pull request Sep 8, 2023
Adds a `@tmux-nerd-font-window-name-shell-icon` tmux option to overwrite the shell icon.
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