commit bc8eac5058d7d9ecac86daa99712137059c4eb09
parent 6e2c67f813fedc83f49720029c8e054c4836d740
Author: Ed van Bruggen <edvb@uw.edu>
Date: Fri, 1 Jan 2021 21:00:46 -0800
ed: If given directory open files within
Diffstat:
1 file changed, 9 insertions(+), 3 deletions(-)
diff --git a/bin/ed b/bin/ed
@@ -4,14 +4,20 @@
#
# Opens a file with your $EDITOR. If no argument is given then it opens the
# whole directory into a tree view, or if there is only a few files in the
-# current directly then it just opens all of them.
+# current directly then it just opens all of them. If given directory open the
+# files within
if [[ "$@" == "" ]]; then
+ # if less than 5 files in cwd open all of them
if [[ $(ls -l | wc -l) -le 5 ]]; then
$EDITOR ./*
else
$EDITOR .
fi
-else
- $EDITOR "$@"
+else # open files given
+ if [ -d "$1" ]; then # if given directory open files within
+ $EDITOR $1/*
+ else
+ $EDITOR "$@"
+ fi
fi