Skip to content

Commit

Permalink
BUG: Filespecs are not properly quoted
Browse files Browse the repository at this point in the history
Filespec(s, on individual lines) need to be shell-quoted, as they are passed (through xargs) to the opener.
For the editor (which cannot simply be launched but needs to use the actual terminal so that the editor will be launched inside and therefore visible inside the pane), it's even worse: The concluding CR is only appended once, not for each file. Files should not be edited separately, anyway, but passed as multiple argments to a single editor instance. Also, the editor call itself should disable name lookup (send-keys -l) so that filenames that resemble a Tmux key aren't accidentally translated into a keypress.

Inspired by tmux-plugins#38 (which provides a bad solution, though).
  • Loading branch information
inkarkat committed May 24, 2023
1 parent 82890bf commit 68da2b7
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions open.tmux
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ is_cygwin() {

command_generator() {
local command_string="$1"
echo "{ cd \"\$(tmux display-message -p '#{pane_current_path}')\" && xargs -I {} $command_string \"{}\" >/dev/null; }"
echo "{ cd \"\$(tmux display-message -p '#{pane_current_path}')\" && xargs -I {} printf '%q\\n' {} | xargs -I {} $command_string {} >/dev/null; }"
}

search_command_generator() {
Expand Down Expand Up @@ -81,7 +81,7 @@ generate_editor_command() {
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 send-keys '$editor -- \"{}\"'; tmux send-keys 'C-m'"
echo "xargs -I {} printf '%q\\n' {} | tmux send-keys -l \"$editor -- \$(tr '\\n' ' ')\"; tmux send-keys 'C-m'"
}

set_copy_mode_open_bindings() {
Expand Down

0 comments on commit 68da2b7

Please sign in to comment.