From f48c3a36a5cb57edfdb87c7b680f9a381c01f007 Mon Sep 17 00:00:00 2001 From: Daniel Flanagan Date: Fri, 11 Oct 2019 11:57:13 -0500 Subject: [PATCH] Add some helpers for getting most recent file in directory (and editing) Great for when you just wanna look at the latest log in a dir without tab-completing through long dates in the filename. --- shell/bash/aliases | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/shell/bash/aliases b/shell/bash/aliases index 23b3d88..a4232d7 100644 --- a/shell/bash/aliases +++ b/shell/bash/aliases @@ -17,6 +17,19 @@ alias f='fzf' alias cp="rsync -ah --progress" alias year="cal $(date +%Y)" +# gets the newest function for the current directory (or the specified directory +# if one is provided) +function ltl() { + local d="${1-$PWD}" + unset -v l + for f in "$d"/*; do + [[ $f -nt $l ]] && [[ ! -d $f ]] && l="$f" + done + echo "$l" +} + +alias vltl="vim \"\$(ltl)\"" + # navigation aliases function c() { if [[ -n $1 ]]; then