summaryrefslogtreecommitdiff
path: root/functions.zsh
blob: b068b3c9bdb86cc8632deb80b1cc651c41c48dc9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
if [[ ${UID} = 0 ]]; then
    return
fi

if [[ -f /lib/gentoo/functions.sh ]]; then
    source /lib/gentoo/functions.sh
fi

wl-clear() {
    wl-copy --clear
    wl-copy --primary --clear
}

with-userns() {
    if [[ ${1} =~ '^[0-9]+$' ]]; then
        local id="${1}"
        shift
    else
        local id="0"
    fi
    unshare --keep-caps --map-auto -S "${id}" -G "${id}" "$@"
}

eunpack() {
    env PORTAGE_USERNAME=${USER} \
        PORTAGE_GRPNAME=${USER} \
        FEATURES="unprivileged" \
        PORTAGE_TMPDIR="${2:-.}" \
        ebuild $(equery which "${1}") clean unpack
}