Last active
March 21, 2025 07:29
-
-
Save mbigras/3c855d54f7700dbd55e311a56ddbb5e2 to your computer and use it in GitHub Desktop.
Revisions
-
Max Bigras revised this gist
Mar 21, 2025 . 1 changed file with 2 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,3 +1,5 @@ # e - list files sorted by time, also filter and edit if only 1 match # usage: e pattern1 pattern2 ... pattern=$(echo "$@" | awk ' BEGIN { printf "//" } { for (i = 1; i <= NF; i++) -
Max Bigras revised this gist
Mar 21, 2025 . 1 changed file with 10 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,10 @@ pattern=$(echo "$@" | awk ' BEGIN { printf "//" } { for (i = 1; i <= NF; i++) printf(" && /%s/", $i) }') matches=$(ls -t | tac | awk "$pattern") echo "$matches" if test $(echo "$matches" | wc -l) -eq 1 then ed "$matches" fi -
mbigras created this gist
Mar 21, 2025 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,18 @@ # e - list files sorted by time, also filter and edit if only 1 match # usage: e pattern1 pattern2 ... ls -t | awk ' BEGIN { for (i = 1; ARGV[i] != "-"; i++) { # collect patterns pat[++np] = ARGV[i] ARGV[i] = "" } } { for (i = 1; i <= np; i++) { if (!match($0, pat[i])) next } nm++; fn=$0; print } END { if (nm == 1) system(sprintf("rlwrap ed </dev/tty \"%s\"", fn)) } ' "$@" - This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,10 @@ # e - list files sorted by time, also filter and edit if only 1 match # usage: e pattern1 pattern2 ... f=$(mktemp) m=$(mktemp) printf '/%s/ && ' "" "$@" | awk '{ $NF=""; print }' >$f ls -t | awk -f $f | tee $m if test $(wc -l <$m) -eq 1 then exec rlwrap ed "$(cat $m)" fi