dotfiles

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README | LICENSE

commit 643886a7c9c61d9fb7eb6f4e906bf2360be44c6f
parent c109b22891fd164b2695220d724bc2ae752d17c3
Author: Luke Smith <luke@lukesmith.xyz>
Date:   Thu, 21 Mar 2019 14:59:26 -0400

Merge pull request #245 from The-King-of-Toasters/master

change rotdir to use ed(1)
Diffstat:
M.scripts/tools/rotdir | 17+++++++++++++++--
1 file changed, 15 insertions(+), 2 deletions(-)

diff --git a/.scripts/tools/rotdir b/.scripts/tools/rotdir @@ -1,3 +1,16 @@ #!/bin/sh -# Give this script a filename argument. Returns PWD rotated with that file first. -ls "$PWD" | awk "BEGIN { lines = \"\"; m = 0; } /^$1$/ { m = 1; } { if (!m) { if (lines) { lines = lines\"\n\"; } lines = lines\"\"\$0; } else { print \$0; } } END { print lines; }" +if [ -z "$1" ]; then + echo usage: rotdir regex 2>&1 + exit 1; +fi + +ed -s <<EOF +# Read in all files in the current dir +r !find "$PWD" -maxdepth 1 +# Search all lines for regex, move to top +g/$1/m0 +# Print all lines +,p +# Force quit +Q +EOF