2Z7DEYRKYS5DMQMFIVYGJMKXZRSRPJZHELW4PD3GOOZYGZFEI46QC function pyactivate --description 'activate a pyenv virtualenv by name'set VENV_NAMEfor arg in $argvswitch $argcase --helpecho 'USAGE:'echo " pyactivate [venv_name] activate a pyenv-virtualenv by name"echo ' pyactivate ls list available pyenv-virtualenvs'echoecho ' options:'echo ' --help display this message'return 0case ls listpyenv versionsreturn 0case '--*'error_message --warn --bold "$arg is an unrecognized flag"return 9case '*'if test -n $VENV_NAMEset VENV_NAME $argendendendif not test -n "$VENV_NAME"error_message --alert 'virtual environment name is a required arguemnt'return 1elseif echo (pyenv versions) | grep -qw "$VENV_NAME"set VENV_DIR "$PYENV_ROOT/versions/$VENV_NAME"source $VENV_DIR/bin/activate.fishelseerror_message 'virtual env does not exist'return 2endendend
function error_messageset ERR_STRINGset RING_ALERT_BELL Falseset BOLD_OUTPUT Falseset ERR_COLOR 'red'set NO_COLOR Falsefor arg in $argvswitch $argcase --alert -aset RING_ALERT_BELL Truecase --bold -bset BOLD_OUTPUT Truecase --warn -wset ERR_COLOR 'yellow'case --no-colorset NO_COLOR Truecase '*'set ERR_STRING $ERR_STRING $argendendset ERR_MSG $ERR_STRINGif not eval $NO_COLORset COLOR_FLAGS "--color-$ERR_COLOR"if eval $BOLD_OUTPUTset COLOR_FLAGS '--bold' $COLOR_FLAGSendset ERR_MSG (colorize $COLOR_FLAGS $ERR_STRING)endecho "$ERR_MSG" > /dev/stderrif eval $RING_ALERT_BELLecho -ne '\a'endend
function colorizeset STRINGset COLOR $normalset BOLD_OUTPUT Falsefor arg in $argv# echo 'arg' $arg# echoswitch $argcase ls listset_color -ccase --bold -bset BOLD_OUTPUT Truecase '--color-*'set COLOR (echo $arg | rg '(\-\-color\-)(\w+)' --replace '$2')case '*'set STRING $STRING $argendendif echo (set_color -c) | grep -qw "$COLOR"set COLOR_ESC_SEQ (set_color $COLOR)if eval $BOLD_OUTPUTset COLOR_ESC_SEQ (set_color -o $COLOR)endecho $COLOR_ESC_SEQ $STRING (set_color $normal)elseerror_message "$COLOR is not an available color"endend