Skip to content

Instantly share code, notes, and snippets.

@Konfekt
Last active September 26, 2024 06:47
Show Gist options
  • Save Konfekt/9f6710df5a96d58f6c0f3408684b180e to your computer and use it in GitHub Desktop.
Save Konfekt/9f6710df5a96d58f6c0f3408684b180e to your computer and use it in GitHub Desktop.
Opensuse Zypper packagement aliases
#!/usr/bin/env bash
command -v zypper >/dev/null 2>&1 || return 1
# Zypper {{{1
zcommands=(
licenses ps shell source-download tos vcmp if patch-info pattern-info product-info pt se wp
)
len=${#zcommands[*]}
for (( i=0; i<len; i++ )); do
c=${zcommands[$i]}
alias z$c="zypper $c"
done
# Custom
alias zh="zypper help"
alias zhse="zypper help search"
# }}}
# Sudo Zypper {{{1
alias sz='sudo zypper'
szcommands=(
inr rm si ve # Packages
dup lp lu pchk patch # Updates
pa pch pd # Patches
ar clean lr mr nr ref rr # Repositories
as ms refs rs ls # Services
al cl ll rl # Locks
)
len=${#szcommands[*]}
for (( i=0; i<len; i++ )); do
c=${szcommands[$i]}
alias sz$c="sudo zypper $c"
done
params="--auto-agree-with-licenses --download in-advance"
alias szin="sudo zypper install $params"
alias szup="sudo zypper update $params"
alias sznin="sudo zypper --non-interactive install $params"
alias sznup="sudo zypper --non-interactive update $params"
unset params
# List Packages Repo
szlpr() { sudo zypper --no-refresh search --details --installed-only --repo "$1" | awk '$1 ~ /^i/{print $3}'; }
# Clean Unneeded Dependencies
szcud() { sudo zypper packages --unneeded | awk -F'|' 'NR==0 || NR==1 || NR==2 || NR==3 || NR==4 {next} {print $3}' | grep -v Name | sudo xargs -r zypper remove --clean-deps; }
# }}}
# ex: set foldmethod=marker:
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment