Zsh: Change Gentoo repo directory aliases a bit

- Check for /etc/gentoo-release instead of calling lsb_release
- Make allrepos command nicer
This commit is contained in:
tastytea 2022-04-08 00:28:05 +02:00
parent 12256f9137
commit 10e4b0ff86
Signed by: tastytea
SSH Key Fingerprint: SHA256:FBkvrOlhq5use1XEttyUGT4bUTDVA1ar9SgIc9P03cM

View File

@ -85,42 +85,40 @@ alias machklein='mksmol'
alias diff='diff --color=auto'
# OS specific settings.
case $(lsb_release -i -s 2> /dev/null) in
Gentoo)
# Directory aliases for some Gentoo paths
for dir in /etc/portage/package.*; do
hash -d -- -${dir##*/}=${dir}
done
if [[ -f /etc/gentoo-release ]]; then
# Directory aliases for some Gentoo paths
for dir in /etc/portage/package.*; do
hash -d -- -${dir##*/}=${dir}
done
# Directory aliases for all enabled repos
function _my_diralias_repo_done()
{
local return_code=${2}
local stdout=${3}
# Directory aliases for all enabled repos
function _my_diralias_repo_done()
{
local return_code=${2}
local stdout=${3}
if [[ ${return_code} -eq 0 ]]; then
if [[ "${stdout%%=*}" == "allrepos" ]]; then
# We got the list of repos
for repo in $(print ${stdout#*=}); do
async_job diralias_repo _my_diralias_repo ${repo}
done
else
# We got the path of a repo
local repo="repo_${stdout%%=*}"
hash -d -- -${repo}="${stdout#*=}"
fi
if [[ ${return_code} -eq 0 ]]; then
if [[ "${stdout%%=*}" == "allrepos" ]]; then
# We got the list of repos
for repo in $(print ${stdout#*=}); do
async_job diralias_repo _my_diralias_repo ${repo}
done
else
# We got the path of a repo
local repo="repo_${stdout%%=*}"
hash -d -- -${repo}="${stdout#*=}"
fi
}
function _my_diralias_repo()
{
print -n "${1}="
portageq get_repo_path / "${1}"
}
async_start_worker diralias_repo
async_register_callback diralias_repo _my_diralias_repo_done
async_job diralias_repo "print -n "allrepos=" && portageq get_repos /"
;;
esac
fi
}
function _my_diralias_repo()
{
print -n "${1}="
portageq get_repo_path / "${1}"
}
async_start_worker diralias_repo
async_register_callback diralias_repo _my_diralias_repo_done
async_job diralias_repo 'print -n "allrepos=$(portageq get_repos /)"'
fi
command -v apt-cache > /dev/null && alias qs="apt-cache search --names-only"