#!/bin/bash # -*- coding: utf-8 mode: sh -*- vim:sw=4:sts=4:et:ai:si:sta:fenc=utf-8 source "$(dirname "$0")/../../ulib/ulib" && urequire DEFAULTS || exit 1 pyulibdir="$(abspath "$scriptdir/..")" utoolsdir="$(abspath "$scriptdir/../..")" new_pc= show_pc=1 show_path= show_ppath= default=1 while [ -n "$1" ]; do [ "$1" == "-n" ] && default= && show_pc= [ "$1" == "-p" ] && default= && show_path=1 [ "$1" == "-P" ] && default= && show_ppath=1 shift done [ -n "$default" ] && show_pc=1 && show_path=1 && show_ppath=1 function quote_pc() { local s s="${1//\\/\\\\}" s="${s//\"/\\\"}" s="${s//$/\\$}" s="${s//then /then }" s="${s// /; }" echo "$s" } srcdir="$pyulibdir/src" testdir="$pyulibdir/test" pc_prefix="echo /SPP/" if [ "${PROMPT_COMMAND#$pc_prefix}" == "$PROMPT_COMMAND" ]; then new_pc="$pc_prefix; $PROMPT_COMMAND" fi array_from_path path "$PATH" array_del path /usr/local/utools array_del path /usr/local/nutools array_del path "$utoolsdir" array_ins path "$srcdir/uapps" array_ins path "$utoolsdir" array_from_path ppath "$PYTHONPATH" array_del ppath /usr/local/utools array_del ppath /usr/local/nutools array_del ppath "$srcdir" array_del ppath "$testdir" array_ins ppath "$testdir" array_ins ppath "$srcdir" [ -n "$show_pc" -a -n "$new_pc" ] && echo "export PROMPT_COMMAND=\"$(quote_pc "$new_pc")\"" IFS=: [ -n "$show_path" ] && echo "export PATH=\"${path[*]}\"" [ -n "$show_ppath" ] && echo "export PYTHONPATH=\"${ppath[*]}\""