local-bin/link.sh

22 lines
378 B
Bash
Executable File

#!/bin/sh
node=$(uname -n)
common_files=($(ls $PWD/common))
dest="$HOME/.local/bin/"
# Ensure destination exists
if [ ! -d "$dest" ]; then
mkdir -p "$dest"
fi
if [ -d "$node" ]; then
node_files=($(ls $PWD/$node))
for file in "${node_files[@]}"; do
ln -sf "$PWD/$node/$file" "$dest"
done
fi
for file in "${common_files[@]}"; do
ln -sf "$PWD/common/$file" "$dest"
done