|
Continuing on in the effort to make bash more me-friendly, I added the ability to assign to the right for variables.
This took an annoying IPC hack as bash execs commands to the right of a pipe in their own subshell, which means
I can't just simply export the variable back into the current shell process. An example and the relevant code follow:
|
16615 ~> grep :0: /etc/passwd | awk -F: '{ print $1 }' | into foo
16616 ~> echo "$foo"
root
sync
shutdown
halt
operator
# allow us to assign to the right
export ENVDIR="${HOME}/.bash_env.d"
into() {
# XXX there has to be a better way to do this IPC
[ ! -d ${ENVDIR} ] && mkdir ${ENVDIR}
cat > ${ENVDIR}/$1
}
into_import() { # call this from your PROMPT_COMMAND
[ ! -d "${ENVDIR}" ] && mkdir "${ENVDIR}"
builtin cd ${ENVDIR}
#find . -cmin -2 -print | each rm {} # if you want to share
for i in * ; do
if [ -f "$i" ]; then
export "$i"="$(< $i)"
rm "$i"
fi
done
builtin cd - >/dev/null
}