poldyaev
11/24/2018 - 5:26 AM

refresh-ln-scripts

refresh-ln-scripts

#!/bin/zsh

cd $HOME/sys/bin

find . -maxdepth 1 -type l -delete
find . -mindepth 2 -type f -executable ! -iname "*~" -exec ln -s "{}" . \;
find . -mindepth 2 -type l ! -iname "*~" -exec ln -s "{}" . \;
find . -maxdepth 1 -type f -iname "*~" -exec chmod -x "{}" \;

# Exclude some executable files
NO_LINK="jbig2 Multivalent.jar pdfsizeopt.py png22pnm pngout sam2p"
NO_LINK=$NO_LINK" *.sample"
for i in $NO_LINK; do
  test -L "$i" && rm "$i"
done

for i in $(find . -maxdepth 1 -type l); do
  test -x $(readlink -e "$i") || rm "$i"
done

source ~/.zshrc