Skip to content

Commit f908795

Browse files
HT2KnockCopilot
andauthored
Add support for custom formatting (#57)
Add the ability to overwrite the formatting by setting the automatic-rename-format option with the `#{window_icon}` Co-authored-by: Copilot <[email protected]>
1 parent ff88486 commit f908795

File tree

2 files changed

+23
-1
lines changed

2 files changed

+23
-1
lines changed

README.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,17 @@ icons:
4040
cmatrix: "🤯" # add new entries that aren't included
4141
```
4242
43+
### Custom Placeholder Support
44+
45+
If you prefer to define your own `automatic-rename-format`,
46+
you can include a placeholder that lets this plugin inject its icon output.
47+
48+
For example:
49+
50+
```tmux
51+
set -g automatic-rename-format "#{window_icon} #{b:pane_current_path}"
52+
```
53+
4354
## Contributions
4455

4556
Contributions are welcome! Feel free to make a pull request to submit more

tmux-nerd-font-window-name.tmux

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,15 @@
11
#!/usr/bin/env bash
22

33
CURRENT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
4-
tmux set-option -g automatic-rename-format "#($CURRENT_DIR/bin/tmux-nerd-font-window-name #{pane_current_command} #{window_panes})"
4+
5+
plugin_format="#($CURRENT_DIR/bin/tmux-nerd-font-window-name #{pane_current_command} #{window_panes})"
6+
user_format="$(tmux show-option -gv automatic-rename-format 2>/dev/null)"
7+
placeholder="#{window_icon}"
8+
9+
if [[ -n "$user_format" && "$user_format" == *"$placeholder"* ]]; then
10+
new_format="${user_format//$placeholder/$plugin_format}"
11+
else
12+
new_format="$plugin_format"
13+
fi
14+
15+
tmux set-option -g automatic-rename-format "$new_format"

0 commit comments

Comments
 (0)