1
0
mirror of https://github.com/ohmyzsh/ohmyzsh.git synced 2026-01-22 01:07:36 +08:00

Compare commits

...

4 Commits

Author SHA1 Message Date
Mario A
6ae78695ef
feat(command-not-found): add support for Termux (#9666) 2021-04-09 21:42:11 +02:00
Marc Cornellà
b54a6dab9c
refactor(command-not-found): clean up and reorganize logic 2021-04-09 21:22:25 +02:00
Daniel Wang
8b55fb3b60
feat(command-not-found): add support for Homebrew on Apple M1 (#9797) 2021-04-09 21:22:24 +02:00
Jeff M. Hubbard
9f8801bea6
feat(archlinux)!: remove deprecated commands aur and abs (#9803)
BREAKING CHANGE: the various update aliases will no longer run `abs` and `aur`, which are either
deprecated or nonexistent. See https://archlinux.org/news/deprecation-of-abs/ for more.
2021-04-09 20:48:24 +02:00
4 changed files with 76 additions and 75 deletions

View File

@ -26,13 +26,13 @@ plugins=(... archlinux)
| pacrep | `pacman -Si` | Display information about a package in the repositories |
| pacreps | `pacman -Ss` | Search for packages in the repositories |
| pacrmorphans | `sudo pacman -Rs $(pacman -Qtdq)` | Delete all orphaned packages |
| pacupd | `sudo pacman -Sy && <abs/aur refresh>`[¹](#f1) | Update and refresh local package, ABS and AUR databases |
| pacupd | `sudo pacman -Sy` | Update and refresh local package, ABS and AUR databases |
| pacupg | `sudo pacman -Syu` | Sync with repositories before upgrading packages |
| pacfileupg | `sudo pacman -Fy` | Download fresh package databases from the server |
| pacfiles | `pacman -F` | Search package file names for matching strings |
| pacls | `pacman -Ql` | List files in a package |
| pacown | `pacman -Qo` | Show which package owns a file |
| upgrade[³](#f3) | `sudo pacman -Syu` | Sync with repositories before upgrading packages |
| upgrade[²](#f2) | `sudo pacman -Syu` | Sync with repositories before upgrading packages |
| Function | Description |
|----------------|-----------------------------------------------------------|
@ -70,10 +70,10 @@ upgrades were available. Use `pacman -Que` instead.
| aurrep | `aura -Ai` | Display information about a package from AUR |
| aureps | `aura -As --both` | Search for packages in the repositories and AUR |
| auras | `aura -As --both` | Same as above |
| auupd | `sudo aura -Sy && <abs/aur refresh>`[¹](#f1) | Update and refresh local package, ABS and AUR databases |
| auupd | `sudo aura -Sy` | Update and refresh local package, ABS and AUR databases |
| auupg | `sudo sh -c "aura -Syu && aura -Au"` | Sync with repositories before upgrading all packages (from AUR too) |
| ausu | `sudo sh -c "aura -Syu --no-confirm && aura -Au --no-confirm"` | Same as `auupg`, but without confirmation |
| upgrade[³](#f3) | `sudo aura -Syu` | Sync with repositories before upgrading packages |
| upgrade[²](#f2) | `sudo aura -Syu` | Sync with repositories before upgrading packages |
| Function | Description |
|-----------------|---------------------------------------------------------------------|
@ -96,10 +96,10 @@ upgrades were available. Use `pacman -Que` instead.
| parem | `pacaur -Rns` | Remove packages, including its settings and unneeded dependencies |
| parep | `pacaur -Si` | Display information about a package in the repositories |
| pareps | `pacaur -Ss` | Search for packages in the repositories |
| paupd | `pacaur -Sy && <abs/aur refresh>`[¹](#f1) | Update and refresh local package, ABS and AUR databases |
| paupd | `pacaur -Sy` | Update and refresh local package, ABS and AUR databases |
| paupg | `pacaur -Syua` | Sync with repositories before upgrading all packages (from AUR too) |
| pasu | `pacaur -Syua --no-confirm` | Same as `paupg`, but without confirmation |
| upgrade[³](#f3) | `pacaur -Syu` | Sync with repositories before upgrading packages |
| upgrade[²](#f2) | `pacaur -Syu` | Sync with repositories before upgrading packages |
#### Trizen
@ -118,12 +118,12 @@ upgrades were available. Use `pacman -Que` instead.
| trrem | `trizen -Rns` | Remove packages, including its settings and unneeded dependencies |
| trrep | `trizen -Si` | Display information about a package in the repositories |
| trreps | `trizen -Ss` | Search for packages in the repositories |
| trupd | `trizen -Sy && <abs/aur refresh>`[¹](#f1) | Update and refresh local package, ABS and AUR databases |
| trupd | `trizen -Sy` | Update and refresh local package, ABS and AUR databases |
| trupg | `trizen -Syua` | Sync with repositories before upgrading all packages (from AUR too) |
| trsu | `trizen -Syua --no-confirm` | Same as `trupg`, but without confirmation |
| upgrade[³](#f3) | `trizen -Syu` | Sync with repositories before upgrading packages |
| upgrade[²](#f2) | `trizen -Syu` | Sync with repositories before upgrading packages |
#### Yaourt[²](#f2)
#### Yaourt[¹](#f1)
| Alias | Command | Description |
|---------|-----------------------------------|---------------------------------------------------------------------|
@ -140,12 +140,12 @@ upgrades were available. Use `pacman -Que` instead.
| yarem | `yaourt -Rns` | Remove packages, including its settings and unneeded dependencies |
| yarep | `yaourt -Si` | Display information about a package in the repositories |
| yareps | `yaourt -Ss` | Search for packages in the repositories |
| yaupd | `yaourt -Sy && <abs/aur refresh>`[¹](#f1) | Update and refresh local package, ABS and AUR databases |
| yaupd | `yaourt -Sy` | Update and refresh local package, ABS and AUR databases |
| yaupg | `yaourt -Syua` | Sync with repositories before upgrading all packages (from AUR too) |
| yasu | `yaourt -Syua --no-confirm` | Same as `yaupg`, but without confirmation |
| upgrade[³](#f3) | `yaourt -Syu` | Sync with repositories before upgrading packages |
| upgrade[²](#f2) | `yaourt -Syu` | Sync with repositories before upgrading packages |
#### Yay[²](#f2)
#### Yay[¹](#f1)
| Alias | Command | Description |
|---------|--------------------------------|-------------------------------------------------------------------|
@ -162,21 +162,17 @@ upgrades were available. Use `pacman -Que` instead.
| yarem | `yay -Rns` | Remove packages, including its settings and unneeded dependencies |
| yarep | `yay -Si` | Display information about a package in the repositories |
| yareps | `yay -Ss` | Search for packages in the repositories |
| yaupd | `yay -Sy && <abs/aur refresh>`[¹](#f1) | Update and refresh local package, ABS and AUR databases |
| yaupd | `yay -Sy` | Update and refresh local package, ABS and AUR databases |
| yaupg | `yay -Syu` | Sync with repositories before upgrading packages |
| yasu | `yay -Syu --no-confirm` | Same as `yaupg`, but without confirmation |
| upgrade[³](#f3) | `yay -Syu` | Sync with repositories before upgrading packages |
| upgrade[²](#f2) | `yay -Syu` | Sync with repositories before upgrading packages |
---
<span id="f1">¹</span>
If the `abs` and/or `aur` commands are present, `sudo abs` and `sudo aur` are also
called to update the ABS and AUR databases.
<span id="f2">²</span>
Yay and Yaourt aliases overlap. If both are installed, yay will take precedence.
<span id="f3">³</span>
<span id="f2">²</span>
The `upgrade` alias is set for all package managers. Its value will depend on
whether the package manager is installed, checked in the following order:
@ -199,3 +195,4 @@ whether the package manager is installed, checked in the following order:
- MatthR3D - matthr3d@gmail.com
- ornicar - thibault.duplessis@gmail.com
- Ybalrid (Arthur Brainville) - ybalrid@ybalrid.info
- Jeff M. Hubbard - jeffmhubbard@gmail.com

View File

@ -2,12 +2,6 @@
# Pacman #
#######################################
# abs and aur command check
local abs_aur=''
(( ! $+commands[abs] )) || abs_aur+=' && sudo abs'
(( ! $+commands[aur] )) || abs_aur+=' && sudo aur'
# Pacman - https://wiki.archlinux.org/index.php/Pacman_Tips
alias pacupg='sudo pacman -Syu'
alias pacin='sudo pacman -S'
@ -26,7 +20,7 @@ alias pacfileupg='sudo pacman -Fy'
alias pacfiles='pacman -F'
alias pacls='pacman -Ql'
alias pacown='pacman -Qo'
alias pacupd="sudo pacman -Sy$abs_aur"
alias pacupd="sudo pacman -Sy"
alias upgrade='sudo pacman -Syu'
function paclist() {
@ -108,7 +102,7 @@ if (( $+commands[aura] )); then
alias aurrep='aura -Ai'
alias aureps='aura -As --both'
alias auras='aura -As --both'
alias auupd="sudo aura -Sy$abs_aur"
alias auupd="sudo aura -Sy"
alias auupg='sudo sh -c "aura -Syu && aura -Au"'
alias ausu='sudo sh -c "aura -Syu --no-confirm && aura -Au --no-confirm"'
alias upgrade='sudo aura -Syu'
@ -135,7 +129,7 @@ if (( $+commands[pacaur] )); then
alias paorph='pacaur -Qtd'
alias painsd='pacaur -S --asdeps'
alias pamir='pacaur -Syy'
alias paupd="pacaur -Sy$abs_aur"
alias paupd="pacaur -Sy"
alias upgrade='pacaur -Syu'
fi
@ -155,7 +149,7 @@ if (( $+commands[trizen] )); then
alias trorph='trizen -Qtd'
alias trinsd='trizen -S --asdeps'
alias trmir='trizen -Syy'
alias trupd="trizen -Sy$abs_aur"
alias trupd="trizen -Sy"
alias upgrade='trizen -Syu'
fi
@ -175,7 +169,7 @@ if (( $+commands[yaourt] )); then
alias yaorph='yaourt -Qtd'
alias yainsd='yaourt -S --asdeps'
alias yamir='yaourt -Syy'
alias yaupd="yaourt -Sy$abs_aur"
alias yaupd="yaourt -Sy"
alias upgrade='yaourt -Syu'
fi
@ -195,8 +189,7 @@ if (( $+commands[yay] )); then
alias yaorph='yay -Qtd'
alias yainsd='yay -S --asdeps'
alias yamir='yay -Syy'
alias yaupd="yay -Sy$abs_aur"
alias yaupd="yay -Sy"
alias upgrade='yay -Syu'
fi
unset abs_aur

View File

@ -28,5 +28,6 @@ It works out of the box with the command-not-found packages for:
- [macOS (Homebrew)](https://github.com/Homebrew/homebrew-command-not-found)
- [Fedora](https://fedoraproject.org/wiki/Features/PackageKitCommandNotFound)
- [NixOS](https://github.com/NixOS/nixpkgs/tree/master/nixos/modules/programs/command-not-found)
- [Termux](https://github.com/termux/command-not-found)
You can add support for other platforms by submitting a Pull Request.

View File

@ -1,52 +1,62 @@
# Uses the command-not-found package zsh support
# as seen in https://www.porcheron.info/command-not-found-for-zsh/
# this is installed in Ubuntu
## Platforms with a built-in command-not-found handler init file
if [ -x /usr/lib/command-not-found -o -x /usr/share/command-not-found/command-not-found ]; then
function command_not_found_handler {
# check because c-n-f could've been removed in the meantime
if [ -x /usr/lib/command-not-found ]; then
/usr/lib/command-not-found -- "$1"
return $?
elif [ -x /usr/share/command-not-found/command-not-found ]; then
/usr/share/command-not-found/command-not-found -- "$1"
return $?
else
printf "zsh: command not found: %s\n" "$1" >&2
return 127
fi
return 0
}
for file (
# Arch Linux. Must have pkgfile installed: https://wiki.archlinux.org/index.php/Pkgfile#Command_not_found
/usr/share/doc/pkgfile/command-not-found.zsh
# macOS (M1 and classic Homebrew): https://github.com/Homebrew/homebrew-command-not-found
/opt/homebrew/Library/Taps/homebrew/homebrew-command-not-found/handler.sh
/usr/local/Homebrew/Library/Taps/homebrew/homebrew-command-not-found/handler.sh
); do
if [[ -r "$file" ]]; then
source "$file"
unset file
return 0
fi
done
unset file
## Platforms with manual command_not_found_handler() setup
# Debian and derivatives: https://launchpad.net/ubuntu/+source/command-not-found
if [[ -x /usr/lib/command-not-found || -x /usr/share/command-not-found/command-not-found ]]; then
command_not_found_handler() {
if [[ -x /usr/lib/command-not-found ]]; then
/usr/lib/command-not-found -- "$1"
return $?
elif [[ -x /usr/share/command-not-found/command-not-found ]]; then
/usr/share/command-not-found/command-not-found -- "$1"
return $?
else
printf "zsh: command not found: %s\n" "$1" >&2
return 127
fi
}
fi
# Arch Linux command-not-found support, you must have package pkgfile installed
# https://wiki.archlinux.org/index.php/Pkgfile#.22Command_not_found.22_hook
[[ -e /usr/share/doc/pkgfile/command-not-found.zsh ]] && source /usr/share/doc/pkgfile/command-not-found.zsh
# Fedora: https://fedoraproject.org/wiki/Features/PackageKitCommandNotFound
if [[ -x /usr/libexec/pk-command-not-found ]]; then
command_not_found_handler() {
if [[ -S /var/run/dbus/system_bus_socket && -x /usr/libexec/packagekitd ]]; then
/usr/libexec/pk-command-not-found -- "$@"
return $?
fi
# Fedora command-not-found support
if [ -f /usr/libexec/pk-command-not-found ]; then
command_not_found_handler() {
runcnf=1
retval=127
[ ! -S /var/run/dbus/system_bus_socket ] && runcnf=0
[ ! -x /usr/libexec/packagekitd ] && runcnf=0
if [ $runcnf -eq 1 ]; then
/usr/libexec/pk-command-not-found $@
retval=$?
fi
return $retval
}
printf "zsh: command not found: %s\n" "$1" >&2
return 127
}
fi
# OSX command-not-found support
# https://github.com/Homebrew/homebrew-command-not-found
if [[ -s '/usr/local/Homebrew/Library/Taps/homebrew/homebrew-command-not-found/handler.sh' ]]; then
source '/usr/local/Homebrew/Library/Taps/homebrew/homebrew-command-not-found/handler.sh'
# NixOS: https://github.com/NixOS/nixpkgs/tree/master/nixos/modules/programs/command-not-found
if [[ -x /run/current-system/sw/bin/command-not-found ]]; then
command_not_found_handler() {
/run/current-system/sw/bin/command-not-found -- "$@"
}
fi
# NixOS command-not-found support
if [ -x /run/current-system/sw/bin/command-not-found ]; then
command_not_found_handler() {
/run/current-system/sw/bin/command-not-found $@
}
# Termux: https://github.com/termux/command-not-found
if [[ -x /data/data/com.termux/files/usr/libexec/termux/command-not-found ]]; then
command_not_found_handler() {
/data/data/com.termux/files/usr/libexec/termux/command-not-found -- "$1"
}
fi