fish: functions: Add an alias for opening log files in /tmp
This commit is contained in:
parent
7ef1a00db0
commit
1b96983efa
1 changed files with 13 additions and 0 deletions
13
fish/.config/fish/functions/lo.fish
Normal file
13
fish/.config/fish/functions/lo.fish
Normal 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
|
Loading…
Reference in a new issue