diff options
Diffstat (limited to 'bashrc')
-rw-r--r-- | bashrc/dist/gentoo/common.sh | 1 | ||||
-rw-r--r-- | bashrc/dist/gentoo/portdir.sh | 62 | ||||
-rw-r--r-- | bashrc/node/init.sh | 4 |
3 files changed, 66 insertions, 1 deletions
diff --git a/bashrc/dist/gentoo/common.sh b/bashrc/dist/gentoo/common.sh new file mode 100644 index 0000000..904c440 --- /dev/null +++ b/bashrc/dist/gentoo/common.sh @@ -0,0 +1 @@ +_load dist portdir diff --git a/bashrc/dist/gentoo/portdir.sh b/bashrc/dist/gentoo/portdir.sh new file mode 100644 index 0000000..c10347a --- /dev/null +++ b/bashrc/dist/gentoo/portdir.sh @@ -0,0 +1,62 @@ +# portdir goodies +eportdir() { + if [[ -n "${PORTDIR_CACHE}" ]]; then + echo "${PORTDIR_CACHE}" + elif [[ -d /usr/portage ]]; then + PORTDIR_CACHE="/usr/portage" + eportdir + else + PORTDIR_CACHE="$(portageq portdir)" + eportdir + fi +} + +echo1() { echo "$1"; } + +efind() { + local d cat pkg + d=$(eportdir) + + case $1 in + *-*/*) + pkg=${1##*/} + cat=${1%/*} + ;; + + ?*) + pkg=${1} + cat=$(echo1 ${d}/*-*/${pkg}/*.ebuild) + [[ -f $cat ]] || cat=$(echo1 ${d}/*-*/${pkg}*/*.ebuild) + [[ -f $cat ]] || cat=$(echo1 ${d}/*-*/*${pkg}/*.ebuild) + [[ -f $cat ]] || cat=$(echo1 ${d}/*-*/*${pkg}*/*.ebuild) + if [[ ! -f $cat ]]; then + return 1 + fi + pkg=${cat%/*} + pkg=${pkg##*/} + cat=${cat#${d}/} + cat=${cat%%/*} + ;; + esac + + echo ${cat}/${pkg} +} + +ecd() { + local pc d + pc=$(efind $@) + d=$(eportdir) + [[ $pc == "" ]] && return 1 + cd ${d}/${pc} +} + +usedesc() { + local d + d=$(eportdir) + + echo "global:" + grep "$1 - " ${d}/profiles/use.desc + + echo "local:" + grep ":$1 - " ${d}/profiles/use.local.desc +} diff --git a/bashrc/node/init.sh b/bashrc/node/init.sh index 6bf0924..7683cd9 100644 --- a/bashrc/node/init.sh +++ b/bashrc/node/init.sh @@ -1,3 +1,5 @@ # get node specific data -declare -r _NODENAME=laptop +declare -r _NODENAME=${HOSTNAME} + +_load node $_NODENAME |