0

I'm trying to use z (link) to make navigating a little easier. The problem is that I have the following in my .zshrc file, but it doesn't seem to work:

export PATH=$PATH:/home/x/z
alias z='/home/x/z/z.sh'
. z

For some reason, the last command never seems to work. If I do it by hand after opening the shell, it's fine but executing it within the .zshrc will not work.

4
  • Shouldn't the last line be . x rather than . z? Commented Sep 3, 2013 at 19:13
  • Whoops, typo. Fixed. Commented Sep 3, 2013 at 19:21
  • 5
    I'm pretty sure source (and its alias .) doesn't consult the list of aliases. Does it work any better if you just specify the full path to the file on that third line? (Note that you can use ~ as a shorthand for the path to your home directory.) Commented Sep 3, 2013 at 20:00
  • Adding to @MichaelKjörling 's answer, you can prepend a backslash to commands to prevent aliasing (e.g. \source z). Commented Sep 4, 2013 at 1:45

1 Answer 1

2

You are misusing aliases. You should use a variable instead.

z='/home/x/z/z.sh' . "$z"

Aliases are for commands. For example,

alias l=ls

That being said, this should work:

export PATH=$PATH:/home/x/z alias z='/home/x/z/z.sh' alias .='. ' . z

The .='. ' alias enables alias expansion. If the first word after . is an alias, it will be expanded.

Also note that /home/x/z does not need to be in your path to source z.sh.

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.