config

OpenBSD system configuration
git clone git://jacobedwards.org/config
Log | Files | Refs | README

commit 64169ec95cd5c43659eb52b1e9996989a46e0d5d
parent 99693e82dd5ff56aa2a0b85dc04401640a48914d
Author: Jacob R. Edwards <jacobouno@protonmail.com>
Date:   Thu,  3 Sep 2020 21:07:01 -0700

Remove unneeded features and shorten

-p flag always on.

no longer test if the selection is a directory.

shorten usage.

Diffstat:
Mscripts/.local/bin/fsmenu | 46++++++++++++----------------------------------
1 file changed, 12 insertions(+), 34 deletions(-)

diff --git a/scripts/.local/bin/fsmenu b/scripts/.local/bin/fsmenu @@ -1,52 +1,30 @@ #!/usr/bin/env dash # navigate filesystem with dmenu. -set -eu +set -e -aflag=0 -pflag=0 -filter="" -find_flags="" - -# display usage. -usage() -{ - echo "usage: `basename $0` [-pah] [-t type]" - echo "\t-p, display given path in options" - echo "\t-a, don't hide dotfiles" - echo "\t-h, display usage and exit" - echo "\t-t, pass type argument to find(1)" -} +usage() { echo "usage: `basename $0` [-a] [-t type] [directory]" ;} +dmenu() { command dmenu -l 10 $@ ;} +find() { command find $@ | cut -d/ -f2- ;} -args=`getopt "t:pah" $*` || (usage; exit 2); +args=`getopt "at:" $*` || { usage; exit 2 ;} set -- $args +aflag=0 while [ $# -ne 0 ] do case "$1" in - -t) find_flags="-type $2"; shift 2;; -a) aflag=1; shift;; - -p) pflag=1; shift;; - -h) usage; exit 2;; + -t) type="-type $2"; shift 2;; --) shift; break;; - *) usage; exit 2;; esac done -# note that prefix is quoted in all situations intentionaly, that is because of -# the basename and corrosponding -p flag which would break if multiple -# directories were given. -prefix="${@:-"."}" - -[ $aflag -eq 0 ] && filter="$filter | grep -ve '/\\\.'" -[ $pflag -eq 0 ] && filter="$filter | sed -Ee \"s!^$prefix/?!!\" | grep -v '^$'" - -d="$(eval find "$prefix" $find_flags $filter | dmenu -l 10)" -[ $pflag -eq 0 ] && d="$prefix/$d" -if [ ! -e "$d" ]; then - echo "error: '$d': No such file or directory" 1>&2 - exit 2 +cd ${@:-"."} +if [ $aflag -eq 0 ]; then + dir=`find . $type | grep -v "/\." | dmenu` else - echo "$d" + dir=`find . $type | dmenu` fi +echo "${@%/}/$dir"