Skip to content

Commit

Permalink
support tilde expansion
Browse files Browse the repository at this point in the history
  • Loading branch information
jyn514 committed Jun 18, 2024
1 parent 763d0a8 commit 87e201f
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions open.tmux
Original file line number Diff line number Diff line change
Expand Up @@ -34,20 +34,21 @@ get_editor_from_the_env_var() {
fi
}

preserve_url_hash() {
echo "sed s/##/####/g"
escape_and_expand() {
# the `echo {} | bash` is to perform tilde expansion.
echo "sed s/##/####/g | xargs -I {} echo 'echo {}' | bash"
}

command_generator() {
local command_string="$1"
echo "$(preserve_url_hash) | xargs -I {} tmux run-shell -b 'cd #{pane_current_path}; $command_string \"{}\" > /dev/null'"
echo "$(escape_and_expand) | xargs -I {} tmux run-shell -b 'cd #{pane_current_path}; $command_string \"{}\" > /dev/null'"
}

search_command_generator() {
local command_string="$1"
local engine="$2"

echo "$(preserve_url_hash) | sed 's/\ /+/g' | xargs -I {} tmux run-shell -b 'cd #{pane_current_path}; $command_string $engine\"{}\" > /dev/null'"
echo "$(escape_and_expand) | sed 's/\ /+/g' | xargs -I {} tmux run-shell -b 'cd #{pane_current_path}; $command_string $engine\"{}\" > /dev/null'"
}

generate_open_command() {
Expand Down Expand Up @@ -84,7 +85,7 @@ generate_editor_command() {
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 "$(preserve_url_hash) | xargs -I {} tmux send-keys '$editor -- \"{}\"'; tmux send-keys 'C-m'"
echo "$(escape_and_expand) | xargs -I {} tmux send-keys '$editor -- \"{}\"'; tmux send-keys 'C-m'"
}

set_copy_mode_open_bindings() {
Expand Down

0 comments on commit 87e201f

Please sign in to comment.