config

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

commit 431c6ff5e5f7f8847911183b2df2ca392883dd05
parent b2c762854c93f9b02aadaa0d85a63038596733d5
Author: Jacob R. Edwards <jacobouno@protonmail.com>
Date:   Thu, 10 Sep 2020 11:00:04 -0700

Shorten usage messages and rework argument parsing

Diffstat:
Mscripts/.local/bin/fsmenu | 8++------
Mscripts/.local/bin/mark | 7++++---
Mscripts/.local/bin/w3 | 15++++-----------
3 files changed, 10 insertions(+), 20 deletions(-)

diff --git a/scripts/.local/bin/fsmenu b/scripts/.local/bin/fsmenu @@ -7,22 +7,18 @@ usage() { echo "usage: `basename $0` [-a] [-t type] [directory]" ;} dmenu() { command dmenu -l 10 $@ ;} find() { command find $@ | cut -d/ -f2- ;} -args=`getopt "at:" $*` || { usage; exit 2 ;} -set -- $args - -aflag=0 while [ $# -ne 0 ] do case "$1" in -a) aflag=1; shift;; -t) type="-type $2"; shift 2;; - --) shift; break;; + *) break;; esac done cd ${@:-"."} -if [ $aflag -eq 0 ]; then +if [ ${aflag:-0} -eq 0 ]; then dir=`find . $type | grep -v "/\." | dmenu` else dir=`find . $type | dmenu` diff --git a/scripts/.local/bin/mark b/scripts/.local/bin/mark @@ -1,16 +1,17 @@ #!/usr/bin/env dash # bookmarks via dmenu. +usage() { echo "usage: `basename $0` [-a]" ;} + # configuration dmenu() { command dmenu -l 10 ;} xclip() { command xclip -selection clipboard $* ;} if [ "$1" = "-h" ] then - echo "usage: `basename $0` [-a]" + usage; exit 1 else - if [ "$1" = "-a" ] - then + if [ "$1" = "-a" ]; then cat `find $BOOKMARK -type f` | dmenu | xclip else dmenu < $BOOKMARK/`find $BOOKMARK -type f | awk -F"$BOOKMARK/?" '{print $2}' | dmenu` | xclip diff --git a/scripts/.local/bin/w3 b/scripts/.local/bin/w3 @@ -9,20 +9,13 @@ mirror=searx.prvcy.eu lang=en-US # display usage -usage() -{ - echo "usage, `basename $0` [-oeh] [search-term ...]" - echo "\t-o, output url instead of opening" - echo "\t-e, use environment variable BROWSER" - echo "\t-h, display usage and exit" - echo "\narguments only interperated if first argument." -} +usage() { echo "usage: `basename $0` [-eho] [search-term ...]" ;} case "${1:-"-h"}" in - -o) output=1; shift;; - -e) browser=$BROWSER; shift;; - -h) usage; exit;; + -e) shift; browser=$BROWSER;; + -h) usage; exit 1;; + -o) shift; output=1;; esac query="$(echo -n $@ | sed "s/ /%20/g")"