Install multiple ppas at once via terminal without using script
Solution 1:
It doesn't work because who wrote the original script (you can look at it, it's a python script) didn't think that could be useful.
The rationale may be that adding a repository is a thing that is better done slowly. You should check the signature for example --- and double check you really want it.
So it's basically a design decision. You could probably easily modify the script if you want it, or repeating the command on the command line...
for i in ppa:noobslab/malys-themes ppa:alecive/antigone ppa:nitrux/nitrux-artwork ppa:upubuntu-com/themes; do sudo add-apt-repository $i; done
(is that a script or not? A rose is a rose under another name?)
Don't do this, but... unix is famous for letting user shooting themselves in the foot,so...
If you really want your "multiple add-apt-repository"(1) work, do this:
1) find where add-apt-repository is.
(0)samsung-romano:~% which add-apt-repository
/usr/bin/apt-add-repository
2) rename it
(0)samsung-romano:~% sudo mv /usr/bin/add-apt-repository /usr/bin/add-apt-repository.real
3) replace it with a simple script:
(0)samsung-romano:~% sudo gedit /usr/bin/add-apt-repository
with the contents:
#! /bin/bash
#
for i in "$@"; do
/usr/bin/add-apt-repository.real "$i"
done
4) make it executable:
(0)samsung-romano:~% chmod a+rx /usr/bin/add-apt-repository
5) and now you can use your command:
(0)samsung-romano:~% sudo add-apt-repository ppa:noobslab/malys-themes ppa:alecive/antigone ppa:nitrux/nitrux-artwork ppa:upubuntu-com/themes
Why you should not do it? Because next time there will be an update to the package that contains the original apt-add-repository
, problems will arise. Like having your script overwritten or (worst) not having the package updated.
It is in effect much better to avoid touching the system program and simply put the script in your ~/bin
with another name, like my_aptadd
. You are now safe and happy.
Or if you are really fond of the original name, you can create a directory in your home folder like ~/override
, prepend it to your PATH in .profile
(like export PATH=$HOME/override:$PATH
), and save the script there --- obviously with the full path, original /usr/bin/add-apt-repository
in it to avoid an infinite loop. You will then regret it when someone will drop a file called "ls" in it with content exe rm $*
(2), but hey...
So why I wrote it here? Because this is really a useful technique sometime to "fix" programs that otherwise will not run. For example, I have this to add environment variables to programs that otherwise will misbehave, and that are called by other programs that I can't or won't modify.
Footnotes:
(1) I never noticed before but in my system exists even apt-add-repository
, which is a symlink to add-apt-repository
. I can understand why, but it's a call for a mess waiting to happen...
(2) it's wrong. On purpose.
Solution 2:
I've been over this before when talking about how to backup installed PPAs. The following takes a file where all your PPAs are listed and installs them:
<~/ppa-backup.txt xargs -I % sudo add-apt-repository %
It's fairly trivial to tune that to take a list:
xargs -I % sudo add-apt-repository % <<EOF
ppa:noobslab/malys-themes
ppa:alecive/antigone
ppa:nitrux/nitrux-artwork
ppa:upubuntu-com/themes
EOF
Why does
apt-get install ...
accept multiple arguments andadd-apt-repository
not?
Simply because they're different commands, written for different purposes by different people. Why don't less
and rm
take the same arguments? They're different things.
Adding a bunch of repos is really an edge case. It's not like wanting to install more than one package at a time. It also complicates the syntax. add-apt-repository takes a few different formats already, some that include spaces. Parsing that sanely is hard work to get right.
Is there any workaround to make your line work?
Sure. You either write a wrapper for add-apt-repository
and prioritise it or edit the original... Is that a sane thing to do? No, not at all. You'll be breaking the existing add-apt-repository
(see above) in a non-standard way, for what? To save keystrokes on something you run once?
There are multiple one-command methods of splitting this out, as multiple people are telling you. Don't fight the system, use it.
Solution 3:
Try to put something like this:
sudo add-apt-repository ppa:noobslab/malys-themes && sudo add-apt-repository ppa:alecive/antigone && ...
or
sudo add-apt-repository ppa:noobslab/malys-themes; sudo add-apt-repository ppa:alecive/antigone; ...
if the ppa is trusted and needs to be installed any way then -y
can be added as well to force install
sudo add-apt-repository ppa:noobslab/malys-themes -y; sudo add-apt-repository ppa:alecive/antigone -y; ...
So in this format:
command && next_command && next_command
or
command; next_command; next_command
It might work.