Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion Brewfile
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ brew "wget"
brew "wireguard-tools"
brew "yq"

# Terminal
# Terminal utils
brew "bash"
brew "btop"
brew "cmatrix"
Expand Down Expand Up @@ -117,6 +117,7 @@ cask "another-redis-desktop-manager"
cask "caffeine"
cask "db-browser-for-sqlite"
cask "dotnet-sdk"
cask "font-jetbrains-mono"
cask "gimp"
cask "google-drive"
cask "google-cloud-sdk"
Expand Down
19 changes: 19 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,25 @@ Tmux plugin manager is installed along with the following plugins:
In order to have the plugins installed, reload the config with `prefix + I`.
This can also fix problems with the plugins not working.

### Pane text search

Search text across tmux panes using fzf. Selecting a match switches to the pane
and scrolls to the matching line. Requires `fzf` and `tmux` to be installed.

- `prefix + f` — search across all panes in all sessions (1000 lines scrollback)
- `prefix + F` — search panes in the current window only (10000 lines scrollback)

Within the search popup:

| Key | Action |
| --- | --- |
| `ctrl-w` | Toggle searching window/session names |
| `ctrl-/` | Toggle preview (surrounding context) |
| `ctrl-d` / `ctrl-u` | Half page down/up |
| `ctrl-f` / `ctrl-b` | Full page down/up |
| `ctrl-g` / `G` | Jump to first/last result |
| `ctrl-y` | Copy selected line to clipboard |

## FAQ

- No linting in Vim and no lint warning or error symbols in the margin?
Expand Down
34 changes: 34 additions & 0 deletions dotfiles/.functions
Original file line number Diff line number Diff line change
@@ -1,2 +1,36 @@
# Git rebase function
grbh() { git rebase -i HEAD~"$1"; }

# Search text across tmux panes with fzf, then jump to the matching pane
# Usage: tmux-pane-search [window] - 'window' limits to current window with deeper scrollback
tmux-pane-search() {
local list_flag='-a' scrollback=1000 prompt="Search all panes> "
if [ "$1" = "window" ]; then
list_flag='' scrollback=10000 prompt="Search window panes> "
fi
local preview_cmd='
target=$(echo {} | cut -f1)
line=$(echo {} | cut -f3 | sed "s/^ *\([0-9]*\).*/\1/")
{ tmux capture-pane -t "$target" -p -S -'"$scrollback"' 2>/dev/null
tmux capture-pane -t "$target" -p -a 2>/dev/null
} | nl -ba -w4 -s" " | awk -v l="$line" "NR>=l-10 && NR<=l+10 { if(NR==l) printf \"\033[1;32m>> %s\033[0m\n\", \$0; else print \" \" \$0 }"
'
local result
result=$(
tmux list-panes $list_flag -F '#{session_name}:#{window_index}.#{pane_index} #{session_name}|#{window_index}(#{window_name})|#{pane_index}' |
while IFS=' ' read -r target label; do
{ tmux capture-pane -t "$target" -p -S -"$scrollback" 2>/dev/null
tmux capture-pane -t "$target" -p -a 2>/dev/null
} | nl -ba -w4 -s' ' | sed -n '/..*/{s/^/'"$target"' ['"$label"'] /;p;}'
done |
fzf --exact --ansi --no-sort --with-nth=2.. --nth=2.. --delimiter=' ' --prompt="$prompt" \
--color='hl:underline:bold:green,hl+:underline:reverse:green' \
--preview="$preview_cmd" --preview-window='right:50%:hidden' \
--bind='ctrl-/:toggle-preview,ctrl-d:half-page-down,ctrl-u:half-page-up,ctrl-f:page-down,ctrl-b:page-up,ctrl-g:first,G:last,ctrl-y:execute-silent(echo -n {3..} | pbcopy),ctrl-w:transform-nth[test "$FZF_NTH" = "2.." && echo ".." || echo "2.."]+transform-prompt[test "$FZF_NTH" = ".." && echo "Search window names only> " || echo "'"$prompt"'"]'
) || return
local target text
target=$(printf '%s' "$result" | cut -f1)
text=$(printf '%s' "$result" | cut -f3- | sed 's/^ *[0-9]* //')
tmux switch-client -t "$target" \; select-window -t "$target" \; select-pane -t "$target"
tmux copy-mode -t "$target" \; send-keys -t "$target" -X search-backward "$text"
}
5 changes: 5 additions & 0 deletions dotfiles/.tmux.conf
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,11 @@ set -g @vim_navigator_prefix_mapping_clear_screen ""
bind-key -n C-S-Left swap-window -t -1\; select-window -t -1
bind-key -n C-S-Right swap-window -t +1\; select-window -t +1

# Search text across all panes/windows/sessions with fzf
bind f display-popup -E -w 80% -h 80% 'bash -c "source ~/.functions && tmux-pane-search"'
# Search text across panes in the current window only (deeper scrollback)
bind F display-popup -E -w 80% -h 80% 'bash -c "source ~/.functions && tmux-pane-search window"'

# Tmux PLugin Manager config
set -g @plugin 'tmux-plugins/tpm' # https://github.com/tmux-plugins/tpm
set -g @plugin 'tmux-plugins/tmux-continuum' # https://github.com/tmux-plugins/tmux-continuum
Expand Down
Loading