Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: directory alias
- X-seq: zsh-users 18192
- From: TJ Luoma <luomat@xxxxxxxxx>
- To: shawn wilson <ag4ve.us@xxxxxxxxx>
- Subject: Re: directory alias
- Date: Tue, 3 Dec 2013 23:41:20 -0500
- Cc: Zsh Users <zsh-users@xxxxxxx>
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-type; bh=RASSJfmU6xnbYzTyYMzx/2hGG78auqwJBcH/QQWOhxM=; b=d6RPkmSJq6gmQDHjdvexcQAv7hy4n1HD0eHPfHleJivVBXKZHMaACQ1qtHBr269WRd XUPUR42M30ez0YwMWenriI40aqxePSh+jxGYvIV3/5FKbV5glcDBHE4Yd884ZfMaI+fC iyEDtv1s8DDGRJUcZ5LCh529Sm9c/TWEK2nW6u1axIIJ9ohgjzBXff/GvymdhB0jzzzG dZJ4UmgUnr2tgLy4B/0kn91qxqyKmHfYl2jv8YP0lP8h6IS1fmKKiZXBsnWFD0OQ0Z3h wK12ocq/jnBsWDeMvs+OXnLBnqp+w+bw4bLCVv98j0AFpe6kyXQeilpUAfpxja/Wwffe EQeA==
- In-reply-to: <CAH_OBidDmzECfgLVcEUmRj2+bean+WjuBvgiPV6SoE9i0kPfKA@mail.gmail.com>
- List-help: <mailto:zsh-users-help@zsh.org>
- List-id: Zsh Users List <zsh-users.zsh.org>
- List-post: <mailto:zsh-users@zsh.org>
- Mailing-list: contact zsh-users-help@xxxxxxx; run by ezmlm
- References: <CAH_OBidDmzECfgLVcEUmRj2+bean+WjuBvgiPV6SoE9i0kPfKA@mail.gmail.com>
I make variables for directories I use a lot
db="$HOME/Dropbox"
bin="$db/bin"
and then I can use that to either move files (mv foo $bin) or 'cd' to them
just by typing the variable "$db" and hitting enter.
But if that's what you mean by a "universal alias", then you'd have to do
something else.
You could make your own `cd` function
function cd {
if [ "$#" = "0" ]
then
# if no arg, go to $HOME
chdir "$HOME"
else
if [ -d "$@" ]
then
# if the arg is a valid directory, go there
chdir "$@"
else
case "$@" in
bar)
chdir /usr/local/some/path/bar
;;
foo)
chdir ~/some/deep/directory/tree/foo
;;
*)
echo "chdir: no such file or directory: $@"
return 1
;;
esac
fi
fi
}
On Tue, Dec 3, 2013 at 10:21 PM, shawn wilson <ag4ve.us@xxxxxxxxx> wrote:
> not sure if this is really a 'zsh thing' but I'm looking for a way to
> create aliases for a command. I don't want a bunch of symlinks in my
> home directory, and I don't want a universal alias for each directory
> I commonly cd into. What I want is a way to do:
> cd foo
> and it go to ~/some/deep/directory/tree/foo
> and
> cd bar
> and it go to /usr/local/some/path/bar
>
> Is there some zsh-ism (or better bash-ism that also works in zsh so
> that this works on systems I maintain without zsh) to do this without
> symlinks?
>
Messages sorted by:
Reverse Date,
Date,
Thread,
Author