Last active
February 4, 2021 18:38
-
-
Save funasoul/8124969ffaf27a738b5b5df3a3554963 to your computer and use it in GitHub Desktop.
apt とか yum のオプションを覚えるのが面倒だったので MacPorts のコマンドで動くように。~/.zshrc に入れておく。
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if [[ "$OSTYPE" == "linux-gnu" ]] | |
then | |
export DISTRO=$(lsb_release -si) | |
fi | |
port_usage() { | |
echo "port: A wrapper function for $1." | |
echo "Supported commands:" | |
echo " port clean" | |
echo " port contens \$package" | |
echo " port dependents \$package" | |
echo " port deps \$package" | |
echo " port info \$package" | |
echo " port install \$package" | |
echo " port installed" | |
echo " port outdated" | |
echo " port provides =command" | |
echo " port search \$package" | |
echo " port selfupdate" | |
echo " port uninstall \$package" | |
echo " port upgrade \$package" | |
} | |
port() { | |
if [[ "$OSTYPE" == "linux-gnu" ]]; then | |
if [[ "$DISTRO" == "Ubuntu" ]]; then | |
if [[ "$1" != "" ]]; then | |
case "$1" in | |
cl*) sudo apt autoremove ;; | |
content*) shift; dpkg -L $* ;; | |
dependents) shift; apt rdepends --installed $* ;; | |
deps) shift; apt depends $* ;; | |
inf*) shift; apt show $* ;; | |
installe*) apt list --installed ;; | |
install) shift; sudo apt install $* ;; | |
o*) apt list --upgradable ;; | |
provi*) shift; dpkg -S $* ;; | |
sea*) shift; noglob apt search $* ;; | |
self*) sudo apt update ;; | |
uninstall) shift; sudo apt remove $* ;; | |
upgrade) shift; sudo apt upgrade $* ;; | |
*) apt $* ;; | |
esac | |
else | |
port_usage apt | |
fi | |
elif [[ "$DISTRO" == "CentOS" ]]; then | |
if [[ "$1" != "" ]]; then | |
case "$1" in | |
cl*) sudo yum clean packages ;; | |
content*) shift; rpm -ql $* ;; | |
dependents) shift; repoquery --whatrequires $* ;; | |
deps) shift; yum deplist $* ;; | |
inf*) shift; yum info $* ;; | |
installe*) repoquery --all --qf="%{name}.%{arch} %{version}-%{release} %{repo}" --pkgnarrow=installed ;; | |
install) shift; sudo yum install $* ;; | |
o*) repoquery --all --qf="%{name}.%{arch} %{version}-%{release} %{repo}" --pkgnarrow=updates ;; | |
provi*) shift; yum provides $* ;; | |
sea*) shift; noglob yum search $* ;; | |
self*) sudo yum check-update ;; | |
uninstall) shift; sudo yum remove $* ;; | |
upgrade) shift; sudo yum update $* ;; | |
*) yum $* ;; | |
esac | |
else | |
port_usage yum | |
fi | |
else | |
echo "I guess your Linux is not CentOS nor Ubuntu." | |
fi | |
else | |
command port $* | |
fi | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment