From d14edc94e63c79376d88ecc17bdc461c600f50c1 Mon Sep 17 00:00:00 2001 From: GHPS Date: Fri, 5 Aug 2016 17:26:25 +0200 Subject: [PATCH 1/2] Feature added: Open Editor in Pane (M-o) --- open.tmux | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/open.tmux b/open.tmux index 1c49585..0e49206 100755 --- a/open.tmux +++ b/open.tmux @@ -11,6 +11,10 @@ default_open_editor_key="C-o" open_editor_option="@open-editor" open_editor_override="@open-editor-command" +default_open_editor_in_pane_key="M-o" +open_editor_in_pane_option="@open-editor-in-pane" +open_editor_in_pane_override="@open-editor-in-pane-command" + command_exists() { local command="$1" type "$command" >/dev/null 2>&1 @@ -83,6 +87,14 @@ generate_editor_command() { echo "xargs -I {} tmux send-keys '$editor -- \"{}\"'; tmux send-keys 'C-m'" } +generate_editor_in_new_pane_command() { + local environment_editor=$(get_editor_from_the_env_var) + local editor=$(get_tmux_option "$open_editor_override" "$environment_editor") + # vim freezes terminal unless there's the '--' argument. Other editors seem + # to be fine with it (textmate [mate], light table [table]). + echo "xargs -I {} tmux split-window -h '$editor -- \"{}\"'" +} + set_copy_mode_open_bindings() { local open_command="$(generate_open_command)" local key_bindings=$(get_tmux_option "$open_option" "$default_open_key") @@ -103,6 +115,16 @@ set_copy_mode_open_editor_bindings() { done } +set_copy_mode_open_editor_in_new_pane_bindings() { + local editor_command="$(generate_editor_in_new_pane_command)" + local key_bindings=$(get_tmux_option "$open_editor_in_pane_option" "$default_open_editor_in_pane_key") + local key + for key in $key_bindings; do + tmux bind-key -t vi-copy "$key" copy-pipe "$editor_command" + tmux bind-key -t emacs-copy "$key" copy-pipe "$editor_command" + done +} + set_copy_mode_open_search_bindings() { local stored_engine_vars="$(stored_engine_vars)" local engine_var @@ -120,6 +142,7 @@ set_copy_mode_open_search_bindings() { main() { set_copy_mode_open_bindings set_copy_mode_open_editor_bindings + set_copy_mode_open_editor_in_new_pane_bindings set_copy_mode_open_search_bindings } From 634791ec1ce53be8f9d6f3a08c7816ff95cd00ba Mon Sep 17 00:00:00 2001 From: GHPS Date: Sat, 13 Aug 2016 03:10:00 +0200 Subject: [PATCH 2/2] Allow search key bindings with modifier (Ctrl-/Meta-) keys. --- scripts/helpers.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/helpers.sh b/scripts/helpers.sh index ff418dd..d98f8fc 100644 --- a/scripts/helpers.sh +++ b/scripts/helpers.sh @@ -35,7 +35,7 @@ display_message() { } stored_engine_vars() { - tmux show-options -g | grep -i "^@open" | cut -d '-' -f2 | cut -d ' ' -f1 | xargs + tmux show-options -g | grep -i "^@open" | cut -d '-' -f2-3 | cut -d ' ' -f1 | xargs } get_engine() {