fzdirs - check if the first entry in path-list exists

This commit is contained in:
Arun Prakash Jana 2021-05-28 23:46:00 +05:30
parent f6b14f6505
commit a6eeceec55
No known key found for this signature in database
GPG key ID: A75979F35C080412

View file

@ -8,7 +8,8 @@
# Paths can be file paths; the script will scan the parent dirs. # Paths can be file paths; the script will scan the parent dirs.
# #
# The path-list file precedence is: # The path-list file precedence is:
# - "$1" (the hovered file) if it exists and is plaintext # - "$1" (the hovered file) if it exists, is plain-text and the
# first line points to an existing file
# - "$LIST" if set below # - "$LIST" if set below
# - "$2" (the current directory) [mimics plugin fzcd behaviour] # - "$2" (the current directory) [mimics plugin fzcd behaviour]
# #
@ -29,7 +30,7 @@ IFS="$(printf '\n\r')"
CTX=+ CTX=+
LIST="$LIST" LIST="$LIST"
if [ -n "$1" ] && [ $(file -b --mime-type "$1") = 'text/plain' ]; then if [ -n "$1" ] && [ "$(file -b --mime-type "$1")" = 'text/plain' ] && [ -e "$(head -1 "$1")" ]; then
LIST="$1" LIST="$1"
elif ! [ -s "$LIST" ]; then elif ! [ -s "$LIST" ]; then
LIST="$2" LIST="$2"