2

I'm attempting to install this and running into issues. I am supposed to add a line to the ".bashrc" file? Where in the file? the bottom? the top? somewhere in the if statement? do I make it an alias?

Link to z site: https://github.com/rupa/z

Here's my .bashrc:

echo ". ~/z.sh" > ~/.bashrc
6
  • Just put it anywhere. the end will do.
    – Hasturkun
    May 16, 2013 at 16:25
  • z.sh is in my / directory --- .bashrc is in my /etc/ directory --- at the end of my .bashrc, I added: . ~/z.sh --- I get: -bash: z: command not found
    – Samuel Stiles
    May 16, 2013 at 16:28
  • 2
    Add it to your ~/.bashrc, and use an absolute path. Also, this won't affect a running shell. though you could run . ~/z.sh in one for that.
    – Hasturkun
    May 16, 2013 at 16:29
  • I don't have a ~/.bashrc --- should I just drag it from /etc/ into /? --- and what's an absolute path?
    – Samuel Stiles
    May 16, 2013 at 16:31
  • If you don't have one, create one. An absolute path is of the form /home/user/z.sh or similar.
    – Hasturkun
    May 16, 2013 at 16:33

1 Answer 1

2

Back up a second. /etc/bash.bashrc is the system-wide settings file for bash. $HOME/.bashrc (often abbreviated as ~/.bashrc) has your user's personal settings. ~/.bashrc is read everytime you start a new shell (open a terminal) and so is /etc/bash.bashrc, you don't need to copy anything from one to the other, both will be read.

So, if your system has no ~/.bashrc, all you need to do is create one and add the relevant line to it:

echo ". ~/z.sh" >> ~/.bashrc

That's it.

The . is an alias to bash's source:

source: source filename [arguments]
    Execute commands from a file in the current shell.

    Read and execute commands from FILENAME in the current shell.
8
  • I created ".bashrc" in my /home directory --- it's contents can be seen in my post (edited above) --- z.sh is also located in my home directory --- I still get -bash: z: command not found May 16, 2013 at 16:49
  • @SamuelStiles /home is not your home directory, /home/your_username is. Both .bashrc and z.sh should be in your /home/your_username directory. Just run this command: cp /home/.bashrc /home/z.sh $HOME.
    – terdon
    May 16, 2013 at 16:51
  • done.... stil getting -bash: z: command not found :S I'm logged in as root, will that muck with things? May 16, 2013 at 16:55
  • Correction: I had to re-open my terminal window. It now appears to be working! Thank you! May 16, 2013 at 16:59
  • @SamuelStiles yes, .bashrc is read every time bash is started so you need to restart bash (open a terminal) for it to be read. If my answer helped you please mark it as accepted.
    – terdon
    May 16, 2013 at 17:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.