deleted: .config/apps-list.md modified: .config/btop/btop.conf deleted: .config/config.kdl new file: .config/fish/completions/fisher.fish new file: .config/fish/completions/fzf_configure_bindings.fish new file: .config/fish/conf.d/fzf.fish new file: .config/fish/fish_plugins modified: .config/fish/fish_variables new file: .config/fish/functions/_fzf_configure_bindings_help.fish new file: .config/fish/functions/_fzf_extract_var_info.fish new file: .config/fish/functions/_fzf_preview_changed_file.fish new file: .config/fish/functions/_fzf_preview_file.fish new file: .config/fish/functions/_fzf_report_diff_type.fish new file: .config/fish/functions/_fzf_report_file_type.fish new file: .config/fish/functions/_fzf_search_directory.fish new file: .config/fish/functions/_fzf_search_git_log.fish new file: .config/fish/functions/_fzf_search_git_status.fish new file: .config/fish/functions/_fzf_search_history.fish new file: .config/fish/functions/_fzf_search_processes.fish new file: .config/fish/functions/_fzf_search_variables.fish new file: .config/fish/functions/_fzf_wrapper.fish new file: .config/fish/functions/fisher.fish new file: .config/fish/functions/fzf_configure_bindings.fish new file: .config/fish/functions/y.fish new file: .config/fish/functions/yz.fish new file: ".config/fish/functions/\320\275\321\217.fish" modified: .config/kitty/kitty.conf modified: .config/niri/config.kdl modified: .config/nvim/lazy-lock.json new file: .config/nvim/lua/plugins/luasnip.lua new file: .config/nvim/lua/plugins/markview.lua new file: .config/nvim/lua/plugins/marp-nvim.lua new file: .config/nvim/lua/plugins/nvim-snippy.lua new file: .config/nvim/lua/plugins/render-markdown.lua deleted: .config/nwg-look/config deleted: .config/zathura/zathurarc modified: apps-list.md new file: background renamed: .config/mimeapps.list -> mimeapps.list renamed: .config/pavucontrol.ini -> pavucontrol.ini deleted: sing-box-03.json renamed: .config/user-dirs.dirs -> user-dirs.dirs renamed: .config/user-dirs.locale -> user-dirs.locale
43 lines
1.8 KiB
Fish
43 lines
1.8 KiB
Fish
# helper function for _fzf_search_directory and _fzf_search_git_status
|
|
function _fzf_preview_file --description "Print a preview for the given file based on its file type."
|
|
# because there's no way to guarantee that _fzf_search_directory passes the path to _fzf_preview_file
|
|
# as one argument, we collect all the arguments into one single variable and treat that as the path
|
|
set -f file_path $argv
|
|
|
|
if test -L "$file_path" # symlink
|
|
# notify user and recurse on the target of the symlink, which can be any of these file types
|
|
set -l target_path (realpath "$file_path")
|
|
|
|
set_color yellow
|
|
echo "'$file_path' is a symlink to '$target_path'."
|
|
set_color normal
|
|
|
|
_fzf_preview_file "$target_path"
|
|
else if test -f "$file_path" # regular file
|
|
if set --query fzf_preview_file_cmd
|
|
# need to escape quotes to make sure eval receives file_path as a single arg
|
|
eval "$fzf_preview_file_cmd '$file_path'"
|
|
else
|
|
bat --style=numbers --color=always "$file_path"
|
|
end
|
|
else if test -d "$file_path" # directory
|
|
if set --query fzf_preview_dir_cmd
|
|
# see above
|
|
eval "$fzf_preview_dir_cmd '$file_path'"
|
|
else
|
|
# -A list hidden files as well, except for . and ..
|
|
# -F helps classify files by appending symbols after the file name
|
|
command ls -A -F "$file_path"
|
|
end
|
|
else if test -c "$file_path"
|
|
_fzf_report_file_type "$file_path" "character device file"
|
|
else if test -b "$file_path"
|
|
_fzf_report_file_type "$file_path" "block device file"
|
|
else if test -S "$file_path"
|
|
_fzf_report_file_type "$file_path" socket
|
|
else if test -p "$file_path"
|
|
_fzf_report_file_type "$file_path" "named pipe"
|
|
else
|
|
echo "$file_path doesn't exist." >&2
|
|
end
|
|
end
|