:: Re: [DNG] funny little program
Top Pagina
Delete this message
Reply to this message
Auteur: Rainer Weikusat
Datum:  
Aan: dng
Onderwerp: Re: [DNG] funny little program
hal <vmlinux@???> writes:
> tilt! wrote on 04/23/2016 02:02 PM:
>> Am 22.04.2016 um 21:52 schrieb Rainer Weikusat:
>>> People who may not know it yet but who are (like me) prone to
>>> inverting two letter command names every once in a while might want
>>> to have a look at the sl package/ program.
>>
>> Unfortunately it is not possible to provide such helper programs for
>> cat, cd, cp, dd, dh, gpg, gs, ln, nl, nop, pip, pon, pwd, ss, tac,
>> test and tset. :-)
>
> Could aliases be utilized for this?
> alias sl="/bin/ls -lart"


When using bash, a shell-function could be used to try to auto-correct
two letter commands,

-----------
command_not_found_handle()
(
    ocmd="$1"


    test ${#1} -eq 2 && {
    cmd=$(type -p "`echo $1 | sed 's/\(.\)\(.\)/\2\1/'`")


    test -n "$cmd" && {
        shift
        test -n "$1" && args=" $*"
        printf '%s%s? ' "$cmd" "$args" >&2


        read yn
        expr "$yn" : '[yY]' >/dev/null 2>&1 && exec "$cmd" "$@"
    }
    }


    printf '%s: command not found\n' "$ocmd" >&2
    return 127
)
-----------


OTOH, I like the steam locomotive as a friendly reminder that 'hurrying'
doesn't always mean 'getting stuff done more quickly'.