Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prevent arguments from being interpreted as options #80

Merged
merged 2 commits into from
Jan 16, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions functions/__fzf_search_current_dir.fish
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ function __fzf_search_current_dir --description "Search the current directory. R

# If the current token is a directory and has a trailing slash,
# then use it as fd's base directory.
if string match --quiet "*/" $token && test -d $token
if string match --quiet -- "*/" $token && test -d $token
set --append fd_arguments --base-directory=$token
# use the directory name as fzf's prompt to indicate the search is limited to that directory
set --append fzf_arguments --prompt=$token --preview="__fzf_preview_file $token{}"
Expand All @@ -34,7 +34,7 @@ function __fzf_search_current_dir --description "Search the current directory. R
end
end

commandline --current-token --replace (string escape $file_paths_selected | string join ' ')
commandline --current-token --replace -- (string escape -- $file_paths_selected | string join ' ')
end

commandline --function repaint
Expand Down
2 changes: 1 addition & 1 deletion functions/__fzf_search_history.fish
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ function __fzf_search_history --description "Search command history. Replace the

if test $status -eq 0
set command_selected (string split --max 1 " | " $command_with_ts)[2]
commandline --replace $command_selected
commandline --replace -- $command_selected
end

commandline --function repaint
Expand Down
4 changes: 2 additions & 2 deletions functions/__fzf_search_shell_variables.fish
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ function __fzf_search_shell_variables --argument-names set_show_output set_names
set current_token (commandline --current-token)
# Use the current token to pre-populate fzf's query. If the current token begins
# with a $, remove it from the query so that it will better match the variable names
set cleaned_curr_token (string replace '$' '' $current_token)
set cleaned_curr_token (string replace -- '$' '' $current_token)

set variable_name (
printf '%s\n' $all_variable_names |
Expand All @@ -38,7 +38,7 @@ function __fzf_search_shell_variables --argument-names set_show_output set_names
if test $status -eq 0
# If the current token begins with a $, do not overwrite the $ when
# replacing the current token with the selected variable.
if string match --quiet '$*' $current_token
if string match --quiet -- '$*' $current_token
commandline --current-token --replace \$$variable_name
else
commandline --current-token --replace $variable_name
Expand Down