From 1c2ddf377fe563e8c393cc1b543cd3aa46233ece Mon Sep 17 00:00:00 2001 From: TheSiahxyz <164138827+TheSiahxyz@users.noreply.github.com> Date: Mon, 8 Dec 2025 12:05:52 +0900 Subject: updates --- ar/.config/lf/lfrc | 4 +-- ar/.config/shell/aliasrc | 2 +- ar/.config/zsh/keymaps.zsh | 8 ++--- ar/.local/bin/lastfiles | 77 ++++++++++++++++++++++++++++++++++++++++++++++ ar/.local/bin/lastnvim | 77 ---------------------------------------------- 5 files changed, 84 insertions(+), 84 deletions(-) create mode 100755 ar/.local/bin/lastfiles delete mode 100755 ar/.local/bin/lastnvim (limited to 'ar') diff --git a/ar/.config/lf/lfrc b/ar/.config/lf/lfrc index 06a13b0..64416d3 100644 --- a/ar/.config/lf/lfrc +++ b/ar/.config/lf/lfrc @@ -432,7 +432,7 @@ cmd zi ${{ cmd follow_link %{{ lf -remote "send ${id} select '$(readlink $f)'" }} -cmd lastnvim ${{ +cmd lastfiles ${{ list=$(nvim -u NONE --headless +'lua io.write(table.concat(vim.v.oldfiles, "\n") .. "\n")' +qa) file=$(printf "%s" "$list" | while read -r file; do [ -f "$file" ] && printf "%s\n" "$file" @@ -516,7 +516,7 @@ map delete; clear; save-select map $$EDITOR "$f" map push :!nvim map vlf edit-config -map vll lastnvim +map vll lastfiles map vln $$EDITOR "$(nvim -u NONE --headless +'lua io.write(vim.v.oldfiles[1] .. "\n")' +qa)" # Extract diff --git a/ar/.config/shell/aliasrc b/ar/.config/shell/aliasrc index 119a5b3..55f04e7 100644 --- a/ar/.config/shell/aliasrc +++ b/ar/.config/shell/aliasrc @@ -288,7 +288,7 @@ alias nlu='NVIM_APPNAME=LunarVim nvim' alias nlv='NVIM_APPNAME=LazyVim nvim' alias nnc='NVIM_APPNAME=NvChad nvim' alias snv='sudo nvim' -alias vll='lastnvim -l' +alias vll='lastfiles -l' alias vln='$EDITOR -c '\''execute "edit " . v:oldfiles[0] | normal ''0'\' # nxsiv diff --git a/ar/.config/zsh/keymaps.zsh b/ar/.config/zsh/keymaps.zsh index efd9e04..81b3027 100644 --- a/ar/.config/zsh/keymaps.zsh +++ b/ar/.config/zsh/keymaps.zsh @@ -165,7 +165,7 @@ if [[ -f "${ZPLUGINDIR:-${HOME}/.local/bin/zsh}/zsh-vi-mode/zsh-vi-mode.plugin.z bindkey -s '^F' '^ufzffiles\n' bindkey -s '^G' '^ulf\n' # bindkey -s '^G' '^uyazi\n' - bindkey -s '^N' '^ulastnvim\n' + bindkey -s '^N' '^ulastfiles\n' bindkey -s '^O' '^utmo\n' bindkey -s '^P' '^ufzfpass\n' bindkey -s '^Q' '^uhtop\n' @@ -182,7 +182,7 @@ if [[ -f "${ZPLUGINDIR:-${HOME}/.local/bin/zsh}/zsh-vi-mode/zsh-vi-mode.plugin.z zvm_bind_script viins '^X^F' 'gitfiles' zvm_bind_script viins '^X^G' 'rgafiles ' zvm_bind_script viins '^X^L' 'gloac' - zvm_bind_script viins '^X^N' 'lastnvim -l' + zvm_bind_script viins '^X^N' 'lastfiles -l' # zvm_bind_script viins '^X^O' '^u\n' zvm_bind_script viins '^X^Q' 'fpkill' zvm_bind_script viins '^X^R' 'fgst' @@ -312,7 +312,7 @@ else bindkey -s '^D' '^ucdi\n' bindkey -s '^F' '^ufzffiles\n' bindkey -s '^G' '^ulf\n' - bindkey -s '^N' '^ulastnvim\n' + bindkey -s '^N' '^ulastfiles\n' bindkey -s '^O' '^utmo\n' bindkey -s '^P' '^ufzfpass\n' bindkey -s '^Q' '^uhtop\n' @@ -326,7 +326,7 @@ else bindkey -s '^X^F' '^ugitfiles\n' bindkey -s '^X^G' '^urgafiles ' bindkey -s '^X^L' '^ugloac\n' - bindkey -s '^X^N' '^ulastnvim -l\n' + bindkey -s '^X^N' '^ulastfiles -l\n' # bindkey -s '^X^O' '^u\n' bindkey -s '^X^Q' '^ufpkill\n' bindkey -s '^X^R' '^ufgst\n' diff --git a/ar/.local/bin/lastfiles b/ar/.local/bin/lastfiles new file mode 100755 index 0000000..b1ab6c9 --- /dev/null +++ b/ar/.local/bin/lastfiles @@ -0,0 +1,77 @@ +#!/bin/sh + +# Display help message +usage() { + echo "Open the most recent file or the list of old files in fzf edited by nvim." + echo "" + echo "Usage: ${0##*/} [OPTION]" + echo "" + echo "Options:" + echo " : Open the most recent old file in Neovim." + echo " -h, --help : Show this help message." + echo " -l, --list : Show all recent files in Neovim using fzf." + echo "" + echo "Examples:" + echo " ${0##*/} # Open the most recent file." + echo " ${0##*/} -l # Show all recent files in fzf and select to open." + exit 0 +} + +# List and handle oldfiles +list_oldfiles() { + # Fetch the oldfiles list from Neovim + oldfiles=$(nvim -u NONE --headless +'lua io.write(table.concat(vim.v.oldfiles, "\n") .. "\n")' +qa) + + # Exit if no oldfiles are found + [ -z "$oldfiles" ] && { + echo "No recent files found in Neovim." >&2 + exit 1 + } + + case "$1" in + -h | --help) + usage + ;; + -l | --list) + # Filter valid files + valid_files=$(echo "$oldfiles" | while IFS= read -r file; do + [ -f "$file" ] && printf "%s\n" "$file" + done) + + # Exit if no valid files exist + [ -z "$valid_files" ] && { + echo "No valid files found." >&2 + exit 1 + } + + # Use fzf to select files + selected_files=$(echo "$valid_files" | + fzf-tmux \ + --multi \ + --preview 'bat -n --color=always --line-range=:500 {} 2>/dev/null || echo "Error previewing file"' \ + --height=70% \ + --reverse) + + # Exit if no files were selected + [ -z "$selected_files" ] && exit 1 + + # Open selected files in Neovim + openfiles "$selected_files" + ;; + *) + # Open the most recent file + for file in $oldfiles; do + if [ -f "$file" ]; then + openfiles "$file" + exit 0 + fi + done + + echo "No valid recent files found." >&2 + exit 1 + ;; + esac +} + +# Parse command-line arguments +list_oldfiles "$@" diff --git a/ar/.local/bin/lastnvim b/ar/.local/bin/lastnvim deleted file mode 100755 index b1ab6c9..0000000 --- a/ar/.local/bin/lastnvim +++ /dev/null @@ -1,77 +0,0 @@ -#!/bin/sh - -# Display help message -usage() { - echo "Open the most recent file or the list of old files in fzf edited by nvim." - echo "" - echo "Usage: ${0##*/} [OPTION]" - echo "" - echo "Options:" - echo " : Open the most recent old file in Neovim." - echo " -h, --help : Show this help message." - echo " -l, --list : Show all recent files in Neovim using fzf." - echo "" - echo "Examples:" - echo " ${0##*/} # Open the most recent file." - echo " ${0##*/} -l # Show all recent files in fzf and select to open." - exit 0 -} - -# List and handle oldfiles -list_oldfiles() { - # Fetch the oldfiles list from Neovim - oldfiles=$(nvim -u NONE --headless +'lua io.write(table.concat(vim.v.oldfiles, "\n") .. "\n")' +qa) - - # Exit if no oldfiles are found - [ -z "$oldfiles" ] && { - echo "No recent files found in Neovim." >&2 - exit 1 - } - - case "$1" in - -h | --help) - usage - ;; - -l | --list) - # Filter valid files - valid_files=$(echo "$oldfiles" | while IFS= read -r file; do - [ -f "$file" ] && printf "%s\n" "$file" - done) - - # Exit if no valid files exist - [ -z "$valid_files" ] && { - echo "No valid files found." >&2 - exit 1 - } - - # Use fzf to select files - selected_files=$(echo "$valid_files" | - fzf-tmux \ - --multi \ - --preview 'bat -n --color=always --line-range=:500 {} 2>/dev/null || echo "Error previewing file"' \ - --height=70% \ - --reverse) - - # Exit if no files were selected - [ -z "$selected_files" ] && exit 1 - - # Open selected files in Neovim - openfiles "$selected_files" - ;; - *) - # Open the most recent file - for file in $oldfiles; do - if [ -f "$file" ]; then - openfiles "$file" - exit 0 - fi - done - - echo "No valid recent files found." >&2 - exit 1 - ;; - esac -} - -# Parse command-line arguments -list_oldfiles "$@" -- cgit v1.2.3