Mercurial > dotfiles
view .shell.d/00.path_manipulation.sh @ 480:4c5814d3cfd8
afcopy: some enhancements from Bryan's dotfiles
This makes `afcopy` able to drop things in the clipboard over ssh. Wild stuff.
See
https://bitbucket.org/bcmills/dotfiles/src/101956eeb90160f1d225ae23c8e6566c9df91c5c/bin/clip?at=default&fileviewer=file-view-default
for some details.
author | Augie Fackler <raf@durin42.com> |
---|---|
date | Thu, 14 Mar 2019 10:38:49 -0400 |
parents | 7dfb7799567f |
children | c85072e620a8 |
line wrap: on
line source
# Functions for manipulating $PATH. Split out so I can use them in .zshenv if I want. function insert_path_element() { insert_element_into_var $1 PATH } function remove_path_element() { remove_element_from_var $1 PATH } function insert_element_into_var () { eval varcontents=\$"$2" eval varname="$2" newcomp="$1" if echo "$varcontents" | grep "$newcomp:" >> /dev/null; then true elif [[ "$varcontents" == "" ]] ; then export $varname="$newcomp" else export $varname="$newcomp:$varcontents" fi } function remove_element_from_var() { eval varcontents=\$"$2" eval varname="$2" newcomp="$1" if echo "$varcontents" | grep "$newcomp:" >> /dev/null; then export $varname="`echo $varcontents | sed s%$newcomp:%%`" elif [[ "$varcontents" == "$newcomp" ]] ; then unset $varname else echo $1 not in $varname fi }