f8022980a3423f25e3d5e1b6a60d2372a2ba006b

Author
Amr Elsayyad <20210190+AmrElsayyad@users.noreply.github.com>
Committer
GitHub <noreply@github.com>
Date

Message

feat(ubuntu): add `apt-fast` support (#13175)

Diff

 1diff --git a/plugins/ubuntu/README.md b/plugins/ubuntu/README.md
 2index 20f5c65ee747b66558068a38f10225a4d86fee1b..4b09ba02ba4c0ec5ce0db32e8ea5fe3302db6543 100644
 3--- a/plugins/ubuntu/README.md
 4+++ b/plugins/ubuntu/README.md
 5@@ -10,10 +10,11 @@ plugins=(... ubuntu)
 6 
 7 ## Aliases
 8 
 9-Commands that use `$APT` will use `apt` if installed or defer to `apt-get` otherwise.
10+Commands that use `$APT` will use `apt-fast` if installed, or `apt` if installed, or defer to `apt-get`
11+otherwise.
12 
13 | Alias   | Command                                                                  | Description                                                                                       |
14-|---------|--------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------|
15+| ------- | ------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------- |
16 | age     | `sudo $APT`                                                              | Run apt-get with sudo                                                                             |
17 | acs     | `apt-cache search`                                                       | Search the apt-cache with the specified criteria                                                  |
18 | acsp    | `apt-cache showpkg`                                                      | Shows information about the listed packages                                                       |
19@@ -26,7 +27,7 @@ Commands that use `$APT` will use `apt` if installed or defer to `apt-get` other
20 | agd     | `sudo $APT dselect-upgrade`                                              | Follows dselect choices for package installation                                                  |
21 | agi     | `sudo $APT install <pkg>`                                                | Install the specified package                                                                     |
22 | agli    | `apt list --installed`                                                   | List the installed packages                                                                       |
23-| aglu    | `sudo apt-get -u upgrade --assume-no`                                    | Run an apt-get upgrade assuming no to all prompts                                                 |
24+| aglu    | `apt list --upgradable`                                                  | List available updates only                                                                       |
25 | agp     | `sudo $APT purge <pkg>`                                                  | Remove a package including any configuration files                                                |
26 | agr     | `sudo $APT remove <pkg>`                                                 | Remove a package                                                                                  |
27 | ags     | `$APT source <pkg>`                                                      | Fetch the source for the specified package                                                        |
28@@ -36,21 +37,20 @@ Commands that use `$APT` will use `apt` if installed or defer to `apt-get` other
29 | agar    | `sudo $APT autoremove`                                                   | Remove automatically installed packages no longer needed                                          |
30 | aguu    | `sudo $APT update && sudo $APT upgrade`                                  | Update packages list and upgrade available packages                                               |
31 | allpkgs | `dpkg --get-selections \| grep -v deinstall`                             | Print all installed packages                                                                      |
32-| kclean  | `sudo aptitude remove -P ?and(~i~nlinux-(ima\|hea) ?not(~n$(uname -r)))` |Remove ALL kernel images and headers EXCEPT the one in use                                         |
33+| kclean  | `sudo aptitude remove -P ?and(~i~nlinux-(ima\|hea) ?not(~n$(uname -r)))` | Remove ALL kernel images and headers EXCEPT the one in use                                        |
34 | mydeb   | `time dpkg-buildpackage -rfakeroot -us -uc`                              | Create a basic .deb package                                                                       |
35 | ppap    | `sudo ppa-purge <ppa>`                                                   | Remove the specified PPA                                                                          |
36 
37-
38 ## Functions
39 
40-| Function          | Usage                                 |Description                                                               |
41-|-------------------|---------------------------------------|--------------------------------------------------------------------------|
42+| Function          | Usage                                 | Description                                                              |
43+| ----------------- | ------------------------------------- | ------------------------------------------------------------------------ |
44 | aar               | `aar ppa:xxxxxx/xxxxxx [packagename]` | apt-add-repository with automatic install/upgrade of the desired package |
45 | apt-history       | `apt-history <action>`                | Prints the Apt history of the specified action                           |
46 | apt-list-packages | `apt-list-packages`                   | List packages by size                                                    |
47 | kerndeb           | `kerndeb`                             | Kernel-package building shortcut                                         |
48 
49-## Authors:
50+## Authors
51 
52 - [@AlexBio](https://github.com/AlexBio)
53 - [@dbb](https://github.com/dbb)
54@@ -59,3 +59,4 @@ Commands that use `$APT` will use `apt` if installed or defer to `apt-get` other
55 - [Nicolas Jonas](https://nextgenthemes.com)
56 - [@loctauxphilippe](https://github.com/loctauxphilippe)
57 - [@HaraldNordgren](https://github.com/HaraldNordgren)
58+- [@AmrElsayyad](https://github.com/AmrElsayyad)
59diff --git a/plugins/ubuntu/ubuntu.plugin.zsh b/plugins/ubuntu/ubuntu.plugin.zsh
60index 7b765a40649d1327de52ae7967ee4ccda9347dff..66e2d52cbe6a802ee79385075abea7e03cec30ed 100644
61--- a/plugins/ubuntu/ubuntu.plugin.zsh
62+++ b/plugins/ubuntu/ubuntu.plugin.zsh
63@@ -1,11 +1,22 @@
64-(( $+commands[apt] )) && APT=apt || APT=apt-get
65+# Detect available package manager (prefer apt-fast > apt > apt-get)
66+if (( $+commands[apt-fast] )); then
67+    APT=apt-fast
68+elif (( $+commands[apt] )); then
69+    APT=apt
70+else
71+    APT=apt-get
72+fi
73 
74 alias acs='apt-cache search'
75 
76 alias afs='apt-file search --regexp'
77 
78 # These are apt/apt-get only
79-alias ags="$APT source"
80+if (( $+commands[apt] )); then
81+    alias ags="apt source"
82+else
83+    alias ags="apt-get source"
84+fi
85 
86 alias acp='apt-cache policy'
87