Skip to content

Commit d62b686

Browse files
aacebedosainnhe
authored andcommitted
add TMUX_FZF_WINDOW_FILTER
1 parent 2397bd6 commit d62b686

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,13 @@ Similarly, `TMUX_FZF_WINDOW_FORMAT` and `TMUX_FZF_SESSION_FORMAT` can also be ha
154154

155155
For more information, check "FORMATS" section in tmux manual.
156156

157+
158+
## Filter
159+
160+
When using the window listing script, it is possible to filter its output. This relies on the tmux filtering feature with a specific syntax for filters. For more information about this feature, check "FORMATS" section in the tmux manual.
161+
162+
To use this filtering feature, set the variable `TMUX_FZF_WINDOW_FILTER` to the filter you want to apply before calling the `window.sh` script.
163+
157164
# FAQ
158165

159166
**Q: Why use environment variables instead of tmux options to customize this plugin?**

scripts/window.sh

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,17 @@ source "$CURRENT_DIR/.envs"
55

66
current_window_origin=$(tmux display-message -p '#S:#I: #{window_name}')
77
current_window=$(tmux display-message -p '#S:#I:')
8+
9+
if [[ -z "$TMUX_FZF_WINDOW_FILTER" ]]; then
10+
window_filter="-a"
11+
else
12+
window_filter="-f \"$TMUX_FZF_WINDOW_FILTER\""
13+
fi
14+
815
if [[ -z "$TMUX_FZF_WINDOW_FORMAT" ]]; then
9-
windows=$(tmux list-windows -a)
16+
windows=$(tmux list-windows $window_filter)
1017
else
11-
windows=$(tmux list-windows -a -F "#S:#{window_index}: $TMUX_FZF_WINDOW_FORMAT")
18+
windows=$(tmux list-windows $window_filter -F "#S:#{window_index}: $TMUX_FZF_WINDOW_FORMAT")
1219
fi
1320

1421
FZF_DEFAULT_OPTS="$FZF_DEFAULT_OPTS --header='Select an action.'"

0 commit comments

Comments
 (0)