~pi/aka

ref: f62ee3266d3bfc99f64ebd3d2b4815d2a77e9f81 aka/aka -rwxr-xr-x 620 bytes
f62ee326Paul Ivanov pretty sweet 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
30
31
#!/bin/sh

# Is this an alias creation? If so, 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
    # TODO - wrap this in if-VERBOSE
    #echo sourcing .aka;
    . ./.aka
fi

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