Skip to content

Commit 130b614

Browse files
authored
Merge pull request #28 from tmux-plugins/fix-search-engine-feature
Fix search engine feature for tmux 2.4 and above
2 parents 6d26892 + d81446c commit 130b614

File tree

2 files changed

+25
-2
lines changed

2 files changed

+25
-2
lines changed

README.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ In tmux copy mode:
1111
- `o` - "open" a highlighted selection with the system default program. `open`
1212
for OS X or `xdg-open` for Linux.
1313
- `Ctrl-o` - open a highlighted selection with the `$EDITOR`
14+
- `Shift-s` - search the highlighted selection directly inside a search engine (defaults to google).
1415

1516
### Examples
1617

@@ -22,6 +23,7 @@ In copy mode:
2223
- highlight `http://example.com` and press `o` - link will be opened in the
2324
default browser.
2425
- highlight `file.txt` and press `Ctrl-o` - file will open in `$EDITOR`.
26+
- highlight `TypeError: 'undefined' is not a function` and press `Shift-s` - the text snipped will be searched directly inside google by default
2527

2628
### Screencast
2729

@@ -64,6 +66,21 @@ Put `set -g @open 'x'` in `tmux.conf`.
6466
6567
Put `set -g @open-editor 'C-x'` in `tmux.conf`.
6668

69+
> How can I change the default search engine to "duckduckgo" or any other one?
70+
71+
Put `set -g @open-S 'https://www.duckduckgo.com/'` in `tmux.conf`
72+
73+
> How can I use multiple search engines?
74+
75+
Put:
76+
77+
```
78+
set -g @open-B 'https://www.bing.com/search?q='
79+
set -g @open-S 'https://www.google.com/search?q='
80+
```
81+
82+
in `tmux.conf`
83+
6784
### Other goodies
6885

6986
`tmux-open` works great with:

open.tmux

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,8 +122,14 @@ set_copy_mode_open_search_bindings() {
122122
for engine_var in $stored_engine_vars; do
123123
engine="$(get_engine "$engine_var")"
124124

125-
tmux bind-key -t vi-copy "$engine_var" copy-pipe "$(generate_open_search_command "$engine")"
126-
tmux bind-key -t emacs-copy "$engine_var" copy-pipe "$(generate_open_search_command "$engine")"
125+
if tmux-is-at-least 2.4; then
126+
tmux bind-key -T copy-mode-vi "$engine_var" send-keys -X copy-pipe-and-cancel "$(generate_open_search_command "$engine")"
127+
tmux bind-key -T copy-mode "$engine_var" send-keys -X copy-pipe-and-cancel "$(generate_open_search_command "$engine")"
128+
else
129+
tmux bind-key -t vi-copy "$engine_var" copy-pipe "$(generate_open_search_command "$engine")"
130+
tmux bind-key -t emacs-copy "$engine_var" copy-pipe "$(generate_open_search_command "$engine")"
131+
fi
132+
127133
done
128134
}
129135

0 commit comments

Comments
 (0)