added all scripts

This commit is contained in:
liph22
2025-12-20 00:03:46 +01:00
parent cf14159137
commit c2f3269124
20 changed files with 1193 additions and 0 deletions

29
fzf_listoldfiles.sh Executable file
View File

@@ -0,0 +1,29 @@
#!/bin/bash
# Script to list recent files and open nvim using fzf
# set to an alias nlof in .zshrc
list_oldfiles() {
# Get the oldfiles list from Neovim
local oldfiles=($(nvim -u NONE --headless +'lua io.write(table.concat(vim.v.oldfiles, "\n") .. "\n")' +qa))
# Filter invalid paths or files not found
local valid_files=()
for file in "${oldfiles[@]}"; do
if [[ -f "$file" ]]; then
valid_files+=("$file")
fi
done
# Use fzf to select from valid files
local files=($(printf "%s\n" "${valid_files[@]}" | \
grep -v '\[.*' | \
fzf --multi \
--preview 'bat -n --color=always --line-range=:500 {} 2>/dev/null || echo "Error previewing file"' \
--height=70% \
--layout=default))
# Open selected files in Neovim
[[ ${#files[@]} -gt 0 ]] && nvim "${files[@]}"
}
# Call the function
list_oldfiles "$@"