Skip to content

Commit

Permalink
add TMUX_FZF_WINDOW_FILTER
Browse files Browse the repository at this point in the history
  • Loading branch information
aacebedo authored and sainnhe committed Oct 24, 2023
1 parent 2397bd6 commit d62b686
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,13 @@ Similarly, `TMUX_FZF_WINDOW_FORMAT` and `TMUX_FZF_SESSION_FORMAT` can also be ha

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


## Filter

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.

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.

# FAQ

**Q: Why use environment variables instead of tmux options to customize this plugin?**
Expand Down
11 changes: 9 additions & 2 deletions scripts/window.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,17 @@ source "$CURRENT_DIR/.envs"

current_window_origin=$(tmux display-message -p '#S:#I: #{window_name}')
current_window=$(tmux display-message -p '#S:#I:')

if [[ -z "$TMUX_FZF_WINDOW_FILTER" ]]; then
window_filter="-a"
else
window_filter="-f \"$TMUX_FZF_WINDOW_FILTER\""
fi

if [[ -z "$TMUX_FZF_WINDOW_FORMAT" ]]; then
windows=$(tmux list-windows -a)
windows=$(tmux list-windows $window_filter)
else
windows=$(tmux list-windows -a -F "#S:#{window_index}: $TMUX_FZF_WINDOW_FORMAT")
windows=$(tmux list-windows $window_filter -F "#S:#{window_index}: $TMUX_FZF_WINDOW_FORMAT")
fi

FZF_DEFAULT_OPTS="$FZF_DEFAULT_OPTS --header='Select an action.'"
Expand Down

0 comments on commit d62b686

Please sign in to comment.