Make commands permanent
okotok opened this issue ยท comments
Hi,
I am not a programmer, so it could be that this is basic knowledge. Hope you can help me.
I love using your Overdrive script to get my books, so I can listen to them on other devices. I have it working with just one little issue. Every time I use it, I have to enter the commands you mention in the text below before I can do cd Downloads ---> Overdrive Download MyBook.odm.
Is there any way to make these commands permanent, so I don't have to enter them every time I restart Terminal?
Thanks in advance and thanks for your script!
Chris
At this point, if calling overdrive produces the error message -bash: overdrive: command not found, you'll need to add ~/.local/bin to your PATH. One way to do this:
printf 'export PATH=$HOME/.local/bin:$PATH\n' >> ~/.bashrc
source ~/.bashrc
The printf ... >> ~/.bashrc
line is supposed to do precisely that โ allow you to use the script on a fresh Terminal. Hard to say what your setup is missing, but a couple ideas:
- If you're on macOS Catalina (10.15) or later, and haven't changed any defaults, your shell is probably zsh, not bash, so try the alternative sequence from the README (i.e.,
printf 'export PATH=$HOME/.local/bin:$PATH\n' >> ~/.zshrc
). Or you know what? Just run the alternative anyway. Can't hurt. - It sounds like you installed the script correctly ๐ (you don't have to re-download and chmod it each time), so you could just call it directly. I.e., at the Terminal prompt, instead of the typical:
you'd put this:
overdrive download MyBook.odm
...it's a few extra characters, but more potentially more reliable.~/.local/bin/overdrive download MyBook.odm
Lmk if/which of those works, and I'll update the README to clarify things for other users, if relevant.
Thanks for the reply. After I wrote, I did a bit of research into it. I found that my .bashrc file had 21 lines with the line "export PATH=$HOME/.local/bin:$PATH". Probably one line for each time I have used your script. I still don't know why I have to refer to this file every time with the source command, but I found that I actually only needed to use that command and not keep adding lines to the file.
After a little more research, I decided to try to add the path to the system using "sudo nano /etc/paths". But I couldn't figure out (again - newbie) what text should be in the paths file exactly.
Finally, I thought to myself: Why keep trying to add the path when the paths file has several working ones. So I copied you script from /.local/bin to /usr/bin and now it works without having to type the path commands first. I don't know if this method is recommended or if it is unsafe in any way, but it works.
Again, thanks for a nice script which makes my book reading quite a bit more mobile and enjoyable!
I found that my .bashrc file had 21 lines with the line [...]
Haha, oops ๐ That makes sense though and would be harmless as far as I know.
sudo nano /etc/paths
That'd work, as would creating a new file like /etc/paths.d/my_user_local_bin
, but since those are both system-level, you'd have to use the absolute path, i.e., resolving ~
to the full path for your user. Also, on macOS, both of those locations are owned by root
and read-only for everybody else, so you'd have to sudo
to do anything with them, which is why they're not part of the mainstream installation instructions.
copied [...] to /usr/bin
Sure, that's another way to do it. Again, by default on macOS, root
owns /usr/bin
, so that would require sudo
at some point; thus, not recommended. Not unsafe, though it might get wiped the next time you upgrade your OS.
Glad the script's working for you, and that you learned a little shell scripting along the way ๐