Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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
share|improve this question

migrated from stackoverflow.com May 16 '13 at 16:41

This question came from our site for professional and enthusiast programmers.

    
Just put it anywhere. the end will do. –  Hasturkun May 16 '13 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 '13 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 '13 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 '13 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 '13 at 16:33

1 Answer 1

up vote 1 down vote accepted

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.
share|improve this answer
    
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 –  Samuel Stiles May 16 '13 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 '13 at 16:51
    
done.... stil getting -bash: z: command not found :S I'm logged in as root, will that muck with things? –  Samuel Stiles May 16 '13 at 16:55
    
Correction: I had to re-open my terminal window. It now appears to be working! Thank you! –  Samuel Stiles May 16 '13 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 '13 at 17:00

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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