Skip to content

Commit 5fcdae8

Browse files
committed
2.2.5
1 parent 4e31c97 commit 5fcdae8

File tree

3 files changed

+91
-16
lines changed

3 files changed

+91
-16
lines changed

CHANGELOG.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,18 @@ All notable changes to this project will be documented here.
44

55
---
66

7+
## [2.2.5] - 2025-05-09
8+
9+
### Added
10+
11+
- New documentation: docs/SingleQuotes.md
12+
13+
### Changed
14+
15+
- Updated README.md to refer to docs/SingleQuotes.md when relevant
16+
17+
---
18+
719
## [2.2.4] - 2025-05-09
820

921
### Added

README.md

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,12 @@ experienced users, then add more for newbies.
2020

2121
## Recent Changes
2222

23+
- Added `docs/SingleQuotes.md` to explain some pitfalls of single quoted variables.
24+
- Now handles tmux 3.4 odd interpretation of `$HOME` inside single quotes
2325
- Prevent tmux variables from being expanded in `Display Menu Commands`
2426
- Moved Layouts and Split window into Windows menu
2527
- Main menu help displays kind of an about box info, about what version of the
2628
plugin is used
27-
- `Display menu commands` Rotates between displaying commands and all matching
28-
prefix and root binds.
29-
- Added parameter `@menus_border_type` for Styling
3029

3130
</details>
3231
<details>
@@ -172,17 +171,8 @@ The default trigger is `<prefix> \` The trigger is configured like this:
172171
set -g @menus_trigger 'Space'
173172
```
174173

175-
Note: Non-standard keys, such as the default backslash (`\`), must be prefixed with `\`
176-
(e.g., `\\`) to prevent confusion in tmux.
177-
178-
Handling special keys becomes more complex when using quotes:
179-
180-
- Inside single quotes, both `'\'` and `'\\'` work.
181-
- Inside double quotes, only `"\\"` is valid.
182-
183-
To avoid unexpected errors when switching between quoting styles, it's recommended
184-
to always prefix special keys with `\` inside both single and double quotes,
185-
as well as when not using quotes.
174+
See [SingleQuotes](docs/SingleQuotes.md) for how to handle special chars like `\`
175+
in tmux variables.
186176

187177
### Display without using prefix
188178

@@ -197,9 +187,12 @@ Use this in order to trigger menus without first hitting `<prefix>`
197187
### Pointer to the config file
198188

199189
```tmux
200-
set -g @menus_config_file '~/.configs/tmux.conf'
190+
set -g @menus_config_file "~/.configs/tmux.conf"
201191
```
202192

193+
See [SingleQuotes](docs/SingleQuotes.md) for how to handle `$HOME` and `~`
194+
in tmux variables.
195+
203196
In the main menu, the tmux config file to be reloaded.
204197
The default location for this is:
205198

@@ -306,9 +299,12 @@ Per default logging is disabled. If this is desired, provide a log file name
306299
like this:
307300

308301
```tmux
309-
set -g @menus_log_file '~/tmp/tmux-menus.log'
302+
set -g @menus_log_file "~/tmp/tmux-menus.log"
310303
```
311304

305+
See [SingleQuotes](docs/SingleQuotes.md) for how to handle `$HOME` and `~`
306+
in tmux variables.
307+
312308
### Display menu commands
313309

314310
```tmux

docs/SingleQuotes.md

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
# Quoting Pitfalls in Plugin Variable Assignments
2+
3+
## `$HOME`, `~`, and Single Quotes
4+
5+
A common but problematic habit is using single quotes when assigning plugin variables,
6+
especially with paths involving `$HOME` or `~`.
7+
8+
Before tmux 3.0, tmux would automatically interpret paths like `'$HOME/some/path'`
9+
or `'~/some/path'` correctly—effectively converting them to `"$HOME/some/path"`
10+
behind the scenes.
11+
12+
That changed starting with version 3.0:
13+
14+
- `'$HOME/some/path'` is interpreted as `"\$HOME/some/path"`
15+
- `'~/some/path'` becomes `\~/some/path`
16+
17+
In 3.4, `$HOME` became `"\\$HOME/some/path"` while `~` was still broken in the same way.
18+
As of 3.5, tmux reverted to the 3.0 behavior again.
19+
20+
To work around this inconsistency, a helper—`fix_home_path()`—has been added.
21+
It detects the tmux version and rewrites broken single-quoted paths into their
22+
proper double-quoted form.
23+
24+
While this provides some compatibility, **it’s still discouraged**. Most plugins
25+
do not account for these quirks, and relying on single quotes leads to broken
26+
behavior across versions.
27+
28+
**Best practice:** Always wrap paths and variables like `$HOME` or `~` in
29+
double quotes. This ensures consistent, correct expansion in all tmux versions.
30+
31+
---
32+
33+
## Special Characters and Escaping
34+
35+
Quoting also affects how special characters like the backslash (`\`) are parsed.
36+
37+
- With no quoting, `\\` must be used
38+
- In _single quotes_, both `'\\'` and `'\'` can be used.
39+
- In _double quotes_, you must escape the backslash: `"\\"`.
40+
41+
To avoid subtle quoting issues in key bindings or option values,
42+
**escape special characters consistently**, regardless of quoting style:
43+
44+
- Use `\\` for a literal backslash
45+
- Avoid switching between single and double quotes unless necessary
46+
47+
---
48+
49+
## Examples
50+
51+
**Incorrect (common mistakes):**
52+
53+
```tmux
54+
set -g @plugin_path '$HOME/.tmux/plugins'
55+
set -g @plugin_path '~/plugins'
56+
set -g @my_key '\' # unreliable in some quoting contexts
57+
```
58+
59+
**Correct (portable and safe):**
60+
61+
```tmux
62+
set -g @plugin_path "$HOME/.tmux/plugins"
63+
set -g @plugin_path "$HOME/plugins"
64+
set -g @my_key "\\" # explicit and unambiguous
65+
```
66+
67+
These patterns behave consistently across tmux versions and quoting contexts.

0 commit comments

Comments
 (0)