Skip to content

Commit

Permalink
save progress
Browse files Browse the repository at this point in the history
  • Loading branch information
PatrickF1 committed Feb 6, 2021
1 parent 08a2327 commit 160e862
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 9 deletions.
2 changes: 1 addition & 1 deletion functions/__fzf_preview_file.fish
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,6 @@ function __fzf_preview_file --argument-names file_path --description "Print a pr
else if test -p "$file_path"
__fzf_report_file_type "$file_path" "named pipe"
else
echo "File doesn't exist." >&2
echo "File doesn't exist or is empty." >&2
end
end
19 changes: 11 additions & 8 deletions functions/__fzf_search_current_dir.fish
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ function __fzf_search_current_dir --description "Search the current directory. R

set fd_arguments --hidden --color=always --exclude=.git
set fzf_arguments --multi --ansi
set token (commandline --current-token | string unescape)
set current_token (commandline --current-token)
set token (string unescape $current_token)
# need to expand ~ in the directory name since fd can't expand it
set expanded_token (string replace --regex -- "^~/" $HOME/ $token)

Expand All @@ -23,14 +24,16 @@ function __fzf_search_current_dir --description "Search the current directory. R


if test $status -eq 0
# If the user was in the middle of inputting the first token and only one path is selected,
# then prepend ./ to the selected path so that
# - if the path is an executable, the user can hit Enter one more time to immediately execute it
# - if the path is a directory, the user can hit Enter one more time to immediately cd into it (fish will
# attempt to cd implicitly if a directory name starts with a dot)
if test (count $file_paths_selected) = 1
# Fish will implicitly take action on a path when a path is provided as the first token and it
# begins with a dot, slash, or tilde. If the path is a directory, Fish will cd into it.
# If the path is an executable, Fish will execute it. To help users harness
# this convenient behavior, we automatically prepend ./ to the selected path if
# - only one path was selected,
# - the user was in the middle of inputting the first token,
# - and the path doesn't already begin with a dot, slash, or tilde
# Then, the user only needs to hit Enter once more to potentially cd into or execute that path.
if test (count $file_paths_selected) = 1 && not string match --regex "^[.|/|~]" $file_paths_selected
set commandline_tokens (commandline --tokenize)
set current_token (commandline --current-token)
if test "$commandline_tokens" = "$current_token"
set file_paths_selected ./$file_paths_selected
end
Expand Down

0 comments on commit 160e862

Please sign in to comment.