~pi/aka

97da1d5192f04d8f4c935df205cc87f977b306fc — Paul Ivanov 1 year, 3 months ago 46bcf07
that was easy
3 files changed, 26 insertions(+), 4 deletions(-)

M .aka
M README
M aka
M .aka => .aka +1 -1
@@ 1,1 1,1 @@
alias pager=more
alias pager='more'

M README => README +2 -2
@@ 3,10 3,10 @@
A simply "launcher" of command-subcommand style where the the subcommands can
be altered based on configuration

    $ aka pager=more
    $ aka alias pager more
    $ aka pager --version
    more from util-linux 2.36
    $ aka pager=less
    $ aka alias pager less
    $ aka pager --version
    less 551 (GNU regular expressions)
    Copyright (C) 1984-2019  Mark Nudelman

M aka => aka +23 -1
@@ 1,7 1,29 @@
#!/bin/sh

# is this a alias creation? that means we should have at least 3 arguments,
# such as:
#
# $ aka alias pager more
#    \     \     \    \
#     $0    $1    $2   $3
#
#
if [ $# -ge 3 ]  && [ $1 = alias ] ; then
    # cmd='pager'
    cmd=$2
    # make 'more' the new $1
    shift 2
    # get rid of previous aliases for 'pager'
    cat .aka | grep -v "alias $cmd=" > .aka
    # get rid of previous aliases
    echo "alias $cmd='$*'" >> .aka
    exit 0
fi

if [ -e .aka ] ; then
    echo sourcing .aka;
    . ./.aka
fi

echo `type pager`
# TODO - wrap this in if VERBOSE
echo `type $1`