2

I want to make an alias for zsh to download packages by aria2 and install them by pacman, I don't want to use aria2c by adding xfercommand to pacman.conf because of 2 things:

First my internet connection's speed is low and I don't want pacman go lock for some hours,

Second xfercommand doesn't support multi link downloads.

First off, I use this command to download or upgrade and update by pacman:

sudo pacman -Sp [Package] > ~/Documents/.install&& sudo aria2c -c -x16 -x16 -m16 -k1M -j10 -i ~/Documents/.install -d /var/cache/pacman/pkg

But I don't know how to make it alias in zsh?

General Grievance
  • 4,555
  • 31
  • 31
  • 45
GmArian
  • 21
  • 1
  • 4
  • If everything is fixed, no variable values, `alias myalias="sudo pacman -Sp eclipse > ~/Documents/.install&& sudo aria2c -c -x16 -x16 -m16 -k1M -j10 -i ~/Documents/.install -d /var/cache/pacman/pkg"` should make it. – fedorqui Sep 06 '13 at 14:27
  • Sorry my code was wrong , I want it to use myalias works to install any package , for example I could use myalias wget axel , or myalias firefox and I want tha [Package] be a function . – GmArian Sep 06 '13 at 15:18
  • OK. Then you need to create a function. Check http://stackoverflow.com/a/15456145/1983854 for example – fedorqui Sep 06 '13 at 15:19

2 Answers2

7

Install aria2, then edit /etc/pacman.conf by adding the following line to the [options] section:

XferCommand = /usr/bin/aria2c --allow-overwrite=true --continue=true --file-allocation=none --log-level=error --max-tries=2 --max-connection-per-server=2 --max-file-not-found=5 --min-split-size=5M --no-conf --remote-time=true --summary-interval=60 --timeout=5 --dir=/ --out %o %u
Blues Melody
  • 81
  • 2
  • 5
2

Taking from the aria2 arch wiki, you don't need the intermediary install file, just use the flag -i -. I also had to add sudo to the aria command. Looks like this:

pacman -Sp [package] | sudo aria2c -d /var/cache/pacman/pkg/ -i -

I have an aria2 config, so all other options are there.

From what I've seen, if you use aria2 in the XferCommand, it wouldn't do multiple downloads, just use aria2 one link at a time.

As for using a function, try

mypacman() {
  pacman -Sp $1 | sudo aria2c -d /var/cache/pacman/pkg/ -i -
}

The $1 indicates the first thing after the function call will be placed in this place.

Use it like mypacman [package].

Note: It seems the next version of pacman will do parallel downloads out of the box :)

http://allanmcrae.com/

But I won't risk using it right now...