gnu-arch-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Gnu-arch-users] Convenience shell macros


From: Brian May
Subject: [Gnu-arch-users] Convenience shell macros
Date: Sun, 01 Feb 2004 10:58:02 +1100
User-agent: Gnus/5.1006 (Gnus v5.10.6) Emacs/21.3 (gnu/linux)

People might be interested in the macros I have written for zsh
(I suspect these will run under any POSIX sh, not tested).

They are designed to save on typing for frequent commands I use.

Before tla/arch I had:

alias md="mkdir "
[ md = make dir ]

alias rd="rmdir "
[ rd = remove dir ]

alias rcd="TEMP="\`"pwd"\`";cd ..;rmdir "\$"TEMP"
[ rcd = Remove Current Directory]

acd()
{
        mkdir $1 &&
        cd $1
}
[acd = Add Current Directory]

Now I have added new macros, similar to the above for TLA:

tmd()
{
        mkdir $1 &&
        tla add $1
}

trd()
{
        rm $1/.arch-ids/\=id &&
        rmdir $1/.arch-ids &&
        rmdir $1
}

alias trcd="TEMP="\`"pwd"\`";cd ..;trd "\$"TEMP"

tacd() 
{
        mkdir $1 &&
        tla add $1 &&
        cd $1
}

Also:

tmv()
{
        tla mv $*
}

trm()
{
        tla delete $* &&
        rm $*
}

The only one I am still not entirely happy with is "trd" (TLA Remove
Directory). I would rather an atomic operation, and have it came up
with an error if there are any unexpected files in this directory, but
I don't know the best way to detect this condition...

Any comments? Are these useful for anyone?

Disclaimers:

1. I am not a shell programming expert. I think there was a good
reason why some a functions and others a aliases, but I can't remember
why...

2. I haven't yet tested trd, trcd, or trm...
-- 
Brian May <address@hidden>




reply via email to

[Prev in Thread] Current Thread [Next in Thread]