Skip to content

Commit f0bfaff

Browse files
joshmedeskikenos1
andauthored
feat: add yaml config support (#13)
* Added other text editors and utilities * Add extra options * Added package managers * Fix tabs in code * Add fzf and skim * Init of custom icons branch * Added recommended icons * Add Nix * Update README * Add screenshot * Init for yaml branch * feat: set default configs * feat: get user config to work * docs: update docs * chore: delete unused conf file --------- Co-authored-by: Kenos <flatware-gold-bronze@tutanota.com>
1 parent 60d4feb commit f0bfaff

7 files changed

+94
-121
lines changed

README.md

+20-43
Original file line numberDiff line numberDiff line change
@@ -1,64 +1,41 @@
1-
<a href="https://www.joshmedeski.com/posts/tmux-nerd-font-window-name-plugin/" target="_blank">
2-
3-
![thumbnail](https://github.com/joshmedeski/tmux-nerd-font-window-name/blob/main/tmux-nerd-font-window-name-thumb.jpeg?raw=true)
4-
5-
</a>
6-
71
# tmux nerd font window name plugin
82

9-
Automatically rename your tmux windows to Nerd Font Icons.
3+
Automatically add Nerd Font support to your tmux window names!
104

11-
## Prerequisites
5+
![tmux-nerd-font-window-name screenshot](./tmux-nerd-font-window-name-screenshot.png)
6+
7+
## Requirements
128

139
- [tmux](https://github.com/tmux/tmux)
1410
- [tpm](https://github.com/tmux-plugins/tpm)
15-
- [Nerd Font](https://www.nerdfonts.com/)
11+
- [yq](https://github.com/mikefarah/yq)
1612

17-
## How to install
13+
## Installation
1814

1915
### Install tpm plugin
2016

21-
This script can be installed with the [Tmux Plugin Manager (tpm)](https://github.com/tmux-plugins/tpm).
22-
23-
Add the following line to your `~/.tmux.conf` file:
24-
25-
```conf
26-
set -g @plugin 'joshmedeski/tmux-nerd-font-window-name'
27-
```
28-
29-
### Options
17+
This plugin can be installed with the [Tmux Plugin Manager (tpm)](https://github.com/tmux-plugins/tpm).
3018

31-
Add the following options to your `tmux.conf` before you set the plugin.
19+
Add the following line to your tmux configuration file:
3220

3321
```sh
34-
# shows the window name next to the icon (default false)
35-
set -g @tmux-nerd-font-window-name-show-name true
22+
set -g @plugin 'joshmedeski/tmux-nerd-font-window-name'
3623
```
3724

38-
### Minimalist format
39-
40-
If you want a minimalist format and only show the nerd font icon. You can update your window status to just `#W` (window name) in your tmux config.
41-
42-
```conf
43-
set -g window-status-current-format '#[fg=magenta]#W'
44-
set -g window-status-format '#[fg=gray]#W'
45-
```
25+
## Configuration
4626

47-
### Custom shell icon
27+
You can configure this plugin by creating a `~/.config/tmux/tmux-nerd-font-window-name.yml` file. The following options can be changed:
4828

49-
To specify a custom shell icon, use the following option to set any icon you prefer:
29+
```yml
30+
config:
31+
fallback-icon: "?" # icon to use if no definition is found
32+
show-name: true # show the window name with the icon
5033

51-
```sh
52-
set -g @tmux-nerd-font-window-name-shell-icon ""
34+
icons:
35+
zsh: "" # overwrite with your own symbol (Nerd Font icon, emoji, whatever!)
36+
cmatrix: "🤯" # add new entries that aren't included
5337
```
54-
## How it works
55-
56-
When installed, your window names will automatically update to a Nerd Font that matches the activity (ex: vim, bash, node, ect...).
57-
58-
## Tasks
59-
60-
- [x] Create tpm plugin
6138
62-
## Contributing
39+
## Contributions
6340
64-
I encourage contributors! I want to make this plugin the best it can be. Feel free to fork it and submit pull requests with any new ideas or improvements you have.
41+
Contributions are welcome! Feel free to make a pull request to submit more preset icon settings or improve the codebase!

bin/defaults.yml

+46
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
# cSpell:disable
2+
config:
3+
fallback-icon: "?"
4+
show-name: true
5+
6+
icons:
7+
apt: ""
8+
bash: ""
9+
beam.smp: ""
10+
beam: ""
11+
brew: ""
12+
cfdisk: ""
13+
dnf: ""
14+
docker: ""
15+
dpkg: ""
16+
emacs: ""
17+
fdisk: ""
18+
fish: ""
19+
git: ""
20+
gitui: ""
21+
go: ""
22+
htop: ""
23+
lazydocker: ""
24+
lazygit: ""
25+
lf: ""
26+
lfcd: ""
27+
lvim: ""
28+
nala: ""
29+
node: ""
30+
nvim: ""
31+
pacman: ""
32+
parted: ""
33+
paru: ""
34+
Python: ""
35+
ranger: ""
36+
ruby: ""
37+
rustc: ""
38+
rustup: ""
39+
tcsh: ""
40+
tig: ""
41+
tmux: ""
42+
top: ""
43+
vim: ""
44+
yay: ""
45+
yum: ""
46+
zsh: ""

bin/tmux-nerd-font-window-name

+20-63
Original file line numberDiff line numberDiff line change
@@ -1,73 +1,30 @@
11
#!/usr/bin/env bash
22

3-
NAME=$1
4-
SHOW_NAME="$(tmux show -gqv '@tmux-nerd-font-window-name-show-name')"
3+
NAME="$1"
4+
CURRENT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
5+
DEFAULT_CONFIG="$CURRENT_DIR/defaults.yml"
6+
USER_CONFIG="$HOME/.config/tmux/tmux-nerd-font-window-name.yml"
57

6-
function get_shell_icon() {
7-
local default_shell_icon=""
8-
local shell_icon
9-
shell_icon="$(tmux show -gqv '@tmux-nerd-font-window-name-shell-icon')"
10-
if [ "$shell_icon" != "" ]; then
11-
echo "$shell_icon"
12-
else
13-
echo "$default_shell_icon"
8+
get_config_value() {
9+
local key=$1
10+
local value
11+
value="$(yq "$key" "$USER_CONFIG")"
12+
if [ "$value" == "null" ]; then # get default config value
13+
value="$(yq "$key" "$DEFAULT_CONFIG")"
1414
fi
15+
echo "$value"
1516
}
1617

17-
SHELL_ICON=$(get_shell_icon)
18+
ICON="$(get_config_value ".icons.$NAME")"
1819

19-
get_icon() {
20-
case $NAME in
21-
tmux)
22-
echo ""
23-
;;
24-
htop | top)
25-
echo ""
26-
;;
27-
fish | zsh | bash | tcsh)
28-
echo "$SHELL_ICON"
29-
;;
30-
vi | vim | nvim | lvim)
31-
echo ""
32-
;;
33-
lazygit | git | tig)
34-
echo ""
35-
;;
36-
node)
37-
echo ""
38-
;;
39-
ruby)
40-
echo ""
41-
;;
42-
go)
43-
echo ""
44-
;;
45-
lf | lfcd)
46-
echo ""
47-
;;
48-
beam | beam.smp) # Erlang runtime
49-
echo ""
50-
;;
51-
rustc | rustup)
52-
echo ""
53-
;;
54-
Python)
55-
echo ""
56-
;;
57-
*)
58-
if [ "$SHOW_NAME" = true ]; then
59-
echo ""
60-
else
61-
echo "$NAME"
62-
fi
63-
;;
64-
esac
65-
}
66-
67-
ICON=$(get_icon)
20+
if [ "$ICON" == "null" ]; then
21+
FALLBACK_ICON="$(get_config_value '.config.fallback-icon')"
22+
ICON="$FALLBACK_ICON"
23+
fi
6824

25+
SHOW_NAME="$(get_config_value '.config.show-name')"
6926
if [ "$SHOW_NAME" = true ]; then
70-
echo "$ICON" "$NAME"
71-
else
72-
echo "$ICON"
27+
ICON="$ICON $NAME"
7328
fi
29+
30+
echo "$ICON"

cspell.json

-15
This file was deleted.

shell.nix

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{ pkgs ? import <nixpkgs> {} }:
2+
pkgs.mkShell {
3+
buildInputs = with pkgs;[
4+
tmux
5+
yq-go
6+
nodePackages.bash-language-server
7+
];
8+
}
-741 KB
Loading

tmux-nerd-font-window-name-thumb.jpeg

-569 KB
Binary file not shown.

0 commit comments

Comments
 (0)