fish: functions: Add an alias for opening log files in /tmp

This commit is contained in:
Sanchayan Maity 2024-05-15 20:32:21 +05:30
parent 7ef1a00db0
commit 1b96983efa
Signed by: sanchayanmaity
GPG key ID: 6F6A0609C12038F3

View file

@ -0,0 +1,13 @@
function lo --description 'Open a .log file in /tmp or given path'
if count $argv >/dev/null
set logpath "$argv"
else
set logpath /tmp
end
find $logpath -maxdepth 1 -regextype posix-extended -regex ".*\.(log)" -printf '%T@ %p\n' | sort -k 1 -n -r | fzf --bind "ctrl-d:half-page-down,ctrl-u:half-page-up" | awk -F' ' '{print $2}' | read -l result
if test -n "$result"
nvim "$result"
end
end