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