mirror of
https://github.com/XNM1/linux-nixos-hyprland-config-dotfiles.git
synced 2025-09-15 09:45:58 +03:00
fish scripts update
changelog: - refactored fzf scripts - nullify unused\remapped fzf bindings - `list-op.fish` hotfix 3 - added `hexyl` package to the system
This commit is contained in:
11
home/.config/fish/functions/archive-preview.fish
Normal file
11
home/.config/fish/functions/archive-preview.fish
Normal file
@@ -0,0 +1,11 @@
|
||||
function archive-preview
|
||||
set archive "$argv[1]"
|
||||
set supported_archive_formats tar.gz tar.bz2 tar.xz zip rar 7z
|
||||
|
||||
for format in $supported_archive_formats
|
||||
if string match -q "application/$format" (file -b --mime-type "$archive")
|
||||
ouch list --tree --no "$archive"
|
||||
exit 0
|
||||
end
|
||||
end
|
||||
end
|
4
home/.config/fish/functions/dir-preview.fish
Normal file
4
home/.config/fish/functions/dir-preview.fish
Normal file
@@ -0,0 +1,4 @@
|
||||
function dir-preview
|
||||
set dir "$argv[1]"
|
||||
lsd --tree --depth=1 --color=always --icon=always --icon-theme=fancy "$dir"
|
||||
end
|
4
home/.config/fish/functions/file-preview.fish
Normal file
4
home/.config/fish/functions/file-preview.fish
Normal file
@@ -0,0 +1,4 @@
|
||||
function file-preview
|
||||
set file "$argv[1]"
|
||||
bat --color=always --style=numbers,header-filesize,grid --line-range=:15 --wrap=auto "$file"
|
||||
end
|
@@ -8,6 +8,10 @@ function fish_user_key_bindings
|
||||
# The argument specifies the initial mode (insert, "default" or visual).
|
||||
fish_vi_key_bindings --no-erase insert
|
||||
|
||||
# Nullify fzf default keybindings
|
||||
bind \cT '' -M insert
|
||||
bind \cR '' -M insert
|
||||
|
||||
bind \er fzf-history-widget -M insert
|
||||
bind \ef fzf-file-preview-widget -M insert
|
||||
bind \ec fzf-cd-preview-widget -M insert
|
||||
|
@@ -1,5 +1,5 @@
|
||||
function fzf-cd-preview-widget
|
||||
set selected_dir (fd --type d --hidden --no-ignore --exclude .git --exclude .direnv | fzf --height 40% --reverse --preview 'lsd --tree --depth=1 {}' --preview-window=right:40%)
|
||||
set selected_dir (fd --type d --hidden --no-ignore --exclude .git --exclude .direnv | fzf --height 40% --reverse --preview 'dir-preview {}' --preview-window=right:40%)
|
||||
|
||||
if test -n "$selected_dir"
|
||||
cd "$selected_dir"
|
||||
|
@@ -1,4 +1,4 @@
|
||||
function fzf-file-preview-widget
|
||||
commandline -i (fd --hidden --no-ignore --exclude .git --exclude .direnv | fzf --height 40% --preview-window=right:40% --reverse --preview "test -f {}; and file {} | grep -q text; and bat --color=always --style=numbers --line-range=:500 --wrap=auto {}; or echo 'Preview unavailable for binary files and directories'")
|
||||
commandline -i (fd --hidden --no-ignore --exclude .git --exclude .direnv | fzf --height 40% --preview-window=right:40% --reverse --preview 'switch-preview {}')
|
||||
commandline -f repaint
|
||||
end
|
||||
|
9
home/.config/fish/functions/image-preview.fish
Normal file
9
home/.config/fish/functions/image-preview.fish
Normal file
@@ -0,0 +1,9 @@
|
||||
function image-preview
|
||||
set image "$argv[1]"
|
||||
|
||||
# Retrieve the current terminal dimensions and reduce them slightly to avoid boundary issues
|
||||
set term_width (math (tput cols) - 1)
|
||||
set term_height (math (tput lines) - 1)
|
||||
|
||||
chafa "$image" --size="$term_width"x"$term_height"
|
||||
end
|
@@ -1,6 +1,6 @@
|
||||
function list-op
|
||||
echo \n
|
||||
lsd -al
|
||||
echo ""
|
||||
lsd -Alg
|
||||
echo \n\n
|
||||
commandline -f repaint
|
||||
end
|
||||
|
20
home/.config/fish/functions/switch-preview.fish
Normal file
20
home/.config/fish/functions/switch-preview.fish
Normal file
@@ -0,0 +1,20 @@
|
||||
function switch-preview
|
||||
set path "$argv[1]"
|
||||
|
||||
if test -f "$path"
|
||||
if test ! -s "$path"
|
||||
echo "File is empty"
|
||||
else
|
||||
archive-preview "$path"
|
||||
if string match -q "image/*" (file -b --mime-type "$path")
|
||||
image-preview "$path"
|
||||
else
|
||||
file-preview "$path"
|
||||
end
|
||||
end
|
||||
else if test -d "$path"
|
||||
dir-preview "$path"
|
||||
else
|
||||
echo "Preview unavailable"
|
||||
end
|
||||
end
|
Reference in New Issue
Block a user