@@ -11,6 +11,10 @@ default_open_editor_key="C-o"
11
11
open_editor_option=" @open-editor"
12
12
open_editor_override=" @open-editor-command"
13
13
14
+ default_open_search_key=" S"
15
+ open_search_option=" @open_search"
16
+ open_search_override=" @open_search_command"
17
+
14
18
command_exists () {
15
19
local command=" $1 "
16
20
type " $command " > /dev/null 2>&1
@@ -35,6 +39,11 @@ command_generator() {
35
39
echo " xargs -I {} tmux run-shell 'cd #{pane_current_path}; $command_string \" {}\" > /dev/null'"
36
40
}
37
41
42
+ search_command_generator () {
43
+ local command_string=" $1 "
44
+ echo " xargs -I {} tmux run-shell 'cd ~/Development/Tmux/tmux-open; $command_string https://www.google.com.br/search?q=\" {}\" > /dev/null'"
45
+ }
46
+
38
47
generate_open_command () {
39
48
if is_osx; then
40
49
echo " $( command_generator " open" ) "
@@ -46,6 +55,17 @@ generate_open_command() {
46
55
fi
47
56
}
48
57
58
+ generate_open_search_command () {
59
+ if is_osx; then
60
+ echo " $( search_command_generator " open" ) "
61
+ elif command_exists " xdg-open" ; then
62
+ echo " $( search_command_generator " xdg-open" ) "
63
+ else
64
+ # error command for Linux machines when 'xdg-open' not installed
65
+ " $CURRENT_DIR /scripts/tmux_open_error_message.sh xdg-open"
66
+ fi
67
+ }
68
+
49
69
# 1. write a command to the terminal, example: 'vim -- some_file.txt'
50
70
# 2. invoke the command by pressing enter/C-m
51
71
generate_editor_command () {
@@ -76,8 +96,20 @@ set_copy_mode_open_editor_bindings() {
76
96
done
77
97
}
78
98
99
+ set_copy_mode_open_search_bindings () {
100
+ local search_command=" $( generate_open_search_command) "
101
+ local key_bindings=$( get_tmux_option " $open_search_option " " $default_open_search_key " )
102
+ local key
103
+ for key in $key_bindings ; do
104
+ tmux bind-key -t vi-copy " $key " copy-pipe " $search_command "
105
+ tmux bind-key -t emacs-copy " $key " copy-pipe " $search_command "
106
+ done
107
+ }
108
+
79
109
main () {
80
110
set_copy_mode_open_bindings
81
111
set_copy_mode_open_editor_bindings
112
+ set_copy_mode_open_search_bindings
82
113
}
114
+
83
115
main
0 commit comments