Better link handling in fzgo functions
This commit is contained in:
parent
1b24ccb8b9
commit
3482265bd6
|
@ -19,12 +19,11 @@ local function get_entries() {
|
|||
return
|
||||
fi
|
||||
for entry in "$XDG_CONFIG_HOME/fzgo/entries/$file_type"/*; do
|
||||
# If the file is a symlink to a directory, we want to list the directory
|
||||
if [ -L "$entry" ]; then
|
||||
target=$(realpath "$entry")
|
||||
if [ -d "$target" ]; then
|
||||
fd . "$target" -t "$file_type"
|
||||
fi
|
||||
entry=$(realpath "$entry")
|
||||
end
|
||||
if [ -d "$entry" ]; then
|
||||
fd . "$entry" -t "$file_type"
|
||||
else
|
||||
cat "$entry"
|
||||
fi
|
||||
|
@ -42,15 +41,14 @@ function fzgo_update_cache() {
|
|||
for entry in "$file_type_dir"/*; do
|
||||
file_type=$(basename "$file_type_dir")
|
||||
mkdir -p "$XDG_CACHE_HOME/fzgo/entries/$file_type"
|
||||
# If the file is a symlink to a directory, we want to list the directory
|
||||
if [ -L "$entry" ]; then
|
||||
target=$(realpath "$entry")
|
||||
if [ -d "$target" ]; then
|
||||
out_file="$(echo "$target" | sed 's\/\|\g')"
|
||||
entry=$(realpath "$entry")
|
||||
end
|
||||
if [ -d "$entry" ]; then
|
||||
out_file="$(echo "$entry" | sed 's\/\|\g')"
|
||||
out_file="$XDG_CACHE_HOME/fzgo/entries/$file_type/$out_file"
|
||||
mkdir -p "$(dirname \"$out_file\")"
|
||||
fd . "$target" -t "$file_type" > "$out_file"
|
||||
fi
|
||||
fd . "$entry" -t "$file_type" > "$out_file"
|
||||
fi
|
||||
done
|
||||
done
|
||||
|
|
Loading…
Reference in New Issue