How do I install "z" script?
Solution 1
In the z
readme after line 48, it says:
Installation:
Put something like this in your $HOME/.bashrc or $HOME/.zshrc:
. /path/to/z.sh
cd around for a while to build up the db.
You need to download the z.sh
file to a directory of your choosing, then tell your .bashrc
where it is, so your terminal can find it. (The same applies for z-shell, which is just another shell system.) Then, after you use bash for a while, z
will know your favorite locations.
Solution 2
You can download and add to *rc
files using command line as so
# Download to latest to home dir
wget https://raw.githubusercontent.com/rupa/z/master/z.sh -O ~/z.sh
# Add to .bashrc
echo . /path/to/z.sh >> ~/.bashrc
# Add to .zshrc
echo . /path/to/z.sh >> ~/.zshrc
Solution 3
From here
Download
wget https://raw.githubusercontent.com/rupa/z/master/z.sh
.Install
printf "\n\n#initialize Z (https://github.com/rupa/z) \n. ~/z.sh \n\n" >> .bashrc
. This command appends. ~/z.sh
to your .bashrc
file, which in turn tells it to run Z upon start-up.- Reload shell
source ~/.bashrc
.To test how Z works, browse to these directories:
cd /etc/systemd/system cd /usr/share/nano cd /etc/kernel/postinst.d cd ~
Now, from your terminal, type in
z sys
and push the tab button, then enter. Next, typez nano
and hit the tab button, then enter again. You will see in both cases that Z automatically knew tocd
into the first and second directories where we initially browsed.Using Z with Zsh
- Run
printf "\n\n#initialize Z (https://github.com/rupa/z) \n. ~/z.sh \n\n" >> .zshrc
. This command appends. ~/z.sh
to.zshrc
file, which tells it to run Z on start-up.- Reload shell
source ~/.zshrc
.
Using Z with Zsh + Oh My Zsh
Just add z
to the plugins list in ~/.zshrc
plugins=(
git
z
)
Download the z
script to your home directory:
wget https://raw.githubusercontent.com/rupa/z/master/z.sh -O ~/.z
Then:
source ~/.zshrc
Solution 4
When installing scripts like this (shell augmentation), it is usually a good idea to install them to /etc/profile.d
. To download and install in a single step, you can use the following command:
sudo curl https://raw.githubusercontent.com/rupa/z/master/z.sh \
-o /etc/profile.d/z.sh
Some of the advantages of installing your shell modifications on /etc/profile.d
:
- It will be available for all shells and users;
- There's no need to
chmod +x
; - It is easier to uninstall (just remove the file);
- It is easier to remember where you put them.
BuZZ-dEE
A free information society can only be based on free software and open standards. Contact: @buzz-dee:matrix.org using Element client
Updated on September 18, 2022Comments
-
BuZZ-dEE over 1 year
How do I install the shell "z" script directory jumper on Ubuntu 12.10?
-
web.learner over 9 years@VolkerSiegel There is no link in this answer at all, so your comment isn't very helpful. David: It is true however that your answer doesn't provide much explanation. I see the shell comments, but could you expand on those in the answer itself? Thanks.
-
Volker Siegel over 9 years@Seth Yes, I asked on meta related to handling this as "link only", and learned something: meta.askubuntu.com/questions/11980/… I mixed up flagging with commenting on close.
-
muru over 8 years@Alexis Why
/usr/local/bin
? Why executable permissions? It doesn't look like this file has to be executed directly, or that it needs to be somewhere inPATH
. -
muru over 8 years@Alexis Yep, I'm rolling back. Nothing so far indicates that the script needs to be in
PATH
or that it needs to be executable by the user. -
xeruf about 6 yearsthis simply did not work
-
0x49D1 over 5 yearsWorked well on Git Bash for Windows (without sudo of course), thanks!
-
Beltalowda over 5 yearsI used
/usr/local/z
for the installation path and/usr/local/man/man1
for the man page. Execute permissions and inclusion inPATH
weren't necessary after sourcing the script in.bashrc
. Using this method I was able to easily integratez
for all users on the machine (shared dev machine). Thanks! -
Mohamed over 4 years@GAD3R is it really necessary to download the z script ? isn't it integrated the oh-my-zsh fw ?
-
GAD3R over 4 yearsWithout the
z
script you may receive_z_dirs:2: no such file or directory: /home/$USER/.z
error. To reproduce the problem :mv .z .z.bak
, then execute some jumps. -
techfly almost 3 years@GAD3R .z is the data directory. All you have to do is
mkdir .z
. Even if you don't, when you receive the error, it creates the directory, after which the error stops appearing unless you remove the folder again. .z is NOT meant to be the script.