Skip to content

Commit 87e201f

Browse files
committed
support tilde expansion
1 parent 763d0a8 commit 87e201f

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

open.tmux

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,20 +34,21 @@ get_editor_from_the_env_var() {
3434
fi
3535
}
3636

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

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

4647
search_command_generator() {
4748
local command_string="$1"
4849
local engine="$2"
4950

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

5354
generate_open_command() {
@@ -84,7 +85,7 @@ generate_editor_command() {
8485
local editor=$(get_tmux_option "$open_editor_override" "$environment_editor")
8586
# vim freezes terminal unless there's the '--' argument. Other editors seem
8687
# to be fine with it (textmate [mate], light table [table]).
87-
echo "$(preserve_url_hash) | xargs -I {} tmux send-keys '$editor -- \"{}\"'; tmux send-keys 'C-m'"
88+
echo "$(escape_and_expand) | xargs -I {} tmux send-keys '$editor -- \"{}\"'; tmux send-keys 'C-m'"
8889
}
8990

9091
set_copy_mode_open_bindings() {

0 commit comments

Comments
 (0)