~pi/aka

ref: 97da1d5192f04d8f4c935df205cc87f977b306fc aka/aka -rwxr-xr-x 576 bytes
97da1d51Paul Ivanov that was easy 1 year, 3 months ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
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

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