comparison .bashrc @ 927:6ebd7de4d85e default tip

remove defunkt functionality
author Jeff Hammel <k0scist@gmail.com>
date Sat, 10 May 2025 18:43:15 -0700
parents 0bb00763f6d2
children
comparison
equal deleted inserted replaced
926:f1168a3417d2 927:6ebd7de4d85e
189 # echo $CMD 189 # echo $CMD
190 eval $CMD 190 eval $CMD
191 191
192 } 192 }
193 193
194 chainff() {
195 # chained fast find
196
197 if (( $# < 2 ))
198 then
199 return 1 # bad invocation
200 fi
201
202 RESULTS=`ff "$2" "$1"`
203 shift 2
204
205 for i in $RESULTS
206 do
207 for arg in $@
208 do
209 if grep -il "$arg" "$i" &> /dev/null
210 then
211 touch /dev/null
212 else
213 i=""
214 break
215 fi
216 done
217 if [ -n "$i" ]
218 then
219 echo $i
220 fi
221 done
222 }
223
224
225 cff () {
226 # contextual fastfind
227 if (( $# < 2 )); then
228 local FILENAME='*' # default -- look in all files
229 else
230 local FILENAME=$2
231 fi
232
233 for i in `ff "$1" "$FILENAME"`; do
234 echo -e "$CLR_GREEN--->>> ""$CLR_YELLOWBOLD""$i""$CLR_NOTHING" :
235 grep --color=auto -i -n -C 3 "$1" $i
236 done
237
238 }
239 194
240 ### functions for files 195 ### functions for files
241 196
242 tmpfile() { 197 tmpfile() {
243 # make a temporary file if `tempfile` not available 198 # make a temporary file if `tempfile` not available
366 pyfile() { 321 pyfile() {
367 # python file path 322 # python file path
368 python -c "import $1; print ($1.__file__)" 323 python -c "import $1; print ($1.__file__)"
369 } 324 }
370 325
371 setup-all() {
372 # setup all for development
373 # TODO: flowerbed?
374 for i in *
375 do
376 if [ -e "${i}/setup.py" ]
377 then
378 cd "${i}"
379 python setup.py develop
380 cd ..
381 fi
382 done
383 }
384
385 distribute() { 326 distribute() {
386 # upload to pypi 327 # upload to pypi
387 python setup.py egg_info sdist develop && twine upload dist/* 328 python setup.py egg_info sdist develop && twine upload dist/*
388 } 329 }
389 330
390 render_long_description() { 331 render_long_description() {
391 # check the long_description from the command line: 332 # check the long_description from the command line:
392 # https://docs.python.org/3.1/distutils/uploading.html#pypi-package-display 333 # https://docs.python.org/3.1/distutils/uploading.html#pypi-package-display
393 python setup.py --long-description | rst2html.py > output.html 334 python setup.py --long-description | rst2html.py > output.html
394 }
395
396 nearest-venv() {
397 # find the nearest venv
398
399 if [[ "$#" == "0" ]]
400 then
401 directory=$PWD
402 else
403 directory=$1
404 fi
405
406 directory=$(python -c "import os; print (os.path.abspath('${directory}'))")
407
408 while [[ "${directory}" != "/" ]]
409 do
410 activate="${directory}/bin/activate"
411 if [ -e "${activate}" ]
412 then
413 echo ${directory}
414 return 0
415 fi
416
417 directory=$(dirname ${directory})
418 done
419 return 1
420 }
421
422 activate-nearest() {
423 # activate the nearest virtualenv
424 nearest=$(nearest-venv)
425 activate=${nearest}/bin/activate
426 if [ -e "${activate}" ]
427 then
428 . ${activate}
429 fi
430 }
431
432 recreate-venv() {
433 # recreate a virtualenv
434 VIRTUALENV="virtualenv.py"
435 if ! which ${VIRTUALENV}
436 then
437 return 1
438 fi
439 VENV_PATH=$(which ${VIRTUALENV})
440 echo VENV_PATH=${VENV_PATH}
441
442 # update virtualenv if possible
443 DIRNAME=$(dirname ${VENV_PATH})
444 if [ -d "${DIRNAME}/.git" ]
445 then
446 cd "${DIRNAME}"
447 git pull
448 cd --
449 fi
450
451 # for each virtualenv given...
452 for i in $@
453 do
454 OLD_PWD=${PWD}
455 echo "${i} : OLDPWD=${OLD_PWD}"
456 # ...recreate it...
457 ${VIRTUALENV} --clear "${i}"
458
459 SRCDIR="${i}"/src
460 if [ -d "${SRCDIR}" ]
461 then
462 . "${i}/bin/activate"
463 cd "${SRCDIR}"
464 for j in *
465 do
466 if [ -e "${j}"/setup.py ]
467 then
468 cd "${j}"
469 python setup.py develop
470 cd ..
471 fi
472 done
473 fi
474 echo "cd OLD_PWD=${OLD_PWD}"
475 cd ${OLD_PWD}
476 done
477 } 335 }
478 336
479 ### functions for version control systems 337 ### functions for version control systems
480 338
481 difffiles() { 339 difffiles() {
534 } 392 }
535 393
536 ### 394 ###
537 395
538 apt-upgrade() { 396 apt-upgrade() {
539 sudo apt-get -y update 397 sudo apt-get -y update
540 sudo apt-get -y upgrade 398 sudo apt-get -y upgrade
541 } 399 }
542 400
543 flatten() { 401 flatten() {
544 directory=$PWD 402 directory=$PWD
545 if [ "$#" == "1" ] 403 if [ "$#" == "1" ]
580 438
581 sed ${inplace} "${command}" "$1" 439 sed ${inplace} "${command}" "$1"
582 440
583 } 441 }
584 442
585 rmktmp() {
586
587 TMPDIR=~/tmp
588 if [ -e ${TMPDIR} ]
589 then
590 rm -rf ${TMPDIR}
591 fi
592 mkdir ${TMPDIR}
593 cd ${TMPDIR}
594 pwd
595
596 }
597 443
598 exists() { 444 exists() {
599 while read line; do echo ${line} : $(($(test "-e ${line}"\") )); done 445 while read line; do echo ${line} : $(($(test "-e ${line}"\") )); done
600 } 446 }
601 447
621 then 467 then
622 . deactivate 468 . deactivate
623 fi 469 fi
624 fi 470 fi
625 471
626
627 ### source site-specific BASHRC extensions 472 ### source site-specific BASHRC extensions
628 export LOCAL_BASHRC="${HOME}/.bashrc_local" 473 export LOCAL_BASHRC="${HOME}/.bashrc_local"
629 if [ -e "${LOCAL_BASHRC}" ] 474 if [ -e "${LOCAL_BASHRC}" ]
630 then 475 then
631 . "${LOCAL_BASHRC}" 476 . "${LOCAL_BASHRC}"
637 if [ -e "${HOME}/.ssh/k0s_rsa" ] 482 if [ -e "${HOME}/.ssh/k0s_rsa" ]
638 then 483 then
639 ssh-add "${HOME}/.ssh/k0s_rsa" 484 ssh-add "${HOME}/.ssh/k0s_rsa"
640 fi 485 fi
641 fi 486 fi
642
643 ### AWS credentials
644 # XXX This only works with a credentials file with a single entry
645 # if [[ -f "${HOME}/.aws/credentials" ]]
646 # then
647 # eval $(awk 'NR != 1 { print "export", toupper($1) "=" $3 }' ~/.aws/credentials)
648 # fi
649 487
650 if type -P xmodmap >> /dev/null && [[ -e "${HOME}/capslock" ]] 488 if type -P xmodmap >> /dev/null && [[ -e "${HOME}/capslock" ]]
651 then 489 then
652 xmodmap "${HOME}/capslock" 490 xmodmap "${HOME}/capslock"
653 fi 491 fi
663 regeneratefluxmenu 501 regeneratefluxmenu
664 502
665 export NVM_DIR="$HOME/.nvm" 503 export NVM_DIR="$HOME/.nvm"
666 [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm 504 [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm
667 [ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion 505 [ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion
506 export PYENV_ROOT="$HOME/.pyenv"
507 [[ -d $PYENV_ROOT/bin ]] && export PATH="$PYENV_ROOT/bin:$PATH"
508 eval "$(pyenv init - bash)"